春风项目四线(合箱线、总装线)
wujian
2024-09-10 51b05b093fa15dd477981372f67ae7b3b2747733
jcdm-quartz/src/main/java/com/jcdm/quartz/task/RyTask.java
@@ -1,7 +1,12 @@
package com.jcdm.quartz.task;
import cn.hutool.core.collection.CollUtil;
import com.jcdm.main.bs.orderScheduling.domain.BsOrderScheduling;
import com.jcdm.main.bs.orderScheduling.service.IBsOrderSchedulingService;
import com.jcdm.main.da.passingStationCollection.service.IDaPassingStationCollectionService;
import com.jcdm.main.da.passingStationCollection.service.impl.DaPassingStationCollectionServiceImpl;
import com.jcdm.main.om.productionOrde.domain.OmProductionOrdeInfo;
import com.jcdm.main.om.productionOrde.service.impl.OmProductionOrdeInfoServiceImpl;
import com.jcdm.main.webservice.service.ReceivingServices;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -9,7 +14,10 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
 * 定时任务调度测试
@@ -19,6 +27,15 @@
@Component("ryTask")
public class RyTask
{
    @Autowired
    private DaPassingStationCollectionServiceImpl passingStationCollectionServiceImpl;
    @Autowired
    private IBsOrderSchedulingService bsOrderSchedulingService;
    @Resource
    private OmProductionOrdeInfoServiceImpl omProductionOrdeInfoService;
    private static final Logger logger = LoggerFactory.getLogger("sys-user");
    public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i)
    {
@@ -32,11 +49,40 @@
    public void ryNoParams()
    {
        System.out.println("执行无参方法");
        logger.info("执行定时任务开始");
        String a=passingStationCollectionServiceImpl.SelectSN("88","OP010");
        BsOrderScheduling bsOrderScheduling = new BsOrderScheduling();
        bsOrderScheduling.setRemarks("1");
        List<BsOrderScheduling> bsOrderSchedulingList = bsOrderSchedulingService.selectBsOrderSchedulingList(bsOrderScheduling);
        if (CollUtil.isNotEmpty(bsOrderSchedulingList)){
            Map<String, List<BsOrderScheduling>> map = bsOrderSchedulingList.stream().collect(Collectors.groupingBy(BsOrderScheduling::getOrderNo));
            OmProductionOrdeInfo omProductionOrdeInfo = new OmProductionOrdeInfo();
            for (String s : map.keySet()) {
                List<BsOrderScheduling> bsOrderSchedulings = map.get(s);
                if (CollUtil.isNotEmpty(bsOrderSchedulings)){
                    BsOrderScheduling scheduling = bsOrderSchedulings.get(0);
                    int size = bsOrderSchedulings.size();
                    omProductionOrdeInfo.setPlanQty((long)size);
                    omProductionOrdeInfo.setActualQty((long)0);
                    omProductionOrdeInfo.setWorkOrderNo(s);
                    omProductionOrdeInfo.setProductCode(scheduling.getModel());
                    omProductionOrdeInfo.setOrderStatus("2");
                    omProductionOrdeInfo.setTypeZ(scheduling.getModel());
                    omProductionOrdeInfoService.insertOmProductionOrdeInfo(omProductionOrdeInfo);
                    logger.info("插入工单,{}",s);
                }
            }
            for (BsOrderScheduling scheduling : bsOrderSchedulingList) {
                scheduling.setRemarks("0");
                scheduling.setProductionStatus("1");
                bsOrderSchedulingService.updateBsOrderScheduling(scheduling);
            }
        }
        System.out.println("执行过程返回:" + a);
        logger.info("定时任务执行结束");
    }
    @Autowired
    private IBsOrderSchedulingService bsOrderSchedulingService;
    String url = "http://podqapp.cfmoto.com.cn:50100/XISOAPAdapter/MessageServlet?senderParty=&senderService=BC_MES&receiverParty=&receiverService=&interface=SI_ZPP_CF_BC_001_SYN_OUT&interfaceNamespace=http://cfmoto.com/xi/MES";
    public void workReportingTasks(){
        report10();
@@ -47,14 +93,39 @@
        BsOrderScheduling bsOrderScheduling = new BsOrderScheduling();
        bsOrderScheduling.setReport10("0");
        List<BsOrderScheduling> bsOrderSchedulings = bsOrderSchedulingService.selectBsOrderSchedulingList(bsOrderScheduling);
        for (BsOrderScheduling orderScheduling : bsOrderSchedulings) {
            String xmlResult = ReceivingServices.getInterfaceInformationXml(url, getProductionPlanInformationXml(orderScheduling.getOrderNo(), "0010"));
            String status = ReceivingServices.xmlToJSON3(xmlResult);
            if(status.equals("1")){
        String status="";
        String ev_meassage="";
        if (CollUtil.isNotEmpty(bsOrderSchedulings)){
            BsOrderScheduling orderScheduling = bsOrderSchedulings.get(0);
            try {
                String xmlResult = ReceivingServices.getInterfaceInformationXml(url, getProductionPlanInformationXml(orderScheduling.getOrderNo(), "0010"));
                ev_meassage=ReceivingServices.xmlToJSON1(xmlResult);
                status = ReceivingServices.xmlToJSON3(xmlResult);
            } catch (Exception e) {
                status="3";
            }
            if(status.equals("1")) {
                orderScheduling.setReport10("1");
                int i = bsOrderSchedulingService.updateBsOrderScheduling(orderScheduling);
                System.out.println("更新状态成功");
                //logger.info("{}合箱报工成功",orderScheduling.getOrderNo());
                logger.info("{}合箱报工成功",orderScheduling.getOrderNo());
            }else {
                if(StringUtils.isEmpty(orderScheduling.getSpareField1())){
                    orderScheduling.setSpareField1("1");
                    bsOrderSchedulingService.updateBsOrderScheduling(orderScheduling);
                }else{
                    if(Integer.valueOf(orderScheduling.getSpareField1())+1>=3) {
                        //累计报工异常超过3次
                        orderScheduling.setReport10("3");
                        orderScheduling.setSpareField1(String.valueOf(Integer.valueOf(orderScheduling.getSpareField1()) + 1));
                    }else {
                        orderScheduling.setSpareField1(String.valueOf(Integer.valueOf(orderScheduling.getSpareField1()) + 1));
                    }
                    bsOrderSchedulingService.updateBsOrderScheduling(orderScheduling);
                }
                if(status.equals("3"))
                    logger.info("{}合箱报工因为网络原因,报工失败!",orderScheduling.getOrderNo());
                else
                    logger.info("{}合箱报工失败,原因:{}",orderScheduling.getOrderNo(),ev_meassage);
            }
        }
    }
@@ -63,14 +134,39 @@
        BsOrderScheduling bsOrderScheduling = new BsOrderScheduling();
        bsOrderScheduling.setReport20("0");
        List<BsOrderScheduling> bsOrderSchedulings = bsOrderSchedulingService.selectBsOrderSchedulingList(bsOrderScheduling);
        for (BsOrderScheduling orderScheduling : bsOrderSchedulings) {
            String xmlResult = ReceivingServices.getInterfaceInformationXml(url, getProductionPlanInformationXml(orderScheduling.getOrderNo(), "0020"));
            String status = ReceivingServices.xmlToJSON3(xmlResult);
        String status="";
        String ev_meassage="";
        if (CollUtil.isNotEmpty(bsOrderSchedulings)){
            BsOrderScheduling orderScheduling = bsOrderSchedulings.get(0);
            try {
                String xmlResult = ReceivingServices.getInterfaceInformationXml(url, getProductionPlanInformationXml(orderScheduling.getOrderNo(), "0020"));
                ev_meassage=ReceivingServices.xmlToJSON1(xmlResult);
                status = ReceivingServices.xmlToJSON3(xmlResult);
            } catch (Exception e) {
                status="3";
            }
            if(status.equals("1")){
                orderScheduling.setReport20("1");
                int i = bsOrderSchedulingService.updateBsOrderScheduling(orderScheduling);
                System.out.println("更新状态成功");
                //logger.info("{}总装报工成功",orderScheduling.getOrderNo());
                logger.info("{}总装报工成功",orderScheduling.getOrderNo());
            }else {
                if(StringUtils.isEmpty(orderScheduling.getSpareField2())){
                    orderScheduling.setSpareField2("1");
                    bsOrderSchedulingService.updateBsOrderScheduling(orderScheduling);
                }else{
                    if(Integer.valueOf(orderScheduling.getSpareField2())+1>=3) {
                        //累计报工异常超过3次
                        orderScheduling.setReport20("3");
                        orderScheduling.setSpareField2(String.valueOf(Integer.valueOf(orderScheduling.getSpareField2()) + 1));
                    }else{
                        orderScheduling.setSpareField2(String.valueOf(Integer.valueOf(orderScheduling.getSpareField2()) + 1));
                    }
                    bsOrderSchedulingService.updateBsOrderScheduling(orderScheduling);
                    if(status.equals("3"))
                        logger.info("{}总装报工因为网络原因,报工失败!",orderScheduling.getOrderNo());
                    else
                        logger.info("{}总装报工失败,原因:{}",orderScheduling.getOrderNo(),ev_meassage);
                }
            }
        }
    }