| | |
| | | package com.zy.third.lk.task; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.core.common.Cools; |
| | | import com.core.common.DateUtils; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.DocType; |
| | | import com.zy.asrs.entity.Mat; |
| | | import com.zy.asrs.entity.Order; |
| | | import com.zy.asrs.entity.OrderDetl; |
| | | import com.zy.asrs.service.DocTypeService; |
| | |
| | | */ |
| | | @Transactional(rollbackFor = Throwable.class) |
| | | public boolean insertInDet(OrderDetl orderDetl) { |
| | | String sqlInDetTb = "select * from lk_InDetTB where BillNo='" + orderDetl.getOrderNo() + "' and " + |
| | | " ItemId='" + orderDetl.getMatnr() + "' and ItemBatch='" + orderDetl.getBatch() + "' and proType='" + orderDetl.getSpecs() + "'"; |
| | | String sqlInDetTb = "select * from lk_InDetTB where bill_no='" + orderDetl.getOrderNo() + "' and " + " item_id='" + orderDetl.getMatnr() + "' and item_batch='" + orderDetl.getBatch() + "' and pro_type='" + orderDetl.getSpecs() + "'"; |
| | | List<InDetTB> inDets = erpSqlServer.select(sqlInDetTb, InDetTB.class); |
| | | String sqlInDetTbBak = "select * from lk_InDetTB_Bak where BillNo='" + orderDetl.getOrderNo() + "' and " + |
| | | " ItemId='" + orderDetl.getMatnr() + "' and ItemBatch='" + orderDetl.getBatch() + "' and proType='" + orderDetl.getSpecs() + "'"; |
| | | String sqlInDetTbBak = "select * from lk_InDetTB_Bak where bill_no='" + orderDetl.getOrderNo() + "' and " + " item_id='" + orderDetl.getMatnr() + "' and item_batch='" + orderDetl.getBatch() + "' and pro_type='" + orderDetl.getSpecs() + "'"; |
| | | List<InDetTBBak> inDetBaks = erpSqlServer.select(sqlInDetTbBak, InDetTBBak.class); |
| | | if (!inDets.isEmpty() || !inDetBaks.isEmpty()) { |
| | | log.error("该单号料号中间表表身已存在:" + orderDetl.getOrderNo() + "==>>" + orderDetl.getOrderNo()); |
| | |
| | | return true; |
| | | } else { |
| | | log.error("入库回传失败,实体类打印:{}", content); |
| | | return false; |
| | | throw new CoolException("服务器内部错误,请联系管理员"); |
| | | } |
| | | |
| | | } |
| | |
| | | */ |
| | | @Transactional(rollbackFor = Throwable.class) |
| | | public boolean insertInHed(Order order) { |
| | | String sqlInHedTb = "select * from lk_InHedTB where LKName='中扬二期' and BillNo='" + order.getOrderNo() + "'"; |
| | | String sqlInHedTb = "select * from lk_InHedTB where LKName='高霖立库' and bill_no='" + order.getOrderNo() + "'"; |
| | | List<InHedTB> outHeds = erpSqlServer.select(sqlInHedTb, InHedTB.class); |
| | | String sqlInHedTbBak = "select * from lk_InHedTB_Bak where LKName='中扬二期' and BillNo='" + order.getOrderNo() + "'"; |
| | | String sqlInHedTbBak = "select * from lk_InHedTB_Bak where LKName='高霖立库' and bill_no='" + order.getOrderNo() + "'"; |
| | | List<InHedTBBak> inHedBaks = erpSqlServer.select(sqlInHedTbBak, InHedTBBak.class); |
| | | if (!outHeds.isEmpty() || !inHedBaks.isEmpty()) { |
| | | log.error("该单号料号中间表表头已存在:" + order.getOrderNo()); |
| | |
| | | } |
| | | DocType docType = docTypeService.selectById(order.getDocType()); |
| | | HashMap<String, Object> content = new HashMap<>(); |
| | | content.put("BillNo", "'" + order.getOrderNo() + "'"); |
| | | content.put("BillDate", "'" + DateUtils.convert(new Date()) + "'"); |
| | | if (!Cools.isEmpty(docType.getDocCode())) content.put("IoKindID", "'" + docType.getDocCode() + "'"); |
| | | if (!Cools.isEmpty(docType.getDocName())) content.put("IoKindName", "'" + docType.getDocName() + "'"); |
| | | if (!Cools.isEmpty(order.getWareId())) content.put("wareId", "'" + order.getWareId() + "'"); |
| | | if (!Cools.isEmpty(order.getWareName())) content.put("wareName", "'" + order.getWareName() + "'"); |
| | | content.put("bill_no", "'" + order.getOrderNo() + "'"); |
| | | content.put("bill_date", "'" + DateUtils.convert(new Date()) + "'"); |
| | | if (!Cools.isEmpty(docType.getDocCode())) content.put("io_kind_id", "'" + docType.getDocCode() + "'"); |
| | | if (!Cools.isEmpty(docType.getDocName())) content.put("io_kind_name", "'" + docType.getDocName() + "'"); |
| | | if (!Cools.isEmpty(order.getWareId())) content.put("ware_id", "'" + order.getWareId() + "'"); |
| | | if (!Cools.isEmpty(order.getWareName())) content.put("ware_name", "'" + order.getWareName() + "'"); |
| | | if (!Cools.isEmpty(order.getTemp1())) content.put("temp1", "'" + order.getTemp1() + "'"); |
| | | if (!Cools.isEmpty(order.getTemp2())) content.put("temp2", "'" + order.getTemp2() + "'"); |
| | | if (!Cools.isEmpty(order.getTemp3())) content.put("temp3", "'" + order.getTemp3() + "'"); |
| | | if (!Cools.isEmpty(order.getCstmr())) content.put("ObjectId", "'" + order.getCstmr() + "'"); |
| | | if (!Cools.isEmpty(order.getCstmrName())) content.put("ObjectName", "'" + order.getCstmrName() + "'"); |
| | | if (!Cools.isEmpty(order.getMemo())) content.put("Remark", "'" + order.getMemo() + "'"); |
| | | content.put("LKName", "'中扬二期'"); |
| | | content.put("bPass", "1"); |
| | | if (!Cools.isEmpty(order.getCstmr())) content.put("object_id", "'" + order.getCstmr() + "'"); |
| | | if (!Cools.isEmpty(order.getCstmrName())) content.put("object_name", "'" + order.getCstmrName() + "'"); |
| | | if (!Cools.isEmpty(order.getMemo())) content.put("remark", "'" + order.getMemo() + "'"); |
| | | content.put("LKName", "'高霖立库'"); |
| | | content.put("b_pass", "1"); |
| | | int insert = erpSqlServer.insert(InHedTB.class, content); |
| | | if (insert == 1) { |
| | | log.info("入库单表头回传成功:" + content); |
| | | return true; |
| | | } else { |
| | | log.error("入库单表头回传失败:" + content); |
| | | return false; |
| | | throw new CoolException("服务器内部错误,请联系管理员"); |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | @Transactional(rollbackFor = Throwable.class) |
| | | public boolean insertOutDet(OrderDetl orderDetl) { |
| | | String sqlInDetTb = "select * from lk_OutDetTB where BillNo='" + orderDetl.getOrderNo() + "' and " + |
| | | " ItemId='" + orderDetl.getMatnr() + "' and ItemBatch='" + orderDetl.getBatch() + "' and proType='" + orderDetl.getSpecs() + "'"; |
| | | String sqlInDetTb = "select * from lk_OutDetTB where bill_no='" + orderDetl.getOrderNo() + "' and " + " item_id='" + orderDetl.getMatnr() + "' and item_batch='" + orderDetl.getBatch() + "' and pro_type='" + orderDetl.getSpecs() + "'"; |
| | | List<OutDetTB> inDets = erpSqlServer.select(sqlInDetTb, OutDetTB.class); |
| | | String sqlInDetTbBak = "select * from lk_OutDetTB_Bak where BillNo='" + orderDetl.getOrderNo() + "' and " + |
| | | " ItemId='" + orderDetl.getMatnr() + "' and ItemBatch='" + orderDetl.getBatch() + "' and proType='" + orderDetl.getSpecs() + "'"; |
| | | String sqlInDetTbBak = "select * from lk_OutDetTB_Bak where bill_no='" + orderDetl.getOrderNo() + "' and " + " item_id='" + orderDetl.getMatnr() + "' and item_batch='" + orderDetl.getBatch() + "' and pro_type='" + orderDetl.getSpecs() + "'"; |
| | | List<OutDetTBBak> inDetBaks = erpSqlServer.select(sqlInDetTbBak, OutDetTBBak.class); |
| | | if (!inDets.isEmpty() || !inDetBaks.isEmpty()) { |
| | | log.error("该单号料号中间表表身已存在:" + orderDetl.getOrderNo() + "==>>" + orderDetl.getOrderNo()); |
| | |
| | | return true; |
| | | } else { |
| | | log.error("入库回传失败,实体类打印:" + content.toString()); |
| | | return false; |
| | | throw new CoolException("服务器内部错误,请联系管理员"); |
| | | } |
| | | |
| | | } |
| | |
| | | */ |
| | | @Transactional(rollbackFor = Throwable.class) |
| | | public boolean insertOutHed(Order order) { |
| | | String sqlInHedTb = "select * from lk_OutHedTB where LKName='中扬二期' and BillNo='" + order.getOrderNo() + "'"; |
| | | String sqlInHedTb = "select * from lk_OutHedTB where LKName='高霖立库' and bill_no='" + order.getOrderNo() + "'"; |
| | | List<OutHedTB> outHeds = erpSqlServer.select(sqlInHedTb, OutHedTB.class); |
| | | String sqlInHedTbBak = "select * from lk_OutHedTB_Bak where LKName='中扬二期' and BillNo='" + order.getOrderNo() + "'"; |
| | | String sqlInHedTbBak = "select * from lk_OutHedTB_Bak where LKName='高霖立库' and bill_no='" + order.getOrderNo() + "'"; |
| | | List<OutHedTBBak> inHedBaks = erpSqlServer.select(sqlInHedTbBak, OutHedTBBak.class); |
| | | if (!outHeds.isEmpty() || !inHedBaks.isEmpty()) { |
| | | log.error("该单号料号中间表表头已存在:" + order.getOrderNo()); |
| | |
| | | } |
| | | DocType docType = docTypeService.selectById(order.getDocType()); |
| | | HashMap<String, Object> content = new HashMap<>(); |
| | | content.put("BillNo", "'" + order.getOrderNo() + "'"); |
| | | content.put("BillDate", "'" + DateUtils.convert(new Date()) + "'"); |
| | | if (!Cools.isEmpty(docType.getDocCode())) content.put("IoKindID", "'" + docType.getDocCode() + "'"); |
| | | if (!Cools.isEmpty(docType.getDocName())) content.put("IoKindName", "'" + docType.getDocName() + "'"); |
| | | if (!Cools.isEmpty(order.getWareId())) content.put("wareId", "'" + order.getWareId() + "'"); |
| | | if (!Cools.isEmpty(order.getWareName())) content.put("wareName", "'" + order.getWareName() + "'"); |
| | | content.put("bill_no", "'" + order.getOrderNo() + "'"); |
| | | content.put("bill_no", "'" + DateUtils.convert(new Date()) + "'"); |
| | | if (!Cools.isEmpty(docType.getDocCode())) content.put("io_kind_id", "'" + docType.getDocCode() + "'"); |
| | | if (!Cools.isEmpty(docType.getDocName())) content.put("io_kind_name", "'" + docType.getDocName() + "'"); |
| | | if (!Cools.isEmpty(order.getWareId())) content.put("ware_id", "'" + order.getWareId() + "'"); |
| | | if (!Cools.isEmpty(order.getWareName())) content.put("ware_name", "'" + order.getWareName() + "'"); |
| | | if (!Cools.isEmpty(order.getUpdateTime())) content.put("make_date", "'" + order.getUpdateTime() + "'"); |
| | | if (!Cools.isEmpty(order.getTemp1())) content.put("temp1", "'" + order.getTemp1() + "'"); |
| | | if (!Cools.isEmpty(order.getTemp2())) content.put("temp2", "'" + order.getTemp2() + "'"); |
| | | if (!Cools.isEmpty(order.getTemp3())) content.put("temp3", "'" + order.getTemp3() + "'"); |
| | | if (!Cools.isEmpty(order.getCstmr())) content.put("ObjectId", "'" + order.getCstmr() + "'"); |
| | | if (!Cools.isEmpty(order.getCstmrName())) content.put("ObjectName", "'" + order.getCstmrName() + "'"); |
| | | if (!Cools.isEmpty(order.getMemo())) content.put("Remark", "'" + order.getMemo() + "'"); |
| | | content.put("LKName", "'中扬二期'"); |
| | | content.put("bPass", "1"); |
| | | if (!Cools.isEmpty(order.getCstmr())) content.put("object_id", "'" + order.getCstmr() + "'"); |
| | | if (!Cools.isEmpty(order.getCstmrName())) content.put("object_name", "'" + order.getCstmrName() + "'"); |
| | | if (!Cools.isEmpty(order.getMemo())) content.put("remark", "'" + order.getMemo() + "'"); |
| | | content.put("LKName", "'高霖立库'"); |
| | | content.put("b_pass", "1"); |
| | | int insert = erpSqlServer.insert(OutHedTB.class, content); |
| | | if (insert == 1) { |
| | | log.info("入库单表头回传成功:" + content); |
| | | return true; |
| | | } else { |
| | | log.error("入库单表头回传失败:" + content); |
| | | return false; |
| | | throw new CoolException("服务器内部错误,请联系管理员"); |
| | | } |
| | | } |
| | | |
| | | private Map<String, Object> getMap(OrderDetl orderDetl) { |
| | | Map<String, Object> content = new HashMap<>(); |
| | | if (!Cools.isEmpty(orderDetl.getOrderNo())) content.put("BillNo", "'" + orderDetl.getOrderNo() + "'"); |
| | | if (!Cools.isEmpty(orderDetl.getINo())) content.put("iNo", "'" + orderDetl.getINo() + "'"); |
| | | if (!Cools.isEmpty(orderDetl.getThreeCode())) content.put("detId", orderDetl.getThreeCode()); |
| | | if (!Cools.isEmpty(orderDetl.getMatnr())) content.put("ItemId", "'" + orderDetl.getMatnr() + "'"); |
| | | if (!Cools.isEmpty(orderDetl.getModel())) content.put("ItemCode", "'" + orderDetl.getModel() + "'"); |
| | | if (!Cools.isEmpty(orderDetl.getBatch())) content.put("ItemBatch", "'" + orderDetl.getBatch() + "'"); |
| | | if (!Cools.isEmpty(orderDetl.getProType())) content.put("proType", "'" + orderDetl.getProType() + "'"); |
| | | if (!Cools.isEmpty(orderDetl.getOrderNo())) content.put("bill_no", "'" + orderDetl.getOrderNo() + "'"); |
| | | if (!Cools.isEmpty(orderDetl.getINo())) content.put("i_no", "'" + orderDetl.getINo() + "'"); |
| | | if (!Cools.isEmpty(orderDetl.getThreeCode())) content.put("det_id", orderDetl.getThreeCode()); |
| | | if (!Cools.isEmpty(orderDetl.getMatnr())) content.put("item_id", "'" + orderDetl.getMatnr() + "'"); |
| | | if (!Cools.isEmpty(orderDetl.getModel())) content.put("item_code", "'" + orderDetl.getModel() + "'"); |
| | | if (!Cools.isEmpty(orderDetl.getBatch())) content.put("item_batch", "'" + orderDetl.getBatch() + "'"); |
| | | if (!Cools.isEmpty(orderDetl.getProType())) content.put("pro_type", "'" + orderDetl.getProType() + "'"); |
| | | if (!Cools.isEmpty(orderDetl.getUpdateTime())) content.put("make_date", "'" + orderDetl.getUpdateTime() + "'"); |
| | | if (!Cools.isEmpty(orderDetl.getMemo())) content.put("remark", "'" + orderDetl.getMemo() + "'"); |
| | | if (!Cools.isEmpty(orderDetl.getOutOrderNo())) content.put("OrderNo", "'" + orderDetl.getOutOrderNo() + "'"); |
| | | if (!Cools.isEmpty(orderDetl.getQty())) content.put("MainNum", orderDetl.getQty()); |
| | | if (!Cools.isEmpty(orderDetl.getWareId())) content.put("WareId", "'" + orderDetl.getWareId() + "'"); |
| | | if (!Cools.isEmpty(orderDetl.getWareName())) content.put("WareName", "'" + orderDetl.getWareName() + "'"); |
| | | if (!Cools.isEmpty(orderDetl.getPacking())) content.put("Packing", "'" + orderDetl.getPacking() + "'"); |
| | | if (!Cools.isEmpty(orderDetl.getLuHao())) content.put("LuHao", "'" + orderDetl.getLuHao() + "'"); |
| | | if (!Cools.isEmpty(orderDetl.getSPgNO())) content.put("sPgNO", "'" + orderDetl.getSPgNO() + "'"); |
| | | if (!Cools.isEmpty(orderDetl.getOutOrderNo())) content.put("order_no", "'" + orderDetl.getOutOrderNo() + "'"); |
| | | if (!Cools.isEmpty(orderDetl.getQty())) { |
| | | if (orderDetl.getQty() > orderDetl.getAnfme() && orderDetl.getQty() > orderDetl.getWorkQty()) { |
| | | log.info("修正错误数量:{}", JSON.toJSON(orderDetl)); |
| | | content.put("main_num", orderDetl.getWorkQty()); |
| | | } else { |
| | | content.put("main_num", orderDetl.getQty()); |
| | | } |
| | | } |
| | | if (!Cools.isEmpty(orderDetl.getWareId())) content.put("ware_id", "'" + orderDetl.getWareId() + "'"); |
| | | if (!Cools.isEmpty(orderDetl.getWareName())) content.put("ware_name", "'" + orderDetl.getWareName() + "'"); |
| | | if (!Cools.isEmpty(orderDetl.getPacking())) content.put("packing", "'" + orderDetl.getPacking() + "'"); |
| | | // if (!Cools.isEmpty(orderDetl.getLuHao())) content.put("LuHao", "'" + orderDetl.getLuHao() + "'"); |
| | | if (!Cools.isEmpty(orderDetl.getSPgNO())) content.put("s_pg_no", "'" + orderDetl.getSPgNO() + "'"); |
| | | if (!Cools.isEmpty(orderDetl.getTemp1())) content.put("temp1", "'" + orderDetl.getTemp1() + "'"); |
| | | if (!Cools.isEmpty(orderDetl.getTemp2())) content.put("temp2", "'" + orderDetl.getTemp2() + "'"); |
| | | if (!Cools.isEmpty(orderDetl.getTemp3())) content.put("temp3", "'" + orderDetl.getTemp3() + "'"); |
| | | content.put("LKName", "'中扬二期'"); |
| | | content.put("LKName", "'高霖立库'"); |
| | | return content; |
| | | } |
| | | |