新火炬后端单体项目初始化代码
zhangherong
昨天 a27f1b573fc5cf9a3b78e2eacb56e44310f83456
src/main/java/org/jeecg/modules/mes/job/ProductionOrderSyncUpdateJob.java
@@ -1,6 +1,7 @@
package org.jeecg.modules.mes.job;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.modules.lsw.service.ILswMaterialService;
import org.jeecg.modules.mdc.util.DateUtils;
import org.jeecg.modules.mdc.util.ThrowableUtil;
import org.jeecg.modules.mes.entity.MesProductionOrder;
@@ -14,6 +15,7 @@
import org.jeecg.modules.sap.dto.OrderBomDTO;
import org.jeecg.modules.sap.dto.OrderProcessDTO;
import org.jeecg.modules.sap.dto.ProductionOrderDTO;
import org.jeecg.modules.sap.request.ProductionOrderSyncRequest;
import org.jeecg.modules.sap.service.OrderBomSync;
import org.jeecg.modules.sap.service.OrderProcessSync;
import org.jeecg.modules.sap.service.ProductionOrderSync;
@@ -21,6 +23,7 @@
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
@@ -32,7 +35,8 @@
@Slf4j
public class ProductionOrderSyncUpdateJob implements Job {
    //工厂编码(新火炬 2301)
    private static final String FACTORY_CODE = "2301";
    @Value("${xhj.factoryCode:2301}")
    private String FACTORY_CODE;
    /**
     * 订单类型
     * 标准生产订单 Z001
@@ -41,7 +45,8 @@
     * 试制生产订单(新火炬)  Z011
     * 拆零生产订单(新火炬)  2012
     */
    private static final String ORDER_TYPE_CODE = "Z001";
    @Value("${xhj.orderType:Z001}")
    private String ORDER_TYPE_CODE;
    /**
     * 生产调度员
     * 001 一分厂调度员
@@ -56,14 +61,16 @@
     * 010 六厂调度员
     * 012 八分厂调度员
     */
    private static final String PRODUCTION_MANAGER = "010";
    @Value("${xhj.productionManager:012}")
    private String PRODUCTION_MANAGER;
    /**
     * 生产订单状态,实际上,只有REL状态的工单才可以进行操作
     * CRTD 新建
     * REL 下达
     * TECO 关闭
     */
    private static final String ORDER_STATUS = "REL";
    @Value("${xhj.orderStatus:REL}")
    private String ORDER_STATUS;
    /**
     * 请求成功编码
@@ -86,6 +93,8 @@
    private ISysQuartzLogService sysQuartzLogService;
    @Autowired
    private IQuartzJobService quartzJobService;
    @Autowired
    private ILswMaterialService lswMaterialService;
    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
@@ -106,9 +115,16 @@
                lastSyncDateHigh = null;
            }
        }
        ProductionOrderSyncRequest request = new ProductionOrderSyncRequest();
        request.setFactoryCode(FACTORY_CODE);
        request.setOrderTypeCode(ORDER_TYPE_CODE);
        request.setProductionManager(PRODUCTION_MANAGER);
        request.setOrderStatus(ORDER_STATUS);
        request.setUpdateTimeLow(lastSyncDateLow);
        request.setUpdateTimeHigh(lastSyncDateHigh);
        try {
            //调用SAP接口获取生产订单
            Map<String, Object> productionOrderMap = productionOrderSync.syncProductionOrder(FACTORY_CODE, ORDER_TYPE_CODE, PRODUCTION_MANAGER, ORDER_STATUS, null, null, lastSyncDateLow, lastSyncDateHigh);
            Map<String, Object> productionOrderMap = productionOrderSync.syncProductionOrder(request);
            if (productionOrderMap == null || !SUCCESS_CODE.equals(productionOrderMap.get("ztype"))) {
                log.error("未同步到订单信息!日期:{}", LocalDateTime.now());
                return;
@@ -142,6 +158,12 @@
                log.error("保存订单BOM失败,日期:{}", LocalDateTime.now());
                return;
            }
            //物料数据处理
            b = lswMaterialService.saveOrUpdateMaterial(orderMap, orderBomDTOList);
            if (!b) {
                log.error("保存物料失败,日期:{}", LocalDateTime.now());
                return;
            }
            //订单工序同步
            Map<String, Object> orderProcessMap = orderProcessSync.syncOrderProcess(FACTORY_CODE, orderCodes);
            if (orderBomMap == null || !SUCCESS_CODE.equals(orderProcessMap.get("ztype"))) {