| | |
| | | exceptionHandle("删除入库通知档[workNo={0}]失败", wrkMast.getWrkNo()); |
| | | } |
| | | } |
| | | // // 手动入库生成单据 【 上报三方平台 】 |
| | | // if (!Cools.isEmpty(wrkDetls)) { |
| | | // if (!orderService.saveHandlerOrder(Boolean.TRUE, wrkMast, wrkDetls)) { |
| | | // exceptionHandle("生成手动入库单据[workNo={0}]失败", wrkMast.getWrkNo()); |
| | | // } |
| | | // } |
| | | // 手动入库生成单据 【 上报三方平台 】 |
| | | if (!Cools.isEmpty(wrkDetls)) { |
| | | if (!orderService.saveHandlerOrder(Boolean.TRUE, wrkMast, wrkDetls)) { |
| | | exceptionHandle("生成手动入库单据[workNo={0}]失败", wrkMast.getWrkNo()); |
| | | } |
| | | } |
| | | // 拣料再入库 |
| | | } else if (wrkMast.getIoType() == 53) { |
| | | if (!Cools.isEmpty(wrkDetls)) { |
| | |
| | | import com.zy.asrs.entity.Mat; |
| | | import com.zy.asrs.entity.Order; |
| | | import com.zy.asrs.entity.OrderDetl; |
| | | import com.zy.asrs.service.DocTypeService; |
| | | import com.zy.asrs.service.MatService; |
| | | import com.zy.asrs.service.OrderDetlService; |
| | | import com.zy.asrs.service.OrderService; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.ints.entity.ErpDetTb; |
| | | import com.zy.ints.entity.ErpDetTbBak; |
| | | import com.zy.ints.erp.ErpSqlServer; |
| | |
| | | */ |
| | | @Value("${erp.enabled}") |
| | | private Boolean erpEnabled; |
| | | @Value("${erp.useName.ip}") |
| | | private String ip; |
| | | @Autowired |
| | | private ErpSqlServer erpSqlServer; |
| | | @Autowired |
| | |
| | | private SnowflakeIdWorker snowflakeIdWorker; |
| | | @Autowired |
| | | private DocTypeService docTypeService; |
| | | @Autowired |
| | | private ApiLogService apiLogService; |
| | | |
| | | /** |
| | | * 获取入出库订单信息 |
| | |
| | | Mat mat = matService.selectByMatnr(erpDetTb.getPrdNo()); |
| | | if (Cools.isEmpty(mat)) { |
| | | erpSqlServer.update(sqlUpDateErpDetTbTwo + ",temp1='品号信息在立库不存在,请先添加商品!!!'" + "where 1=1 and prd_no=" + "'" + erpDetTb.getPrdNo() + "'"); |
| | | callApiLogSave(erpDetTb, "erp_det_tb", "品号信息在立库不存在,请先添加商品!!!", false); |
| | | } else { |
| | | Order order = orderService.selectByNo(erpDetTb.getBillNo()); |
| | | if (Cools.isEmpty(order)) { |
| | |
| | | if (!Cools.isEmpty(docType)) { |
| | | order.setDocType(docType.getDocId()); |
| | | if (!orderService.insert(order)) { |
| | | throw new CoolException("添加订单主档信息失败!!!"); |
| | | callApiLogSave(erpDetTb, "erp_det_tb", "订单主档添加失败!!", false); |
| | | continue; |
| | | } else { |
| | | callApiLogSave(erpDetTb, "erp_det_tb", "订单主档添加成功!!", true); |
| | | } |
| | | } |
| | | } |
| | |
| | | orderDetl.setUpdateBy(9999L); |
| | | orderDetl.setUpdateTime(now); |
| | | orderDetl.setMemo(erpDetTb.getWh()); |
| | | if (orderDetlService.insert(orderDetl)){ |
| | | if (orderDetlService.insert(orderDetl)) { |
| | | erpSqlServer.update(sqlUpDateErpDetTbOne + "'" + erpDetTb.getPrdNo() + "'"); |
| | | }else { |
| | | callApiLogSave(erpDetTb, "erp_det_tb", "接收ERP下发订单接收成功!!", true); |
| | | } else { |
| | | erpSqlServer.update(sqlUpDateErpDetTbTwo + ",temp1='添加订单明细档失败!!!'" + "where 1=1 and prd_no=" + "'" + erpDetTb.getPrdNo() + "'"); |
| | | callApiLogSave(erpDetTb, "erp_det_tb", "接收ERP下发订单接收失败!!", false); |
| | | } |
| | | } |
| | | } |
| | |
| | | condition.put("temp3", "'" + erpDetTb.getTemp3() + "'"); |
| | | erpSqlServer.insert(ErpDetTbBak.class, condition); |
| | | |
| | | callApiLogSave(erpDetTb, "erp_det_tb_bak", "erp下发订单备份成功!!", true); |
| | | |
| | | HashMap<String, String> condition2 = new HashMap<>(); |
| | | condition2.put("bill_no", "'" + erpDetTb.getBillNo() + "'"); |
| | | condition2.put("prd_no", "'" + erpDetTb.getPrdNo() + "'"); |
| | | condition2.put("prd_mark", "'" + erpDetTb.getPrdMark() + "'"); |
| | | erpSqlServer.delete(ErpDetTb.class, condition2); |
| | | } else if (status == 2) { |
| | | |
| | | callApiLogSave(erpDetTb, "erp_det_tb", "erp下发订单备份后删除成功!!", true); |
| | | |
| | | } else { |
| | | |
| | | callApiLogSave(erpDetTb, "erp_det_tb", "接收ERP下发订单失败!!!状态异常!!!", false); |
| | | } |
| | | } |
| | | } |
| | |
| | | log.error(date + ": 表名:erp_det_tb :" + e); |
| | | } |
| | | } |
| | | |
| | | public void callApiLogSave(ErpDetTb erpDetTb, String tableName, String response, Boolean bool) { |
| | | apiLogService.save("ERP下发订单信息", "中间表:" + tableName, "null", ip, |
| | | "订单号:" + erpDetTb.getBillNo() + "品号:" + erpDetTb.getPrdNo() + "货品特征:" + erpDetTb.getPrdMark() + "状态:" + erpDetTb.getStatus(), |
| | | response, bool); |
| | | } |
| | | } |
| | |
| | | * ERP与lk库存数据比对 |
| | | */ |
| | | @Scheduled(cron = "${erp.refreshtime}") |
| | | public void InOrOutOrder() { |
| | | public void proofread() { |
| | | if (!erpEnabled) return; |
| | | String sqlSelectErpLk = "select prd_no as prdNo,prd_mark as prdMark,qty,wh,status,temp1,temp2,temp3 from bas_erp_lk where 1=1"; |
| | | String sqlUpDateErpLkOne = "update bas_erp_lk set status=1 where prd_no="; |
| | |
| | | import com.core.common.Cools; |
| | | import com.zy.asrs.entity.Mat; |
| | | import com.zy.asrs.entity.Tag; |
| | | import com.zy.asrs.service.ApiLogService; |
| | | import com.zy.asrs.service.MatService; |
| | | import com.zy.asrs.service.TagService; |
| | | import com.zy.ints.entity.ErpDetTb; |
| | | import com.zy.ints.entity.Prdt; |
| | | import com.zy.ints.entity.PrdtBak; |
| | | import com.zy.ints.erp.ErpSqlServer; |
| | |
| | | */ |
| | | @Value("${erp.enabled}") |
| | | private Boolean erpEnabled; |
| | | @Value("${erp.useName.ip}") |
| | | private String ip; |
| | | @Autowired |
| | | private ApiLogService apiLogService; |
| | | @Autowired |
| | | private TagService tagService; |
| | | @Autowired |
| | |
| | | matNew.setUpdateTime(date); |
| | | if (matService.insert(matNew)) { |
| | | erpSqlServer.update(sqlUpDatePrdtOne + "'" + prdt.getPrdNo() + "'"); |
| | | callApiLogSave(prdt, "erp_prdt", "接收ERP下发商品信息成功!添加商品信息成功!", true); |
| | | } else { |
| | | erpSqlServer.update(sqlUpDatePrdtTwo + "'" + prdt.getPrdNo() + "'"); |
| | | callApiLogSave(prdt, "erp_prdt", "接收ERP下发商品信息失败!!!添加商品信息失败!!!", false); |
| | | } |
| | | } |
| | | } else if (type == 2) { |
| | |
| | | mat.setSpecs(prdt.getSpc()); |
| | | if (matService.updateById(mat)) { |
| | | erpSqlServer.update(sqlUpDatePrdtOne + "'" + prdt.getPrdNo() + "'"); |
| | | callApiLogSave(prdt, "erp_prdt", "接收ERP下发商品信息成功!修改商品信息成功!", true); |
| | | } else { |
| | | erpSqlServer.update(sqlUpDatePrdtTwo + "'" + prdt.getPrdNo() + "'"); |
| | | callApiLogSave(prdt, "erp_prdt", "接收ERP下发商品信息失败!!!修改商品信息失败!!!", false); |
| | | } |
| | | } |
| | | } else if (type == 3) { |
| | |
| | | if (!Cools.isEmpty(mat)) { |
| | | if (matService.deleteById(mat.getId())) { |
| | | erpSqlServer.update(sqlUpDatePrdtOne + "'" + prdt.getPrdNo() + "'"); |
| | | callApiLogSave(prdt, "erp_prdt", "接收ERP下发商品信息成功!删除商品信息成功!", true); |
| | | } else { |
| | | erpSqlServer.update(sqlUpDatePrdtTwo + "'" + prdt.getPrdNo() + "'"); |
| | | callApiLogSave(prdt, "erp_prdt", "接收ERP下发商品信息成功!删除商品信息失败!", false); |
| | | } |
| | | } |
| | | } else { |
| | | |
| | | callApiLogSave(prdt, "erp_prdt", "商品信息出现异常资料!", false); |
| | | } |
| | | } else if (prdt.getStatus() == 1) { |
| | | HashMap<String, Object> condition = new HashMap<>(); |
| | |
| | | condition.put("type", "'" + prdt.getType() + "'"); |
| | | condition.put("status", "'" + prdt.getStatus() + "'"); |
| | | erpSqlServer.insert(PrdtBak.class, condition); |
| | | callApiLogSave(prdt, "erp_prdt_bak", "ERP下发商品信息备份成功!", true); |
| | | |
| | | HashMap<String, String> condition2 = new HashMap<>(); |
| | | condition2.put("prd_no", "'" + prdt.getPrdNo() + "'"); |
| | | erpSqlServer.delete(Prdt.class, condition2); |
| | | } else if (prdt.getStatus() == 2) { |
| | | |
| | | } else { |
| | | |
| | | callApiLogSave(prdt, "erp_prdt_bak", "ERP下发商品信息备份后删除成功!", true); |
| | | } else{ |
| | | callApiLogSave(prdt, "erp_prdt", "商品信息出现异常资料!", false); |
| | | } |
| | | |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | |
| | | Date date = new Date(); |
| | | log.error(date + ": 表名:erp_prdt :" + e); |
| | | } |
| | | } |
| | | |
| | | public void callApiLogSave(Prdt prdt, String tableName, String response, Boolean bool) { |
| | | apiLogService.save("ERP下发商品信息", "中间表:" + tableName, "null", ip, |
| | | "品号:" + prdt.getPrdNo() + "品名:" + prdt.getName() + "类型:" + prdt.getType() + "状态:" + prdt.getStatus(), |
| | | response, bool); |
| | | } |
| | | } |
| | |
| | | import com.zy.asrs.entity.DocType; |
| | | import com.zy.asrs.entity.Order; |
| | | import com.zy.asrs.entity.OrderDetl; |
| | | import com.zy.asrs.service.ApiLogService; |
| | | import com.zy.asrs.service.DocTypeService; |
| | | import com.zy.asrs.service.OrderDetlService; |
| | | import com.zy.asrs.service.OrderService; |
| | | import com.zy.ints.entity.ErpDetTb; |
| | | import com.zy.ints.entity.ErpDetTbBak; |
| | | import com.zy.ints.entity.LkDetTb; |
| | | import com.zy.ints.entity.LkDetTbBak; |
| | |
| | | */ |
| | | @Value("${erp.enabled}") |
| | | private Boolean erpEnabled; |
| | | @Value("${erp.useName.ip}") |
| | | private String ip; |
| | | @Autowired |
| | | private ApiLogService apiLogService; |
| | | @Autowired |
| | | private ErpSqlServer erpSqlServer; |
| | | @Autowired |
| | |
| | | private OrderDetlService orderDetlService; |
| | | @Autowired |
| | | private DocTypeService docTypeService; |
| | | |
| | | /** |
| | | * 上报入出库完结订单信息 |
| | | */ |
| | | @Scheduled(cron = "${erp.refreshtime}") |
| | | public void InOrOutOrder() { |
| | | public void reportOrder() { |
| | | if (!erpEnabled) return; |
| | | String sqlSelectLkDetTb = "select bill_no as billNo,prd_no as prdNo,iokindid,add_id as addId,qty,prd_mark as prdMark,wh,billdate,status,temp1,temp2,temp3 from lk_det_tb where 1=1"; |
| | | String sqlSelectLkDetTbBak = "select bill_no as billNo,prd_no as prdNo,iokindid,add_id as addId,qty,prd_mark as prdMark,wh,billdate,status,temp1,temp2,temp3 from lk_det_tb_bak where 1=1"; |
| | | |
| | | try { |
| | | List<Order> orders = orderService.selectList(new EntityWrapper<Order>().eq("settle", 4L)); |
| | | if (orders.size()>0){ |
| | | for (Order order:orders){ |
| | | if (orders.size() > 0) { |
| | | for (Order order : orders) { |
| | | List<OrderDetl> orderDetls = orderDetlService.selectByOrderId(order.getId()); |
| | | if (!Cools.isEmpty(orderDetls)){ |
| | | for (OrderDetl orderDetl:orderDetls){ |
| | | if (!Cools.isEmpty(orderDetls)) { |
| | | for (OrderDetl orderDetl : orderDetls) { |
| | | Date now = new Date(); |
| | | List<LkDetTb> lkDetTbs = erpSqlServer.select(sqlSelectLkDetTb+ |
| | | " and bill_no='"+orderDetl.getOrderNo()+"'" + |
| | | " and prd_no='"+orderDetl.getMatnr()+"'" + |
| | | " and prd_mark='"+orderDetl.getBatch()+"'" |
| | | List<LkDetTb> lkDetTbs = erpSqlServer.select(sqlSelectLkDetTb + |
| | | " and bill_no='" + orderDetl.getOrderNo() + "'" + |
| | | " and prd_no='" + orderDetl.getMatnr() + "'" + |
| | | " and prd_mark='" + orderDetl.getBatch() + "'" |
| | | , LkDetTb.class); |
| | | List<LkDetTbBak> lkDetTbBaks = erpSqlServer.select(sqlSelectLkDetTbBak+ |
| | | " and bill_no='"+orderDetl.getOrderNo()+"'" + |
| | | " and prd_no='"+orderDetl.getMatnr()+"'" + |
| | | " and prd_mark='"+orderDetl.getBatch()+"'" |
| | | List<LkDetTbBak> lkDetTbBaks = erpSqlServer.select(sqlSelectLkDetTbBak + |
| | | " and bill_no='" + orderDetl.getOrderNo() + "'" + |
| | | " and prd_no='" + orderDetl.getMatnr() + "'" + |
| | | " and prd_mark='" + orderDetl.getBatch() + "'" |
| | | , LkDetTbBak.class); |
| | | if (lkDetTbs.size() == 1 || lkDetTbBaks.size()==1){ |
| | | log.error("订单号:"+orderDetl.getOrderNo()+"、商品编号:"+orderDetl.getMatnr()+"、货品特征:"+orderDetl.getBatch()+" " + |
| | | "已经上报但是明细依旧存在,请联系开发人员!!!"); |
| | | if (lkDetTbs.size() == 1) { |
| | | callApiLogSaveLkDetTb(lkDetTbs.get(0), "erp_det_tb", "已经上报但是明细依旧存在,请联系开发人员!!!", false); |
| | | continue; |
| | | }else if (lkDetTbs.size()>1 || lkDetTbBaks.size()>1){ |
| | | log.error("相同 订单号:"+orderDetl.getOrderNo()+"、商品编号:"+orderDetl.getMatnr()+"、货品特征:"+orderDetl.getBatch()+" " + |
| | | "存在重复资料,联系开发人员!!!"); |
| | | } else if (lkDetTbBaks.size() == 1) { |
| | | callApiLogSaveLkDetTbBak(lkDetTbBaks.get(0), "erp_det_tb_bak", "已经上报但是明细依旧存在,请联系开发人员!!!", false); |
| | | continue; |
| | | // throw new CoolException("相同 订单号:"+orderDetl.getOrderNo()+"、商品编号:"+orderDetl.getMatnr()+"、货品特征:"+orderDetl.getBatch()+" " + |
| | | // "存在重复资料,联系开发人员!!!"); |
| | | }else { |
| | | } else if (lkDetTbs.size() > 1) { |
| | | callApiLogSaveLkDetTb(lkDetTbs.get(0), "erp_det_tb", "存在重复资料,联系开发人员!!!", false); |
| | | continue; |
| | | } else if (lkDetTbBaks.size() > 1) { |
| | | callApiLogSaveLkDetTbBak(lkDetTbBaks.get(0), "erp_det_tb_bak", "存在重复资料,联系开发人员!!!", false); |
| | | continue; |
| | | } else { |
| | | String format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(now); |
| | | HashMap<String, Object> condition = new HashMap<>(); |
| | | condition.put("bill_no", "'" + orderDetl.getOrderNo() + "'"); |
| | | condition.put("prd_no", "'" + orderDetl.getMatnr() + "'"); |
| | | |
| | | DocType docType = docTypeService.selectById(order.getDocType()); |
| | | if (!Cools.isEmpty(docType)){ |
| | | if (!Cools.isEmpty(docType)) { |
| | | int addid = docType.getPakin() == 1 ? 1 : 2; |
| | | condition.put("iokindid", "'" + docType.getDocName$() + "'"); |
| | | condition.put("add_id", "'" + addid + "'"); |
| | |
| | | condition.put("billdate", "'" + format + "'"); |
| | | condition.put("status", "'" + 0 + "'"); |
| | | erpSqlServer.insert(LkDetTb.class, condition); |
| | | callApiLogSaveOrderDetl(orderDetl, "完结订单明细上报完成", true); |
| | | } |
| | | //保存订单明细历史档 |
| | | if (orderDetlService.addToLogTable(orderDetl)){ |
| | | if (orderDetlService.addToLogTable(orderDetl)) { |
| | | callApiLogSaveOrderDetl(orderDetl, "保存订单明细历史档成功!", true); |
| | | //删除订单明细 |
| | | orderDetlService.deleteById(orderDetl.getId()); |
| | | callApiLogSaveOrderDetl(orderDetl, "订单明细档保存后删除成功!", true); |
| | | } |
| | | } |
| | | //保存订单历史档 |
| | | if (orderService.addToLogTable(order)){ |
| | | if (orderService.addToLogTable(order)) { |
| | | callApiLogSaveOrder(order, "完结订单上报完成,并保存订单历史档成功!!!", true); |
| | | //删除完结订单 |
| | | orderService.deleteById(order.getId()); |
| | | callApiLogSaveOrder(order, "完结订单上报完成,并保存订单历史档后删除完结订单成功!!!", true); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | }catch (Exception e){ |
| | | |
| | | } catch (Exception e) { |
| | | Date date = new Date(); |
| | | log.error(date + ": 表名:lk_det_tb :" + e); |
| | | } |
| | | } |
| | | |
| | | public void callApiLogSaveLkDetTb(LkDetTb lkDetTb, String tableName, String response, Boolean bool) { |
| | | apiLogService.save("ERP下发订单信息", "中间表:" + tableName, "null", ip, |
| | | "订单号:" + lkDetTb.getBillNo() + "品号:" + lkDetTb.getPrdNo() + "货品特征:" + lkDetTb.getPrdMark() + "状态:" + lkDetTb.getStatus(), |
| | | response, bool); |
| | | } |
| | | |
| | | public void callApiLogSaveLkDetTbBak(LkDetTbBak lkDetTbBak, String tableName, String response, Boolean bool) { |
| | | apiLogService.save("ERP下发订单信息", "中间表:" + tableName, "null", ip, |
| | | "订单号:" + lkDetTbBak.getBillNo() + "品号:" + lkDetTbBak.getPrdNo() + "货品特征:" + lkDetTbBak.getPrdMark() + "状态:" + lkDetTbBak.getStatus(), |
| | | response, bool); |
| | | } |
| | | |
| | | public void callApiLogSaveOrderDetl(OrderDetl orderDetl, String response, Boolean bool) { |
| | | apiLogService.save("上报完结订单明细信息", "中间表:lk_det_tb", "null", ip, |
| | | "订单号:" + orderDetl.getOrderNo() + "品号:" + orderDetl.getMatnr() + "货品特征:" + orderDetl.getBatch(), |
| | | response, bool); |
| | | } |
| | | |
| | | public void callApiLogSaveOrder(Order order, String response, Boolean bool) { |
| | | apiLogService.save("完结订单信息上报完成", "中间表:lk_det_tb", "null", ip, |
| | | "订单号:" + order.getOrderNo(), response, bool); |
| | | } |
| | | } |
| | |
| | | url: jdbc:sqlserver://127.0.0.1:1433;databasename=lfdasrs |
| | | username: sa |
| | | password: sa@123 |
| | | useName: |
| | | ip: 127.0.0.1 |
| | | |
| | | |
| | | comb: |