| | |
| | | |
| | | 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; |
| | |
| | | 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 |
| | |
| | | } |
| | | |
| | | /* 同步上传erp[uploadBill] 单据上传 */ |
| | | @Scheduled(cron = "0/5 * * * * ? ") |
| | | @Scheduled(cron = "0/2 * * * * ? ") |
| | | public void execute() { |
| | | List<String> orderList = new ArrayList<>(); |
| | | orderList.add("state"); |
| | | orderList.add("create_time"); |
| | | List<WrkLocSync> syncList = wrkLocSyncService.selectList(new EntityWrapper<WrkLocSync>().orderDesc(orderList)); |
| | | // 同步上传清单处理,取第一条 |
| | | if (!Cools.isEmpty(syncList)) { |
| | | WrkLocSync executeData = syncList.get(0); |
| | | // 订单号 |
| | | String docNum = String.valueOf(snowflakeIdWorker.nextId()); |
| | | // 订单类型 34采购单 |
| | | Integer docId = 34; |
| | | List<BillDto> dtos = new ArrayList<BillDto>(); |
| | | BillDto res = new BillDto(); |
| | | res.setMatnr(executeData.getMatnr()); |
| | | res.setQty(executeData.getQty()); |
| | | dtos.add(res); |
| | | if (erpService.uploadBill(dtos, docId, docNum)) { |
| | | // 成功后删除任务 |
| | | if (!wrkLocSyncService.delete(new EntityWrapper<WrkLocSync>().eq("matnr", executeData.getMatnr()))) { |
| | | log.info("库存同步删除任务失败,任务matnr=" + executeData.getMatnr() + "时间=" + new Date()); |
| | | } |
| | | } else { |
| | | // 失败后将任务状态state更新为N |
| | | executeData.setState("X"); |
| | | executeData.setUpdateBy(getUserId()); |
| | | executeData.setCreateTime(new Date()); |
| | | if(!wrkLocSyncService.update(executeData, new EntityWrapper<WrkLocSync>().eq("matnr", executeData.getMatnr()))) { |
| | | log.info("库存同步更新任务失败,任务matnr=" + executeData.getMatnr() + "时间=" + new Date()); |
| | | 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>() |
| | | .eq("state", "N").orderDesc(orderList)); |
| | | // 同步上传清单处理,取第一条 |
| | | if (!Cools.isEmpty(syncList)) { |
| | | WrkLocSync executeData = syncList.get(0); |
| | | // 订单号 |
| | | String docNum = "PU-" + String.valueOf(snowflakeIdWorker.nextId()).substring(0, 15); |
| | | // 订单类型 34采购单 |
| | | Integer docId = 34; |
| | | List<BillDto> dtos = new ArrayList<BillDto>(); |
| | | BillDto res = new BillDto(); |
| | | res.setMatnr(executeData.getMatnr()); |
| | | res.setQty(executeData.getQty()); |
| | | dtos.add(res); |
| | | if (erpService.uploadBill(dtos, docId, docNum)) { |
| | | // 成功后删除任务 |
| | | if (!wrkLocSyncService.delete(new EntityWrapper<WrkLocSync>().eq("matnr", executeData.getMatnr()))) { |
| | | log.info("库存同步删除任务失败,任务matnr=" + executeData.getMatnr() + "时间=" + new Date()); |
| | | } |
| | | } else { |
| | | // 失败后将任务状态state更新为N |
| | | executeData.setState("X"); |
| | | 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()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |