#
luxiaotao1123
2021-05-29 4fefa19b04e38c87cc9d97ba7cd125b5105ba323
src/main/java/zy/cloud/wms/manager/controller/LocSyncController.java
@@ -2,7 +2,6 @@
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.core.annotations.ManagerAuth;
import com.core.common.Cools;
import com.core.common.R;
@@ -13,22 +12,18 @@
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import zy.cloud.wms.common.entity.Parameter;
import zy.cloud.wms.common.model.BillDto;
import zy.cloud.wms.common.service.erp.ErpService;
import zy.cloud.wms.common.web.BaseController;
import zy.cloud.wms.manager.entity.LocSum;
import zy.cloud.wms.manager.entity.Pakout;
import zy.cloud.wms.manager.entity.WrkLocSync;
import zy.cloud.wms.manager.service.LocSyncService;
import zy.cloud.wms.manager.service.PakoutService;
import zy.cloud.wms.manager.service.WrkLocSyncService;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
@RestController
@Slf4j
@@ -94,17 +89,19 @@
    }
    /* 同步上传erp[uploadBill] 单据上传 */
    @Scheduled(cron = "0/5 * * * * ? ")
    @Scheduled(cron = "0/2 * * * * ? ")
    public void execute() {
        if (!Cools.isEmpty(Parameter.get().getSyncSwitch()) && Parameter.get().getSyncSwitch().equals("Y")) {
        List<String> orderList = new ArrayList<>();
        orderList.add("state");
        orderList.add("create_time");
        List<WrkLocSync> syncList = wrkLocSyncService.selectList(new EntityWrapper<WrkLocSync>().orderDesc(orderList));
            List<WrkLocSync> syncList = wrkLocSyncService.selectList(new EntityWrapper<WrkLocSync>()
                    .eq("state", "N").orderDesc(orderList));
        // 同步上传清单处理,取第一条
        if (!Cools.isEmpty(syncList)) {
            WrkLocSync executeData = syncList.get(0);
            // 订单号
            String docNum = String.valueOf(snowflakeIdWorker.nextId());
                String docNum = "PU-" + String.valueOf(snowflakeIdWorker.nextId()).substring(0, 15);
            // 订单类型 34采购单
            Integer docId = 34;
            List<BillDto> dtos = new ArrayList<BillDto>();
@@ -120,7 +117,7 @@
            } else {
                // 失败后将任务状态state更新为N
                executeData.setState("X");
                executeData.setUpdateBy(getUserId());
                    executeData.setUpdateBy(9527L);
                executeData.setCreateTime(new Date());
                if(!wrkLocSyncService.update(executeData, new EntityWrapper<WrkLocSync>().eq("matnr", executeData.getMatnr()))) {
                    log.info("库存同步更新任务失败,任务matnr=" + executeData.getMatnr() + "时间=" + new Date());
@@ -128,4 +125,6 @@
            }
        }
    }
    }
}