| | |
| | | package com.zy.third.lk.task; |
| | | |
| | | 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 org.springframework.stereotype.Component; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | List<Order> orders = orderService.selectList(new EntityWrapper<Order>().eq("settle", 4L)); |
| | | DocType docType; |
| | | for (Order order : orders) { |
| | | System.out.println(order); |
| | | |
| | | docType = docTypeService.selectById(order.getDocType()); |
| | | if (docType == null) { |
| | | log.error("该订单类型不存在:" + order.getDocType()); |
| | |
| | | if (docType.getPakin() == 1) { |
| | | //入库单 |
| | | for (OrderDetl orderDetl : orderDetls) { |
| | | log.info("该入库单对象:" + orderDetl); |
| | | insertInDet(orderDetl); |
| | | } |
| | | insertInHed(order); |
| | | } else { |
| | | //出库单 |
| | | for (OrderDetl orderDetl : orderDetls) { |
| | | log.info("该出库单对象:" + orderDetl); |
| | | insertOutDet(orderDetl); |
| | | } |
| | | insertOutHed(order); |
| | |
| | | log.error("该单号料号中间表表身已存在:" + orderDetl.getOrderNo() + "==>>" + orderDetl.getOrderNo()); |
| | | return true; |
| | | } |
| | | Mat mat = matService.selectByMatnr(orderDetl.getMatnr()); |
| | | Map<String, Object> content = getMap(orderDetl); |
| | | int insert = erpSqlServer.insert(InDetTB.class, content); |
| | | |
| | |
| | | return true; |
| | | } else { |
| | | log.error("入库回传失败,实体类打印:{}", content); |
| | | return false; |
| | | throw new CoolException("服务器内部错误,请联系管理员"); |
| | | } |
| | | |
| | | } |
| | |
| | | log.error("该单号料号中间表表头已存在:" + order.getOrderNo()); |
| | | return true; |
| | | } |
| | | DocType docType = docTypeService.selectById(order.getDocType()); |
| | | HashMap<String, Object> content = new HashMap<>(); |
| | | content.put("BillNo", "'" + order.getOrderNo() + "'"); |
| | | content.put("IoKindID", "'" + order.getDocType() + "'"); |
| | | content.put("ObjectId", "'" + order.getCstmr() + "'"); |
| | | content.put("ObjectName", "'" + order.getCstmrName() + "'"); |
| | | content.put("Remark", "'" + order.getMemo() + "'"); |
| | | 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() + "'"); |
| | | 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"); |
| | | int insert = erpSqlServer.insert(InHedTB.class, content); |
| | | String sql = "UPDATE lk_InHedTB SET bPass = 1, LKName='中扬二期' WHERE BillNo = '" + order.getOrderNo() + "'"; |
| | | int update = erpSqlServer.update(sql); |
| | | if (update == 1) { |
| | | if (insert == 1) { |
| | | log.info("入库单表头回传成功:" + content); |
| | | return true; |
| | | } else { |
| | | log.error("入库单表头回传失败:" + content); |
| | | return false; |
| | | throw new CoolException("服务器内部错误,请联系管理员"); |
| | | } |
| | | } |
| | | |
| | |
| | | log.error("该单号料号中间表表身已存在:" + orderDetl.getOrderNo() + "==>>" + orderDetl.getOrderNo()); |
| | | return true; |
| | | } |
| | | Mat mat = matService.selectByMatnr(orderDetl.getMatnr()); |
| | | Map<String, Object> content = getMap(orderDetl); |
| | | int insert = erpSqlServer.insert(InDetTB.class, content); |
| | | int insert = erpSqlServer.insert(OutDetTB.class, content); |
| | | |
| | | if (insert == 1) { |
| | | log.info("入库单表身回传成功:" + content.toString()); |
| | | return true; |
| | | } else { |
| | | log.error("入库回传失败,实体类打印:" + content.toString()); |
| | | return false; |
| | | throw new CoolException("服务器内部错误,请联系管理员"); |
| | | } |
| | | |
| | | } |
| | |
| | | log.error("该单号料号中间表表头已存在:" + order.getOrderNo()); |
| | | return true; |
| | | } |
| | | DocType docType = docTypeService.selectById(order.getDocType()); |
| | | HashMap<String, Object> content = new HashMap<>(); |
| | | content.put("BillNo", "'" + order.getOrderNo() + "'"); |
| | | content.put("IoKindID", "'" + order.getDocType() + "'"); |
| | | content.put("ObjectId", "'" + order.getCstmr() + "'"); |
| | | content.put("ObjectName", "'" + order.getCstmrName() + "'"); |
| | | content.put("Remark", "'" + order.getMemo() + "'"); |
| | | 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() + "'"); |
| | | 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"); |
| | | int insert = erpSqlServer.insert(OutHedTB.class, content); |
| | | String sql = "UPDATE lk_OutHedTB SET bPass = 1, LKName='中扬二期' WHERE BillNo = '" + order.getOrderNo() + "'"; |
| | | int update = erpSqlServer.update(sql); |
| | | if (update == 1) { |
| | | 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<>(); |
| | | content.put("BillNo", "'" + orderDetl.getOrderNo() + "'"); |
| | | content.put("iNO", "'" + orderDetl.getINO() + "'"); |
| | | content.put("detId", orderDetl.getThreeCode()); |
| | | content.put("ItemId", "'" + orderDetl.getThreeCode() + "'"); |
| | | content.put("ItemCode", "'" + orderDetl.getMatnr() + "'"); |
| | | content.put("ItemBatch", "'" + orderDetl.getBatch() + "'"); |
| | | content.put("proType", "'" + orderDetl.getProType() + "'"); |
| | | content.put("remark", "'" + orderDetl.getMemo() + "'"); |
| | | content.put("OrderNo", "'" + orderDetl.getOutOrderNo() + "'"); |
| | | content.put("MainNum", orderDetl.getQty()); |
| | | content.put("WareId", "'" + orderDetl.getWareId() + "'"); |
| | | content.put("WareName", "'" + orderDetl.getWareName() + "'"); |
| | | content.put("Packing", "'" + orderDetl.getPacking() + "'"); |
| | | content.put("LuHao", "'" + orderDetl.getLuHao() + "'"); |
| | | content.put("sPgNO", "'" + orderDetl.getSPgNO() + "'"); |
| | | content.put("temp1", "'" + orderDetl.getTemp1() + "'"); |
| | | content.put("temp2", "'" + orderDetl.getTemp2() + "'"); |
| | | content.put("temp3", "'" + orderDetl.getTemp3() + "'"); |
| | | 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.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.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", "'中扬二期'"); |
| | | return content; |
| | | } |
| | | |
| | | |
| | | } |