package com.zy.asrs.service.impl; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.core.common.Cools; import com.core.exception.CoolException; import com.zy.asrs.entity.*; import com.zy.asrs.service.*; import com.zy.asrs.utils.MatUtils; import com.zy.nc.SendUtil; import com.zy.nc.entity.*; import com.zy.nc.service.NccSaleDbddWmsService; import com.zy.nc.service.NccSaleXsfhmxWmsService; import com.zy.nc.service.NccScPcdaWmsService; import com.zy.nc.util.NcResultMessage; import com.zy.nc.vo.*; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import java.math.BigDecimal; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @Service @Slf4j public class ReportToThirdServiceImpl implements ReportToThirdService { @Autowired private ApiLogService apiLogService; @Autowired private OrderService orderService; @Autowired private WrkDetlService wrkDetlService; @Autowired private InventoryCheckOrderService inventoryCheckOrderService; @Autowired private InventoryCheckOrderDetlService inventoryCheckOrderDetlService; @Autowired private StoreTypeService storeTypeService; @Autowired private NccScPcdaWmsService nccScPcdaWmsService; @Autowired private NccSaleXsfhmxWmsService nccSaleXsfhmxWmsService; @Autowired private NccSaleDbddWmsService nccSaleDbddWmsService; @Value("${NYNC.ip}") private String nyncIp; @Value("${NYNC.port}") private String port; @Value("${NYNC.saveRefDelivery}") private String saveRefDelivery; @Value("${NYNC.saveRefWhsTrans}") private String saveRefWhsTrans; @Value("${NYNC.invcountAdd}") private String invcountAdd; @Value("${NYNC.purchasein}") private String purchasein; @Value("${NYNC.whstrans}") private String whstrans; @Value("${NYNC.generalout}") private String generalout; @Value("${NYNC.dbdd}") private String dbdd; @Override public void report(Order order, List orderDetls, DocType docType) { int step = (Cools.isEmpty(order.getStep()) || order.getStep() == 0) ? 0 : order.getStep(); NcResultMessage response = null; Object process1 = null; Object process2 = null; String memo = order.getMemo(); String remark = ""; boolean success = false; log.info("订单开始上报:{}", JSON.toJSONString(order)); try { switch (order.getDocType$().toString()) { case "销售退货": process1 = processXSFH(orderDetls, true); //发送请求 response = SendUtil.sendDataToNc(SendUtil.token, nyncIp + ":" + port, saveRefDelivery, JSONObject.toJSONString(process1)); if (!Cools.isEmpty(response) && response.isSuccess()) { log.info("销售发货response:{}", response); step = 10; success = true; } else { remark = response.getMessage() + "--" + response.getErrorStack().substring(0, 100); } break; case "销售发货": process1 = processXSFH(orderDetls, false); //发送请求 response = SendUtil.sendDataToNc(SendUtil.token, nyncIp + ":" + port, saveRefDelivery, JSONObject.toJSONString(process1)); if (!Cools.isEmpty(response) && response.isSuccess()) { log.info("销售发货response:{}", response); step = 10; success = true; } else { remark = response.getMessage() + "--" + response.getErrorStack().substring(0, 100); } break; case "转库-入库": process1 = processZKRK(orderDetls); //发送请求 response = SendUtil.sendDataToNc(SendUtil.token, nyncIp + ":" + port, saveRefWhsTrans, JSONObject.toJSONString(process1)); if (!Cools.isEmpty(response) && response.isSuccess()) { log.info("转库-入库response:{}", response); step = 10; success = true; } else { remark = response.getMessage() + "--" + response.getErrorStack().substring(0, 100); } break; case "采购到货": //不需要上报了 step = 10; // process1 = processCGDH(orderDetls); // List cg = new ArrayList<>(); // cg.add(process1); // //发送请求 // response = SendUtil.sendDataToNc(SendUtil.token, nyncIp + ":" + port, purchasein, JSONObject.toJSONString(cg)); // if (!Cools.isEmpty(response) && response.isSuccess()) { // log.info("采购到货response:{}", response); // step = 10; // } else { // remark = response.getMessage() + "--" + response.getErrorStack().substring(0, 100); // } break; case "转库-出库": if (step == 1) { process2 = processGENERALOUT2(orderDetls, order.getOperMemb(), order.getItemId(), memo); List zkck2 = new ArrayList<>(); zkck2.add(process2); //发送请求 response = SendUtil.sendDataToNc(SendUtil.token, nyncIp + ":" + port, generalout, JSONObject.toJSONString(zkck2)); if (!Cools.isEmpty(response) && response.isSuccess()) { log.info("转库-出库2response:{}", response); step = 10; success = true; } else { remark = response.getMessage() + "--" + response.getErrorStack().substring(0, 100); } } else { process1 = processZKCK(order, orderDetls); List zkck1 = new ArrayList<>(); zkck1.add(process1); //发送请求 response = SendUtil.sendDataToNc(SendUtil.token, nyncIp + ":" + port, whstrans, JSONObject.toJSONString(zkck1)); if (!Cools.isEmpty(response) && response.isSuccess()) { step = 1; log.info("转库-出库1response:{}", response); memo = response.getData().toString(); process2 = processGENERALOUT2(orderDetls, order.getOperMemb(), order.getItemId(), memo); List zkck2 = new ArrayList<>(); zkck2.add(process2); //发送请求 response = SendUtil.sendDataToNc(SendUtil.token, nyncIp + ":" + port, generalout, JSONObject.toJSONString(zkck2)); if (!Cools.isEmpty(response) && response.isSuccess()) { log.info("转库-出库2response:{}", response); step = 10; success = true; } else { remark = response.getMessage() + "--" + response.getErrorStack().substring(0, 100); } } } break; case "集团内部调拨": process1 = processDBDD(orderDetls); //发送请求 response = SendUtil.sendDataToNc(SendUtil.token, nyncIp + ":" + port, dbdd, JSONObject.toJSONString(process1)); if (!Cools.isEmpty(response) && response.isSuccess()) { log.info("集团内部调拨response:{}", response); step = 10; success = true; } else { remark = response.getMessage() + "--" + response.getErrorStack().substring(0, 100); } break; default: throw new CoolException("不能识别的单据类型"); } if (step == 10) { // 修改订单状态 4.完成 ===>> 6.已上报 if (!orderService.updateSettle(order.getId(), 6L, null)) { throw new CoolException("服务器内部错误,请联系管理员"); } } else if (step != 0) { // 修改订单状态 做标记 if (!orderService.updateSettleStep(order.getId(), 4L, null, step, memo, remark)) { throw new CoolException("服务器内部错误,请联系管理员"); } } } catch (Exception e) { e.printStackTrace(); throw new CoolException("调用接口报错,请联系管理员"); } finally { reportApiLog(order, process1, process2, response, order.getDocType$(), nyncIp, saveRefDelivery, success); } } @Override public boolean reportTkrk(WaitPakin waitPakin) { String matnr = waitPakin.getMatnr(); String batch = waitPakin.getBatch(); String orderNo = waitPakin.getOrderNo(); Double anfme = waitPakin.getAnfme(); Object process1 = null; NcResultMessage response1 = null; boolean success1 = false; try { process1 = processTKRK(matnr, batch, orderNo, anfme, waitPakin.getCstateid()); //发送请求 response1 = SendUtil.sendDataToNc(SendUtil.token, nyncIp + ":" + port, saveRefDelivery, JSONObject.toJSONString(process1)); log.info("退库入库response:{}", response1); if (!Cools.isEmpty(response1) && response1.isSuccess()) { log.info("退库入库response:{}", response1); success1 = true; return true; } } catch (Exception e) { e.printStackTrace(); process1 = e.getMessage(); } finally { reportApiLog(null, process1, process1, response1, "TKRK", nyncIp, saveRefDelivery, success1); } Object process2 = null; NcResultMessage response2 = null; boolean success2 = false; try { process2 = processDBTK(matnr, batch, orderNo, anfme, waitPakin.getCstateidVcode()); //发送请求 response2 = SendUtil.sendDataToNc(SendUtil.token, nyncIp + ":" + port, dbdd, JSONObject.toJSONString(process2)); log.info("退库入库response:{}", response2); if (!Cools.isEmpty(response2) && response2.isSuccess()) { log.info("退库入库response:{}", response2); success2 = true; return true; } } catch (Exception e) { e.printStackTrace(); process2 = e.getMessage(); } finally { reportApiLog(null, process2, process2, response2, "DBRK", nyncIp, dbdd, success2); } return false; } @Override public boolean reportCheckOrder(List checkOrderDetls) { ArrayList orderNoList = new ArrayList<>(); HashMap> map = new HashMap<>(); for (InventoryCheckOrderDetl checkOrderDetl : checkOrderDetls) { if (map.containsKey(checkOrderDetl.getCwarehouseid())) { List list = map.get(checkOrderDetl.getCwarehouseid()); list.add(checkOrderDetl); map.put(checkOrderDetl.getCwarehouseid(), list); }else { List list = new ArrayList<>(); list.add(checkOrderDetl); map.put(checkOrderDetl.getCwarehouseid(), list); } if (!orderNoList.contains(checkOrderDetl.getOrderNo())) { orderNoList.add(checkOrderDetl.getOrderNo()); } } boolean result = true; for (Map.Entry> entry : map.entrySet()) { String cwarehouseid = entry.getKey(); List list = entry.getValue(); Object process1 = processInvcount(list, cwarehouseid); NcResultMessage response = null; boolean success = false; try { //发送请求 response = SendUtil.sendDataToNc(SendUtil.token, nyncIp + ":" + port, invcountAdd, JSONObject.toJSONString(process1)); log.info("盘点单response:{}", response); if (!Cools.isEmpty(response) && response.isSuccess()) { log.info("盘点单response:{}", response); success = true; } else { result = false; } } catch (Exception e) { e.printStackTrace(); } finally { reportApiLog(null, process1, null, response, "盘点上报", nyncIp, invcountAdd, success); } } if (result) { List inventoryCheckOrders = inventoryCheckOrderService.selectList(new EntityWrapper() .in("order_no", orderNoList) .eq("status", 1) ); for (InventoryCheckOrder inventoryCheckOrder : inventoryCheckOrders) { inventoryCheckOrder.setStatus("2"); inventoryCheckOrderService.updateById(inventoryCheckOrder); } } return result; } private Object processXSFH(List orderDetls, Boolean flag) { //组装对象数据 Map data = new HashMap(); SaleOutHeadVO saleOutHeadVO = new SaleOutHeadVO(); saleOutHeadVO.setPk_org("FYT"); SaleOutBodyVO saleOutBodyVO = null; List saleOutBodyVOList = new ArrayList<>(); for (OrderDetl orderDetl : orderDetls) { if (orderDetl.getQty() <= 0) { continue; } saleOutBodyVO = new SaleOutBodyVO(); String remark = orderDetl.getRemark(); if (!Cools.isEmpty(remark)) { NccSaleXsfhmxWms nccSaleXsfhmxWms = JSONObject.parseObject(remark, NccSaleXsfhmxWms.class); saleOutBodyVO.setCsourcetype("4331"); //saleOutBodyVO.setClocationid("610101"); saleOutBodyVO.setCsourcebillbid(nccSaleXsfhmxWms.getCdeliverybid()); saleOutBodyVO.setCsourcebillhid(nccSaleXsfhmxWms.getCdeliveryid()); saleOutHeadVO.setVdef2(nccSaleXsfhmxWms.getVdef2()); saleOutHeadVO.setVdef3(nccSaleXsfhmxWms.getVdef3()); saleOutHeadVO.setVdef4(nccSaleXsfhmxWms.getVdef4()); saleOutHeadVO.setVdef7(nccSaleXsfhmxWms.getVdef7()); saleOutHeadVO.setVdef8(nccSaleXsfhmxWms.getVdef8()); saleOutHeadVO.setVdef13(nccSaleXsfhmxWms.getVdef13()); saleOutHeadVO.setVdef14(nccSaleXsfhmxWms.getVdef14()); } saleOutHeadVO.setCwarehouseid(orderDetl.getStandby1()); saleOutBodyVO.setVbatchcode(orderDetl.getBatch()); saleOutBodyVO.setNshouldnum(flag ? -orderDetl.getQty() : orderDetl.getQty()); saleOutBodyVO.setNnum(flag ? -orderDetl.getQty() : orderDetl.getQty()); saleOutBodyVO.setCstateid(orderDetl.getCstateid()); saleOutBodyVOList.add(saleOutBodyVO); } data.put("SaleOutHeadVO", saleOutHeadVO); data.put("SaleOutBodyVO", saleOutBodyVOList); return data; } private Object processTKRK(String matnr, String batch, String orderNo, Double anfme, String cstateid) { // EntityWrapper wrapper = new EntityWrapper<>(); // wrapper.eq("VBATCHCODE", batch).eq("VSOURCEBILLCODE", orderNo); // NccXsckmxTkWms nccXsckmxTkWms = nccXsckmxTkWmsService.selectOne(wrapper); // if (null == nccXsckmxTkWms) { // throw new CoolException("未找到此条码"); // } NccSaleXsfhmxWms nccSaleXsfhmxWms = nccSaleXsfhmxWmsService.selectOne(new EntityWrapper() .eq("VBILLCODE", orderNo) .eq("WLBM", matnr) ); if (null == nccSaleXsfhmxWms) { throw new CoolException("未找到销售单据"); } //组装对象数据 Map data = new HashMap(); SaleOutHeadVO saleOutHeadVO = new SaleOutHeadVO(); saleOutHeadVO.setPk_org("FYT"); SaleOutBodyVO saleOutBodyVO = null; List saleOutBodyVOList = new ArrayList<>(); saleOutBodyVO = new SaleOutBodyVO(); saleOutBodyVO.setCsourcetype("4331"); saleOutBodyVO.setCsourcebillbid(nccSaleXsfhmxWms.getCdeliverybid()); saleOutBodyVO.setCsourcebillhid(nccSaleXsfhmxWms.getCdeliveryid()); saleOutHeadVO.setCwarehouseid(nccSaleXsfhmxWms.getFhckbm()); saleOutBodyVO.setVbatchcode(batch); saleOutBodyVO.setNnum(anfme * -1); saleOutBodyVO.setCstateid(cstateid); saleOutBodyVOList.add(saleOutBodyVO); data.put("SaleOutHeadVO", saleOutHeadVO); data.put("SaleOutBodyVO", saleOutBodyVOList); return data; } private Object processDBTK(String matnr, String batch, String orderNo, Double anfme, String cstateid) { List nccSaleDbddWmsList = nccSaleDbddWmsService.selectList(new EntityWrapper() .eq("wlbm", matnr) .eq("vbillcode", orderNo) ); if (nccSaleDbddWmsList.isEmpty()) { throw new CoolException("调拨订单ERP数据为空"); } NccSaleDbddWms nccSaleDbddWms = nccSaleDbddWmsList.get(0); //组装对象数据 Map data = new HashMap(); List bids = new ArrayList<>(); IaIjBillB iaIjBillB = new IaIjBillB(); // NccScPcdaWms nccScPcdaWms = nccScPcdaWmsService.selectOne(new EntityWrapper().eq("vbatchcode", batch).eq("wlbm", matnr)); // if (nccScPcdaWms == null) { // throw new CoolException("批次[{}]物料[{}]未找到" + batch + "-" + matnr); // } Double weight = MatUtils.calcWeight(matnr, anfme); iaIjBillB.setBid(nccSaleDbddWms.getCbill_bid()); iaIjBillB.setNassistnum(weight * -1); iaIjBillB.setNnum(anfme * -1); iaIjBillB.setVbatchcode(batch); iaIjBillB.setClocationid(""); iaIjBillB.setCstateid(cstateid); bids.add(iaIjBillB); data.put("hid", nccSaleDbddWms.getCbillid()); data.put("bids", bids); return data; } private Object processInvcount(List inventoryCheckOrderDetls, String cwarehouseid) { if (inventoryCheckOrderDetls.isEmpty()) { throw new CoolException("盘点明细不存在"); } HashMap map = new HashMap<>(); for (InventoryCheckOrderDetl checkOrderDetl : inventoryCheckOrderDetls) { String key = checkOrderDetl.getMatnr() + "_" + checkOrderDetl.getBatch() + "_" + checkOrderDetl.getCstateid(); if (map.containsKey(key)) { InventoryCheckOrderDetl orderDetl = map.get(key); BigDecimal checkAnfmeDecimal = BigDecimal.valueOf(orderDetl.getCheckAnfme()); checkAnfmeDecimal = checkAnfmeDecimal.add(BigDecimal.valueOf(checkOrderDetl.getCheckAnfme())); //计算辅数量 Double weight = MatUtils.calcWeight(orderDetl.getMatnr(), checkAnfmeDecimal.doubleValue()); orderDetl.setCheckAnfme(checkAnfmeDecimal.doubleValue()); orderDetl.setWeight(weight); map.put(key, orderDetl); } else { //计算辅数量 Double weight = MatUtils.calcWeight(checkOrderDetl.getMatnr(), checkOrderDetl.getCheckAnfme()); checkOrderDetl.setWeight(weight); map.put(key, checkOrderDetl); } } //组装对象数据 Map data = new HashMap(); List invCountBodyVOList = new ArrayList<>(); for (Map.Entry entry : map.entrySet()) { InventoryCheckOrderDetl checkOrderDetl = entry.getValue(); String matnr = checkOrderDetl.getMatnr(); String batch = checkOrderDetl.getBatch(); NccScPcdaWms nccScPcdaWms = nccScPcdaWmsService.selectOne(new EntityWrapper() .eq("WLBM", matnr) .eq("VBATCHCODE", batch) ); if (null == nccScPcdaWms) { throw new CoolException("ERP数据库无法查询到盘点上报数据"); } InvCountBodyVO invCountBodyVO = new InvCountBodyVO(); invCountBodyVO.setCmaterialoid(matnr); invCountBodyVO.setVbatchcode(batch); invCountBodyVO.setNcountnum(checkOrderDetl.getCheckAnfme()); invCountBodyVO.setNcountastnum(checkOrderDetl.getWeight()); invCountBodyVO.setCstateid(checkOrderDetl.getCstateid()); invCountBodyVO.setPk_batchcode(nccScPcdaWms.getPkBatchcode()); invCountBodyVOList.add(invCountBodyVO); } InvCountHeaderVO invCountHeaderVO = new InvCountHeaderVO(); invCountHeaderVO.setPk_org("FYT"); invCountHeaderVO.setCtrantypeid("4R-01"); invCountHeaderVO.setCwarehouseid(cwarehouseid); data.put("InvCountHeaderVO", invCountHeaderVO); data.put("InvCountBodyVO", invCountBodyVOList); data.put("paper", "1"); data.put("splr", "0"); ArrayList> list = new ArrayList<>(); list.add(data); return list; } private Object processZKRK(List orderDetls) { //组装对象数据 Map data = new HashMap(); GeneralInHeadVO generalInHeadVO = new GeneralInHeadVO(); generalInHeadVO.setPk_org("FYT"); GeneralInBodyVO generalInBodyVO = null; List generalInBodyVOS = new ArrayList<>(); for (OrderDetl orderDetl : orderDetls) { generalInBodyVO = new GeneralInBodyVO(); String remark = orderDetl.getRemark(); if (!Cools.isEmpty(remark)) { NccScZkmxbWms nccScZkmxbWms = JSONObject.parseObject(remark, NccScZkmxbWms.class); generalInBodyVO.setCsourcebillbid(nccScZkmxbWms.getCspecialbid()); generalInBodyVO.setCsourcebillhid(nccScZkmxbWms.getCspecialhid()); generalInBodyVO.setNnum(orderDetl.getQty()); generalInBodyVO.setNshouldnum(orderDetl.getAnfme()); generalInBodyVO.setCsourcetype(nccScZkmxbWms.getZklxbm()); } generalInHeadVO.setCwarehouseid(orderDetl.getStandby1()); generalInBodyVOS.add(generalInBodyVO); } data.put("GeneralInHeadVO", generalInHeadVO); data.put("GeneralInBodyVO", generalInBodyVOS); return data; } private Object processDBDD(List orderDetls) { //组装对象数据 Map data = new HashMap(); String hid = ""; List bids = new ArrayList<>(); for (OrderDetl orderDetl : orderDetls) { if (orderDetl.getQty() <= 0) { continue; } IaIjBillB iaIjBillB = new IaIjBillB(); String remark = orderDetl.getRemark(); if (!Cools.isEmpty(remark)) { Double weight = MatUtils.calcWeight(orderDetl.getMatnr(), orderDetl.getQty()); NccSaleDbddWms nccSaleDbddWms = JSONObject.parseObject(remark, NccSaleDbddWms.class); iaIjBillB.setBid(nccSaleDbddWms.getCbill_bid()); iaIjBillB.setNassistnum(weight); iaIjBillB.setNnum(orderDetl.getQty()); iaIjBillB.setVbatchcode(orderDetl.getBatch()); iaIjBillB.setClocationid(""); iaIjBillB.setCstateid(orderDetl.getCstateidVcode()); hid = nccSaleDbddWms.getCbillid(); bids.add(iaIjBillB); } } data.put("hid", hid); data.put("bids", bids); return data; } private Object processCGDH(List orderDetls) { //组装对象数据 Map data = new HashMap(); ic_purchasein_h ic_purchasein_h = new ic_purchasein_h(); ic_purchasein_h.setPk_org("FYT"); //ic_purchasein_h.setCwarehouseid("6301"); ic_purchasein_h.setCfanaceorgoid("FYT"); ic_purchasein_b ic_purchasein_b = null; List ic_purchasein_bs = new ArrayList<>(); for (OrderDetl orderDetl : orderDetls) { ic_purchasein_b = new ic_purchasein_b(); String remark = orderDetl.getRemark(); if (!Cools.isEmpty(remark)) { NccCgCgdhdWms nccCgCgdhdWms = JSONObject.parseObject(remark, NccCgCgdhdWms.class); ic_purchasein_h.setCvendorid(nccCgCgdhdWms.getGysbm()); ic_purchasein_h.setCtrantypeid(nccCgCgdhdWms.getDhlxbm()); ic_purchasein_b.setCsourcebillbid(nccCgCgdhdWms.getPkArriveorderB()); ic_purchasein_b.setCsourcebillhid(nccCgCgdhdWms.getPkArriveorder()); ic_purchasein_b.setCmaterialvid(orderDetl.getMatnr()); ic_purchasein_b.setNnum(orderDetl.getQty()); ic_purchasein_b.setCsourcetype(nccCgCgdhdWms.getDhlxbm()); ic_purchasein_b.setVbatchcode(orderDetl.getBatch()); } ic_purchasein_h.setCwarehouseid(orderDetl.getStandby1()); ic_purchasein_bs.add(ic_purchasein_b); } data.put("ic_purchasein_h", ic_purchasein_h); data.put("ic_purchasein_b", ic_purchasein_bs); return data; } private Object processZKCK(Order order, List orderDetls) { //组装对象数据 Map data = new HashMap(); WhsTransBillHeaderVO whsTransBillHeaderVO = new WhsTransBillHeaderVO(); whsTransBillHeaderVO.setPk_org("FYT"); whsTransBillHeaderVO.setCotherwhid(order.getItemId()); whsTransBillHeaderVO.setCtrantypeid("4K-01"); WhsTransBillBodyVO whsTransBillBodyVO = null; List whsTransBillBodyVOS = new ArrayList<>(); for (OrderDetl orderDetl : orderDetls) { NccScPcdaWms nccScPcdaWms = nccScPcdaWmsService.selectOne(new EntityWrapper().eq("vbatchcode", orderDetl.getBatch()).eq("wlbm", orderDetl.getMatnr())); if (nccScPcdaWms == null) { throw new CoolException("批次[{}]物料[{}]未找到" + orderDetl.getBatch() + orderDetl.getMatnr()); } whsTransBillBodyVO = new WhsTransBillBodyVO(); whsTransBillBodyVO.setCstateid(orderDetl.getCstateid()); String remark = orderDetl.getRemark(); //if (!Cools.isEmpty(remark)) { //NccSaleXsfhmxWms nccSaleXsfhmxWms = JSONObject.parseObject(remark, NccSaleXsfhmxWms.class); whsTransBillBodyVO.setNnum(orderDetl.getQty()); whsTransBillBodyVO.setCmaterialoid(orderDetl.getMatnr()); whsTransBillBodyVO.setVbatchcode(orderDetl.getBatch()); whsTransBillBodyVO.setPk_batchcode(nccScPcdaWms.getPkBatchcode()); //} whsTransBillHeaderVO.setCwarehouseid(orderDetl.getStandby1()); whsTransBillBodyVOS.add(whsTransBillBodyVO); } data.put("WhsTransBillHeaderVO", whsTransBillHeaderVO); data.put("WhsTransBillBodyVO", whsTransBillBodyVOS); return data; } /** * @param orderDetls * @return */ private Object processGENERALOUT2(List orderDetls, String renyuan, String rukucangku, String memo) { Object o = JSONObject.parseArray(memo).get(0); JSONObject jsonObject = JSONObject.parseObject(o.toString()); String cspecialhid = JSONObject.parseObject(jsonObject.getString("ic.WhsTransBillHeaderVO")).getString("cspecialhid"); List s = new ArrayList<>(); JSONArray objects = JSONObject.parseArray(jsonObject.getString("ic.WhsTransBillBodyVO")); for (int i = 0; i < objects.size(); i++) { s.add(objects.getJSONObject(i).getString("cspecialbid")); } //组装对象数据 Map data = new HashMap(); ic_generalout_h generalout_h = new ic_generalout_h(); generalout_h.setPk_org("FYT"); //generalout_h.setCwarehouseid("6101"); ic_generalout_b generalout_b = null; List ic_purchasein_bs = new ArrayList<>(); for (int i = 0; i < orderDetls.size(); i++) { NccScPcdaWms nccScPcdaWms = nccScPcdaWmsService.selectOne(new EntityWrapper().eq("vbatchcode", orderDetls.get(i).getBatch()).eq("wlbm", orderDetls.get(i).getMatnr())); if (nccScPcdaWms == null) { throw new CoolException("批次[{}]物料[{}]未找到" + orderDetls.get(i).getBatch() + orderDetls.get(i).getMatnr()); } OrderDetl orderDetl = orderDetls.get(i); generalout_h.setCwarehouseid(orderDetl.getStandby1()); generalout_b = new ic_generalout_b(); generalout_b.setCsourcebillbid(s.get(i)); generalout_b.setCsourcetype("4K-01"); generalout_b.setCsourcebillhid(cspecialhid); generalout_b.setCmaterialvid(orderDetl.getMatnr()); generalout_b.setCstateid(orderDetl.getCstateid()); generalout_b.setPk_batchcode(nccScPcdaWms.getPkBatchcode()); StoreType storeType = storeTypeService.selectOne(new EntityWrapper().eq("store_id", orderDetl.getStandby1())); generalout_b.setCdptvid(storeType.getDepartmentId()); generalout_b.setBillmaker(renyuan); StoreType storeType2 = storeTypeService.selectOne(new EntityWrapper().eq("store_id", rukucangku)); generalout_b.setCotherwhid(rukucangku); generalout_b.setCothercalbodyvid(storeType2.getDepartmentId()); //generalout_b.setNshouldassistnum(orderDetl.getQty()); generalout_b.setNnum(orderDetl.getQty()); generalout_b.setVbatchcode(orderDetl.getBatch()); ic_purchasein_bs.add(generalout_b); } data.put("ic_generalout_h", generalout_h); data.put("ic_generalout_b", ic_purchasein_bs); return data; } private Boolean reportApiLog(Order order, Object process1, Object process2, Object response, String docType, String url, String path, Boolean success) { HashMap request = new HashMap<>(); request.put("order", order); request.put("process1", process1); request.put("process2", process2); apiLogService.save( docType, url + path, null, "127.0.0.1", JSON.toJSONString(request), JSON.toJSONString(response), success ); return false; } }