From 9089cef7796121ae34f948c03bc434984089453b Mon Sep 17 00:00:00 2001 From: yinq Date: Wed, 6 Dec 2023 09:41:19 +0800 Subject: [PATCH] =?UTF-8?q?update=20-=20=E8=87=AA=E5=8A=A8=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=E7=94=9F=E4=BA=A7BOM=E3=80=81=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E7=94=9F=E6=88=90=E7=94=9F=E4=BA=A7=E8=AE=A1=E5=88=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../aucma/api/domain/vo/SAPResultBomVo.java | 32 ---- .../api/service/ISAPPutStorageService.java | 2 +- .../api/service/impl/SAPPortServiceImpl.java | 6 +- .../impl/SAPPutStorageServiceImpl.java | 98 ++++++++-- .../BaseMaterialInfoController.java | 1 - .../com/aucma/base/domain/BaseOrderInfo.java | 26 +++ .../aucma/base/mapper/OrderBomInfoMapper.java | 8 + .../impl/BaseMaterialInfoServiceImpl.java | 1 + .../service/impl/OrderBomInfoServiceImpl.java | 21 ++- .../mapper/base/BaseMaterialinfoMapper.xml | 4 +- .../mapper/base/BaseOrderInfoMapper.xml | 96 +++++----- .../mapper/base/OrderBomInfoMapper.xml | 22 ++- .../controller/BaseBomInfoController.java | 12 ++ .../service/IBaseBomInfoService.java | 7 + .../service/impl/BaseBomInfoServiceImpl.java | 43 ++++- .../impl/ProductPlanInfoServiceImpl.java | 3 +- .../mapper/production/BaseBomInfoMapper.xml | 173 +++++++++--------- .../mapper/production/CalendarInfoMapper.xml | 4 +- 18 files changed, 359 insertions(+), 200 deletions(-) diff --git a/aucma-api/src/main/java/com/aucma/api/domain/vo/SAPResultBomVo.java b/aucma-api/src/main/java/com/aucma/api/domain/vo/SAPResultBomVo.java index ab1533b..4fa5dd4 100644 --- a/aucma-api/src/main/java/com/aucma/api/domain/vo/SAPResultBomVo.java +++ b/aucma-api/src/main/java/com/aucma/api/domain/vo/SAPResultBomVo.java @@ -22,12 +22,6 @@ public class SAPResultBomVo { @JsonProperty(value = "O_RETURN") private WERKSDto O_RETURN; - @JsonProperty(value = "EDATE") - private String EDATE; - @JsonProperty(value = "NDATE") - private String NDATE; - @JsonProperty(value = "XTYPE") - private String XTYPE; public HashMap>> getO_TAB() { return O_TAB; @@ -53,29 +47,6 @@ public class SAPResultBomVo { O_RETURN = o_RETURN; } - public String getEDATE() { - return EDATE; - } - - public void setEDATE(String EDATE) { - this.EDATE = EDATE; - } - - public String getNDATE() { - return NDATE; - } - - public void setNDATE(String NDATE) { - this.NDATE = NDATE; - } - - public String getXTYPE() { - return XTYPE; - } - - public void setXTYPE(String XTYPE) { - this.XTYPE = XTYPE; - } @Override public String toString() { @@ -83,9 +54,6 @@ public class SAPResultBomVo { "O_TAB=" + O_TAB + ", WERKS=" + WERKS + ", O_RETURN=" + O_RETURN + - ", EDATE='" + EDATE + '\'' + - ", NDATE='" + NDATE + '\'' + - ", XTYPE='" + XTYPE + '\'' + '}'; } } diff --git a/aucma-api/src/main/java/com/aucma/api/service/ISAPPutStorageService.java b/aucma-api/src/main/java/com/aucma/api/service/ISAPPutStorageService.java index 46fe822..47b10a9 100644 --- a/aucma-api/src/main/java/com/aucma/api/service/ISAPPutStorageService.java +++ b/aucma-api/src/main/java/com/aucma/api/service/ISAPPutStorageService.java @@ -44,6 +44,6 @@ public interface ISAPPutStorageService { * 转换产品bom信息实体类 保存数据 * * */ - public ArrayList insertSAPOrderBomInfo(SAPResultOrderInfoVo resultVo) throws ParseException; + public ArrayList insertSAPOrderBomInfo(SAPResultBomVo resultVo) throws ParseException; } diff --git a/aucma-api/src/main/java/com/aucma/api/service/impl/SAPPortServiceImpl.java b/aucma-api/src/main/java/com/aucma/api/service/impl/SAPPortServiceImpl.java index 8f174f8..88c29e5 100644 --- a/aucma-api/src/main/java/com/aucma/api/service/impl/SAPPortServiceImpl.java +++ b/aucma-api/src/main/java/com/aucma/api/service/impl/SAPPortServiceImpl.java @@ -4,6 +4,7 @@ package com.aucma.api.service.impl; import com.aucma.api.domain.dto.SAPBOMPortDto; import com.aucma.api.domain.dto.SAPPortDto; import com.aucma.api.domain.dto.WERKSDto; +import com.aucma.api.domain.vo.SAPResultBomVo; import com.aucma.api.domain.vo.SAPResultOrderInfoVo; import com.aucma.api.domain.vo.SAPResultVo; import com.aucma.api.service.ISAPPortService; @@ -17,6 +18,7 @@ import com.aucma.base.domain.OrderBomInfo; import com.aucma.common.exception.base.BaseException; import com.aucma.common.utils.StringUtils; import com.aucma.system.utils.PortLogUtils; +import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -111,7 +113,7 @@ public class SAPPortServiceImpl implements ISAPPortService { if (StringUtils.isNull(resultVo.getO_RETURN()) || !resultVo.getO_RETURN().getItem().get(0).get("ID").contains("0")){ throw new BaseException("处理接口返回消息错误!(ID不为0或O_RETURN为空)"); } - //转物料实体类 保存数据 + //转工单实体类 保存数据 baseOrderInfoVos = storageService.insertSAPBaseOrderInfo(resultVo); //保存接口日志 PortLogUtils.savePortLog(werks.getItem().get(0).get("WERKS"), "获取生产工单" + intervalDate, "getSAPBaseOrderInfo", requestParam, result, null); @@ -194,7 +196,7 @@ public class SAPPortServiceImpl implements ISAPPortService { // 处理接口返回消息 ObjectMapper resultMapper = new ObjectMapper(); // 将 JSON 字符串转换为 Java 对象 - SAPResultOrderInfoVo resultVo = resultMapper.readValue(result, SAPResultOrderInfoVo.class); + SAPResultBomVo resultVo = resultMapper.readValue(result, SAPResultBomVo.class); //判断返回数据是否正确 if (StringUtils.isNull(resultVo.getO_RETURN()) || !resultVo.getO_RETURN().getItem().get(0).get("ID").contains("0")){ throw new BaseException("处理接口返回消息错误!(ID不为0或O_RETURN为空)"); diff --git a/aucma-api/src/main/java/com/aucma/api/service/impl/SAPPutStorageServiceImpl.java b/aucma-api/src/main/java/com/aucma/api/service/impl/SAPPutStorageServiceImpl.java index 1b05b57..47eb07e 100644 --- a/aucma-api/src/main/java/com/aucma/api/service/impl/SAPPutStorageServiceImpl.java +++ b/aucma-api/src/main/java/com/aucma/api/service/impl/SAPPutStorageServiceImpl.java @@ -1,5 +1,6 @@ package com.aucma.api.service.impl; +import com.aucma.api.domain.vo.SAPResultBomVo; import com.aucma.api.domain.vo.SAPResultOrderInfoVo; import com.aucma.api.domain.vo.SAPResultVo; import com.aucma.api.service.ISAPPutStorageService; @@ -60,13 +61,14 @@ public class SAPPutStorageServiceImpl implements ISAPPutStorageService { ArrayList baseMaterialInfoArrayList = new ArrayList<>(); List> itemList = resultVo.getO_TAB().get("item"); for (HashMap map : itemList) { - if (StringUtils.isEmpty(map.get("WERKS")) || !map.get("WERKS").equals(SAPConstants.FACTORY_CODE)){ + if (StringUtils.isEmpty(map.get("WERKS")) || !map.get("WERKS").equals(SAPConstants.FACTORY_CODE)) { continue; } BaseMaterialInfo baseMaterialInfo = new BaseMaterialInfo(); baseMaterialInfo.setPlantCode(map.get("WERKS")); baseMaterialInfo.setMaterialCode(map.get("MATNR")); List baseMaterialInfoList = baseMaterialInfoService.selectBaseMaterialInfoList(baseMaterialInfo); + // 插入物料数据 if (baseMaterialInfoList.isEmpty()) { BaseMaterialInfo materialInfo = new BaseMaterialInfo(); materialInfo.setMaterialCode(map.get("MATNR")); @@ -76,14 +78,62 @@ public class SAPPutStorageServiceImpl implements ISAPPutStorageService { materialInfo.setMaterialUnit(map.get("MEINS")); materialInfo.setMaterialMatkl(map.get("MATKL")); materialInfo.setDISPO(map.get("DISPO")); - materialInfo.setIncrementDate(DateUtils.dateTime(DateUtils.YYYY_MM_DD,map.get("UDATE"))); + this.getMaterialType(materialInfo); + materialInfo.setMaterialCategories("100"); + materialInfo.setIncrementDate(DateUtils.dateTime(DateUtils.YYYY_MM_DD, map.get("UDATE"))); baseMaterialInfoService.insertBaseMaterialInfo(materialInfo); baseMaterialInfoArrayList.add(materialInfo); + } else { + //修改物料数据 + BaseMaterialInfo materialInfo = baseMaterialInfoList.get(0); + materialInfo.setMaterialName(map.get("MAKTX")); + materialInfo.setMaterialType(map.get("MTART")); + materialInfo.setMaterialUnit(map.get("MEINS")); + materialInfo.setMaterialMatkl(map.get("MATKL")); + String dispo = map.get("DISPO"); + materialInfo.setDISPO(dispo); + this.getMaterialType(materialInfo); + materialInfo.setMaterialCategories("100"); + materialInfo.setIncrementDate(DateUtils.dateTime(DateUtils.YYYY_MM_DD, map.get("UDATE"))); + baseMaterialInfoService.updateBaseMaterialInfo(materialInfo); + baseMaterialInfoArrayList.add(materialInfo); } } return baseMaterialInfoArrayList; } + /** + * 获取物料类型 + * + * @param materialInfo + * @return + */ + private BaseMaterialInfo getMaterialType(BaseMaterialInfo materialInfo) { + String dispo = materialInfo.getDISPO(); + if (StringUtils.isNotEmpty(dispo)) { + //(100=成品;200=箱体;300=门体) + if (dispo.equals("100") || dispo.equals("200") || dispo.equals("300")) { + materialInfo.setMaterialSubclass(dispo); + } + } + //400=围板;500=内胆 + if (StringUtils.isEmpty(materialInfo.getMaterialSubclass()) && materialInfo.getMaterialName().contains("内胆部件")) { + materialInfo.setMaterialSubclass("500"); + } + if (StringUtils.isEmpty(materialInfo.getMaterialSubclass()) && materialInfo.getMaterialName().contains("预装箱体")) { + materialInfo.setMaterialSubclass("400"); + } + if (StringUtils.isEmpty(materialInfo.getMaterialSubclass()) && materialInfo.getMaterialName().contains("箱壳部件")) { + materialInfo.setMaterialSubclass("400"); + } + //其他 + if (StringUtils.isEmpty(materialInfo.getMaterialSubclass())) { + materialInfo.setMaterialSubclass("900"); + } + return materialInfo; + + } + /** * 转换生产工单实体类 保存数据 */ @@ -92,7 +142,7 @@ public class SAPPutStorageServiceImpl implements ISAPPutStorageService { ArrayList baseOrderInfoList = new ArrayList<>(); List> itemList = resultVo.getO_TAB().get("item"); for (HashMap map : itemList) { - if (StringUtils.isEmpty(map.get("WERKS")) || !map.get("WERKS").equals(SAPConstants.FACTORY_CODE)){ + if (StringUtils.isEmpty(map.get("WERKS")) || !map.get("WERKS").equals(SAPConstants.FACTORY_CODE)) { continue; } BaseOrderInfo boInfo = new BaseOrderInfo(); @@ -113,8 +163,10 @@ public class SAPPutStorageServiceImpl implements ISAPPutStorageService { } baseOrderInfo.setFactoryCode(map.get("WERKS")); baseOrderInfo.setOrderType(map.get("AUART")); - baseOrderInfo.setBeginDate(new SimpleDateFormat("yyyy-MM-dd").parse(map.get("GLTRP"))); - baseOrderInfo.setEndDate(new SimpleDateFormat("yyyy-MM-dd").parse(map.get("GSTRP"))); + baseOrderInfo.setWorkCenterCode(map.get("ARBPL")); + baseOrderInfo.setRoutingCode(map.get("AUFPL")); + baseOrderInfo.setBeginDate(new SimpleDateFormat("yyyy-MM-dd").parse(map.get("GSTRP"))); + baseOrderInfo.setEndDate(new SimpleDateFormat("yyyy-MM-dd").parse(map.get("GLTRP"))); // 同步生产日历 CalendarInfo calendarInfo = new CalendarInfo(); @@ -128,29 +180,33 @@ public class SAPPutStorageServiceImpl implements ISAPPutStorageService { calendarInfoService.insertCalendarInfo(calendarInfo); baseOrderInfoService.insertBaseOrderInfo(baseOrderInfo); baseOrderInfoList.add(baseOrderInfo); - }else { + } else { //更新SAP计划 BaseOrderInfo baseOrderInfo = baseOrderInfos.get(0); - if (baseOrderInfo.getIsRelease() == 0){ - //SAP计划已下达到工位不更新数据 + if (baseOrderInfo.getIsRelease() == 0) { + //SAP计划已下达到生产计划工位不更新数据 continue; } baseOrderInfo.setOrderStatus(map.get("STTXT")); baseOrderInfo.setSaleOrderCode(map.get("KDAUF")); baseOrderInfo.setMaterialName(map.get("MAKTX")); + baseOrderInfo.setOrderType(map.get("AUART")); if (!map.get("GAMNG").equals(null)) { baseOrderInfo.setOrderAmount(new BigDecimal(map.get("GAMNG"))); } - baseOrderInfo.setOrderType(map.get("AUART")); - baseOrderInfo.setBeginDate(new SimpleDateFormat("yyyy-MM-dd").parse(map.get("GLTRP"))); - baseOrderInfo.setEndDate(new SimpleDateFormat("yyyy-MM-dd").parse(map.get("GSTRP"))); + + baseOrderInfo.setWorkCenterCode(map.get("ARBPL")); + baseOrderInfo.setRoutingCode(map.get("AUFPL")); + baseOrderInfo.setBeginDate(new SimpleDateFormat("yyyy-MM-dd").parse(map.get("GSTRP"))); + baseOrderInfo.setEndDate(new SimpleDateFormat("yyyy-MM-dd").parse(map.get("GLTRP"))); baseOrderInfoService.updateBaseOrderInfo(baseOrderInfo); // 同步生产日历 CalendarInfo calendar = new CalendarInfo(); calendar.setSapPlanCode(baseOrderInfo.getOrderCode()); + calendar.setMaterialCode(baseOrderInfo.getMaterialCode()); List calendarInfos = calendarInfoService.selectCalendarInfoList(calendar); - if (calendarInfos.size() == 1){ + if (calendarInfos.size() == 1) { CalendarInfo calendarInfo = calendarInfos.get(0); calendarInfo.setMaterialName(baseOrderInfo.getMaterialName()); calendarInfo.setPlanStartDate(baseOrderInfo.getBeginDate()); @@ -176,11 +232,12 @@ public class SAPPutStorageServiceImpl implements ISAPPutStorageService { ArrayList baseDeviceLedgerArrayList = new ArrayList<>(); List> itemList = resultVo.getO_TAB().get("item"); for (HashMap map : itemList) { - if (StringUtils.isEmpty(map.get("WERKS")) || !map.get("WERKS").equals(SAPConstants.FACTORY_CODE)){ + if (StringUtils.isEmpty(map.get("WERKS")) || !map.get("WERKS").equals(SAPConstants.FACTORY_CODE)) { continue; } BaseDeviceLedger device = new BaseDeviceLedger(); - device.setCostCenter(map.get("KOSTL"));; + device.setCostCenter(map.get("KOSTL")); + ; device.setDeviceCode(map.get("EQUNR")); device.setFactoryCode(map.get("IWERK")); List baseDeviceLedgers = baseDeviceLedgerService.selectBaseDeviceLedgerList(device); @@ -204,14 +261,13 @@ public class SAPPutStorageServiceImpl implements ISAPPutStorageService { /** * 转换产品bom信息实体类 保存数据 - * - * */ + */ @Override - public ArrayList insertSAPOrderBomInfo(SAPResultOrderInfoVo resultVo) throws ParseException { + public ArrayList insertSAPOrderBomInfo(SAPResultBomVo resultVo) throws ParseException { ArrayList orderBomInfoList = new ArrayList<>(); List> itemList = resultVo.getO_TAB().get("item"); for (HashMap map : itemList) { - if (StringUtils.isEmpty(map.get("WERKS")) || !map.get("WERKS").equals(SAPConstants.FACTORY_CODE)){ + if (StringUtils.isEmpty(map.get("WERKS")) || !map.get("WERKS").equals(SAPConstants.FACTORY_CODE)) { continue; } OrderBomInfo bomInfo = new OrderBomInfo(); @@ -230,7 +286,11 @@ public class SAPPutStorageServiceImpl implements ISAPPutStorageService { orderBomInfo.setSort(map.get("SORTF")); orderBomInfo.setVbeln(map.get("VBELN")); orderBomInfo.setVbpos(map.get("VBPOS")); - orderBomInfoService.insertOrderBomInfo(orderBomInfo); + try { + orderBomInfoService.insertOrderBomInfo(orderBomInfo); + } catch (Exception e) { + e.printStackTrace(); + } orderBomInfoList.add(orderBomInfo); } } diff --git a/aucma-base/src/main/java/com/aucma/base/controller/BaseMaterialInfoController.java b/aucma-base/src/main/java/com/aucma/base/controller/BaseMaterialInfoController.java index 7635d75..409b6bf 100644 --- a/aucma-base/src/main/java/com/aucma/base/controller/BaseMaterialInfoController.java +++ b/aucma-base/src/main/java/com/aucma/base/controller/BaseMaterialInfoController.java @@ -86,7 +86,6 @@ public class BaseMaterialInfoController extends BaseController { @PutMapping public AjaxResult edit(@RequestBody BaseMaterialInfo baseMaterialInfo) { baseMaterialInfo.setUpdatedBy(getUsername()); - baseMaterialInfo.setUpdatedTime(DateUtils.getNowDate()); return toAjax(baseMaterialInfoService.updateBaseMaterialInfo(baseMaterialInfo)); } diff --git a/aucma-base/src/main/java/com/aucma/base/domain/BaseOrderInfo.java b/aucma-base/src/main/java/com/aucma/base/domain/BaseOrderInfo.java index 81186b9..da7284b 100644 --- a/aucma-base/src/main/java/com/aucma/base/domain/BaseOrderInfo.java +++ b/aucma-base/src/main/java/com/aucma/base/domain/BaseOrderInfo.java @@ -148,6 +148,32 @@ public class BaseOrderInfo extends BaseEntity { @Excel(name = "完成日期", width = 30, dateFormat = "yyyy-MM-dd") private Date completeDate; + /** + * 工作中心 + */ + private String workCenterCode; + + /** + * 工艺路线 + */ + private String routingCode; + + public String getWorkCenterCode() { + return workCenterCode; + } + + public void setWorkCenterCode(String workCenterCode) { + this.workCenterCode = workCenterCode; + } + + public String getRoutingCode() { + return routingCode; + } + + public void setRoutingCode(String routingCode) { + this.routingCode = routingCode; + } + public Long getIsRelease() { return isRelease; } diff --git a/aucma-base/src/main/java/com/aucma/base/mapper/OrderBomInfoMapper.java b/aucma-base/src/main/java/com/aucma/base/mapper/OrderBomInfoMapper.java index 1b9cd77..e802c85 100644 --- a/aucma-base/src/main/java/com/aucma/base/mapper/OrderBomInfoMapper.java +++ b/aucma-base/src/main/java/com/aucma/base/mapper/OrderBomInfoMapper.java @@ -28,6 +28,14 @@ public interface OrderBomInfoMapper */ public List selectOrderBomInfoList(OrderBomInfo orderBomInfo); + /** + * 查询成品订单BOM列表 + * + * @param orderBomInfo 订单BOM + * @return 订单BOM集合 + */ + public List selectFinishedProductBomInfoList(OrderBomInfo orderBomInfo); + /** * 新增订单BOM * diff --git a/aucma-base/src/main/java/com/aucma/base/service/impl/BaseMaterialInfoServiceImpl.java b/aucma-base/src/main/java/com/aucma/base/service/impl/BaseMaterialInfoServiceImpl.java index 869cc15..aa496ef 100644 --- a/aucma-base/src/main/java/com/aucma/base/service/impl/BaseMaterialInfoServiceImpl.java +++ b/aucma-base/src/main/java/com/aucma/base/service/impl/BaseMaterialInfoServiceImpl.java @@ -67,6 +67,7 @@ public class BaseMaterialInfoServiceImpl implements IBaseMaterialInfoService @Override public int updateBaseMaterialInfo(BaseMaterialInfo baseMaterialInfo) { + baseMaterialInfo.setUpdatedTime(DateUtils.getNowDate()); return baseMaterialInfoMapper.updateBaseMaterialInfo(baseMaterialInfo); } diff --git a/aucma-base/src/main/java/com/aucma/base/service/impl/OrderBomInfoServiceImpl.java b/aucma-base/src/main/java/com/aucma/base/service/impl/OrderBomInfoServiceImpl.java index 63d3bbb..6fd76d7 100644 --- a/aucma-base/src/main/java/com/aucma/base/service/impl/OrderBomInfoServiceImpl.java +++ b/aucma-base/src/main/java/com/aucma/base/service/impl/OrderBomInfoServiceImpl.java @@ -56,13 +56,17 @@ public class OrderBomInfoServiceImpl implements IOrderBomInfoService @Override public int insertOrderBomInfo(OrderBomInfo orderBomInfo) { - OrderBomInfo bomInfo = orderBomInfoMapper.selectOrderBomInfoByMaterialCode(orderBomInfo.getMaterialCode()); - if (StringUtils.isNotNull(bomInfo)){ - throw new BaseException("该物料编号:" + orderBomInfo.getMaterialCode() + "已存在!"); - } +// OrderBomInfo bomInfo = orderBomInfoMapper.selectOrderBomInfoByMaterialCode(orderBomInfo.getMaterialCode()); +// if (StringUtils.isNotNull(bomInfo)){ +// throw new BaseException("该物料编号:" + orderBomInfo.getMaterialCode() + "已存在!"); +// } if (StringUtils.isNotNull(orderBomInfo.getParentId())){ OrderBomInfo info = orderBomInfoMapper.selectOrderBomInfoByMaterialCode(orderBomInfo.getParentId()); - orderBomInfo.setAncestors(info.getAncestors() + "," + orderBomInfo.getMaterialCode()); + if (StringUtils.isNotNull(info)){ + orderBomInfo.setAncestors(info.getAncestors() + "," + orderBomInfo.getMaterialCode()); + }else { + orderBomInfo.setAncestors(orderBomInfo.getParentId() + "," + orderBomInfo.getMaterialCode()); + } }else { orderBomInfo.setAncestors(orderBomInfo.getMaterialCode()); } @@ -73,15 +77,14 @@ public class OrderBomInfoServiceImpl implements IOrderBomInfoService /** * 修改订单BOM * - * @param orderBomInfo 订单BOM + * @param orderBom 订单BOM * @return 结果 */ @Override - public int updateOrderBomInfo(OrderBomInfo orderBomInfoa) + public int updateOrderBomInfo(OrderBomInfo orderBom) { List orderBomInfos = orderBomInfoMapper.selectOrderBomInfoList(new OrderBomInfo()); for (OrderBomInfo orderBomInfo : orderBomInfos) { - String parentId = orderBomInfo.getParentId(); if (StringUtils.isNull(parentId)){ orderBomInfo.setAncestors(orderBomInfo.getMaterialCode()); @@ -99,7 +102,7 @@ public class OrderBomInfoServiceImpl implements IOrderBomInfoService orderBomInfo.setUpdatedTime(DateUtils.getNowDate()); orderBomInfoMapper.updateOrderBomInfo(orderBomInfo); } - return orderBomInfoMapper.updateOrderBomInfo(orderBomInfoa); + return orderBomInfoMapper.updateOrderBomInfo(orderBom); } /** diff --git a/aucma-base/src/main/resources/mapper/base/BaseMaterialinfoMapper.xml b/aucma-base/src/main/resources/mapper/base/BaseMaterialinfoMapper.xml index 7dc1df3..2a2165e 100644 --- a/aucma-base/src/main/resources/mapper/base/BaseMaterialinfoMapper.xml +++ b/aucma-base/src/main/resources/mapper/base/BaseMaterialinfoMapper.xml @@ -105,7 +105,7 @@ #{objId}, #{materialCode}, - #{materialName}, + #{materialName,jdbcType=NVARCHAR}, #{materialCategories}, #{materialSubclass}, #{materialType}, @@ -128,7 +128,7 @@ update base_materialinfo material_code = #{materialCode}, - material_name = #{materialName}, + material_name = #{materialName,jdbcType=NVARCHAR}, material_categories = #{materialCategories}, material_subclass = #{materialSubclass}, material_type = #{materialType}, diff --git a/aucma-base/src/main/resources/mapper/base/BaseOrderInfoMapper.xml b/aucma-base/src/main/resources/mapper/base/BaseOrderInfoMapper.xml index c428617..dc877f7 100644 --- a/aucma-base/src/main/resources/mapper/base/BaseOrderInfoMapper.xml +++ b/aucma-base/src/main/resources/mapper/base/BaseOrderInfoMapper.xml @@ -26,60 +26,66 @@ + + - select obj_id, - order_code, - saleorder_code, - saleorder_linenumber, - material_code, - material_name, - matkl, - order_amount, - complete_amount, - order_type, - order_status, - begin_date, - end_date, - factory_code, - is_flag, - is_release, - created_by, - created_time, - updated_by, - updated_time, - complete_date - from base_orderinfo + select oi.obj_id, + oi.order_code, + oi.saleorder_code, + oi.saleorder_linenumber, + oi.material_code, + oi.material_name, + oi.matkl, + oi.order_amount, + oi.complete_amount, + oi.order_type, + oi.order_status, + oi.begin_date, + oi.end_date, + oi.factory_code, + oi.is_flag, + oi.is_release, + oi.work_center_code, + oi.routing_code, + oi.created_by, + oi.created_time, + oi.updated_by, + oi.updated_time, + oi.complete_date + from base_orderinfo oi @@ -116,6 +122,8 @@ updated_by, updated_time, complete_date, + work_center_code, + routing_code, #{objId}, @@ -123,7 +131,7 @@ #{saleOrderCode}, #{saleOrderLineNumber}, #{materialCode}, - #{materialName}, + #{materialName,jdbcType=NVARCHAR}, #{matkl}, #{orderAmount}, #{completeAmount}, @@ -139,6 +147,8 @@ #{updatedBy}, #{updatedTime}, #{completeDate}, + #{workCenterCode}, + #{routingCode}, @@ -149,7 +159,7 @@ saleorder_code = #{saleOrderCode}, saleorder_linenumber = #{saleOrderLineNumber}, material_code = #{materialCode}, - material_name = #{materialName}, + material_name = #{materialName,jdbcType=NVARCHAR}, matkl = #{matkl}, order_amount = #{orderAmount}, complete_amount = #{completeAmount}, diff --git a/aucma-base/src/main/resources/mapper/base/OrderBomInfoMapper.xml b/aucma-base/src/main/resources/mapper/base/OrderBomInfoMapper.xml index eb586a6..0296c1a 100644 --- a/aucma-base/src/main/resources/mapper/base/OrderBomInfoMapper.xml +++ b/aucma-base/src/main/resources/mapper/base/OrderBomInfoMapper.xml @@ -50,13 +50,12 @@ and ob.bom_code = #{bomCode} - and ob.material_code = #{materialCode} - and bm.material_name like concat(concat('%', - #{materialName}), '%') + and ob.material_code like concat(#{materialCode}, '%') + and bm.material_name like concat(concat('%',#{materialName}), '%') and ob.material_type = #{materialType} and ob.standard_amount = #{standardAmount} - and ob.parent_id = #{parentId} + and ob.parent_id = like concat(#{parentId}, '%') and ob.is_flag = #{isFlag} and ob.created_by = #{createdBy} and ob.created_time = #{createdTime} @@ -166,6 +165,21 @@ select * from order_bominfo where FIND_IN_SET(#{materialCode}, ancestors) ]]> 0 + + + update order_bominfo set ancestors = list = baseBomInfoService.addAutomaticSynchronizationBOM(baseBomInfo); + return success(list); + } + } diff --git a/aucma-production/src/main/java/com/aucma/production/service/IBaseBomInfoService.java b/aucma-production/src/main/java/com/aucma/production/service/IBaseBomInfoService.java index 25c4718..3fa6180 100644 --- a/aucma-production/src/main/java/com/aucma/production/service/IBaseBomInfoService.java +++ b/aucma-production/src/main/java/com/aucma/production/service/IBaseBomInfoService.java @@ -65,4 +65,11 @@ public interface IBaseBomInfoService * @param baseBomInfoList */ void checkBomInfo(List baseBomInfoList); + + /** + * 自动同步生产BOM + * @param baseBomInfo + * @return + */ + List addAutomaticSynchronizationBOM(BaseBomInfo baseBomInfo); } diff --git a/aucma-production/src/main/java/com/aucma/production/service/impl/BaseBomInfoServiceImpl.java b/aucma-production/src/main/java/com/aucma/production/service/impl/BaseBomInfoServiceImpl.java index e514364..5943840 100644 --- a/aucma-production/src/main/java/com/aucma/production/service/impl/BaseBomInfoServiceImpl.java +++ b/aucma-production/src/main/java/com/aucma/production/service/impl/BaseBomInfoServiceImpl.java @@ -2,8 +2,11 @@ package com.aucma.production.service.impl; import java.util.List; +import com.aucma.base.domain.OrderBomInfo; +import com.aucma.base.mapper.OrderBomInfoMapper; import com.aucma.common.exception.ServiceException; import com.aucma.common.exception.base.BaseException; +import com.aucma.common.utils.DateUtils; import com.aucma.common.utils.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -23,6 +26,8 @@ public class BaseBomInfoServiceImpl implements IBaseBomInfoService @Autowired private BaseBomInfoMapper baseBomInfoMapper; + @Autowired + private OrderBomInfoMapper orderBomInfoMapper; /** * 查询生产BOM * @@ -56,8 +61,8 @@ public class BaseBomInfoServiceImpl implements IBaseBomInfoService @Override public int insertBaseBomInfo(BaseBomInfo baseBomInfo) { - BaseBomInfo bomInfo = baseBomInfoMapper.selectBaseBomInfoByMaterialCode(baseBomInfo.getMaterialCode()); - if (StringUtils.isNotNull(bomInfo)){ + List baseBomInfos = baseBomInfoMapper.selectBaseBomInfoList(baseBomInfo); + if (StringUtils.isNotNull(baseBomInfos)){ throw new BaseException("该物料编号:" + baseBomInfo.getMaterialCode() + "已存在!"); } if (StringUtils.isNotNull(baseBomInfo.getParentId())){ @@ -155,4 +160,38 @@ public class BaseBomInfoServiceImpl implements IBaseBomInfoService } } + /** + * 自动同步生产BOM + * @param baseBomInfo + * @return + */ + @Override + public List addAutomaticSynchronizationBOM(BaseBomInfo baseBomInfo) { + // 获取成品BOM + OrderBomInfo bomInfo = new OrderBomInfo(); + bomInfo.setMaterialCode("90"); + List orderBomInfos = orderBomInfoMapper.selectFinishedProductBomInfoList(bomInfo); + // 保存成品BOM信息 + for (OrderBomInfo orderBomInfo : orderBomInfos) { + try { + BaseBomInfo info = new BaseBomInfo(); + info.setBomCode(orderBomInfo.getMaterialCode()); + info.setMaterialCode(orderBomInfo.getMaterialCode()); + info.setMaterialName(orderBomInfo.getMaterialName()); + info.setMaterialType("100"); + info.setStandardAmount(1L); + info.setPlantCode(info.getPlantCode()); + info.setCreatedTime(DateUtils.getNowDate()); + this.insertBaseBomInfo(info); + } catch (Exception e) { + e.printStackTrace(); + } + } + // 获取子BOM信息 + + // 保存子成品BOM信息 + + return null; + } + } diff --git a/aucma-production/src/main/java/com/aucma/production/service/impl/ProductPlanInfoServiceImpl.java b/aucma-production/src/main/java/com/aucma/production/service/impl/ProductPlanInfoServiceImpl.java index 60873c0..18fd671 100644 --- a/aucma-production/src/main/java/com/aucma/production/service/impl/ProductPlanInfoServiceImpl.java +++ b/aucma-production/src/main/java/com/aucma/production/service/impl/ProductPlanInfoServiceImpl.java @@ -128,7 +128,8 @@ public class ProductPlanInfoServiceImpl implements IProductPlanInfoService String saleOrderCode = baseOrderInfo.getSaleOrderCode(); String saleOrderLineNumber = baseOrderInfo.getSaleOrderLineNumber(); BigDecimal orderAmount = baseOrderInfo.getOrderAmount(); - if (StringUtils.isNull(orderAmount) || (orderAmount.compareTo(new BigDecimal(1))==-1)){ + int i = orderAmount.compareTo(new BigDecimal(1)); + if (orderAmount.compareTo(new BigDecimal(1)) < 0){ throw new BaseException("该工单计划数量不合法!"); } //获取生产BOM信息 diff --git a/aucma-production/src/main/resources/mapper/production/BaseBomInfoMapper.xml b/aucma-production/src/main/resources/mapper/production/BaseBomInfoMapper.xml index dca10e3..3186930 100644 --- a/aucma-production/src/main/resources/mapper/production/BaseBomInfoMapper.xml +++ b/aucma-production/src/main/resources/mapper/production/BaseBomInfoMapper.xml @@ -5,23 +5,23 @@ - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + @@ -50,94 +50,101 @@ - - SELECT seq_base_bominfo.NEXTVAL as objId FROM DUAL - + + SELECT seq_base_bominfo.NEXTVAL as objId FROM DUAL + insert into base_bominfo - obj_id, - bom_code, - material_code, - material_name, - material_type, - standard_amount, - parent_id, - plant_code, - product_line_code, - is_flag, - created_by, - created_time, - updated_by, - updated_time, - ancestors, + obj_id, + bom_code, + material_code, + material_name, + material_type, + standard_amount, + parent_id, + plant_code, + product_line_code, + is_flag, + created_by, + created_time, + updated_by, + updated_time, + ancestors, - #{objId}, - #{bomCode}, - #{materialCode}, - #{materialName}, - #{materialType}, - #{standardAmount}, - #{parentId}, - #{plantCode}, - #{productLineCode}, - #{isFlag}, - #{createdBy}, - #{createdTime}, - #{updatedBy}, - #{updatedTime}, - #{ancestors}, + #{objId}, + #{bomCode}, + #{materialCode}, + #{materialName}, + #{materialType}, + #{standardAmount}, + #{parentId}, + #{plantCode}, + #{productLineCode}, + #{isFlag}, + #{createdBy}, + #{createdTime}, + #{updatedBy}, + #{updatedTime}, + #{ancestors}, update base_bominfo - bom_code = #{bomCode}, - material_code = #{materialCode}, - material_name = #{materialName}, - material_type = #{materialType}, - standard_amount = #{standardAmount}, - parent_id = #{parentId}, - plant_code = #{plantCode}, - product_line_code = #{productLineCode}, - is_flag = #{isFlag}, - created_by = #{createdBy}, - created_time = #{createdTime}, - updated_by = #{updatedBy}, - updated_time = #{updatedTime}, - ancestors = #{ancestors}, + bom_code = #{bomCode}, + material_code = #{materialCode}, + material_name = #{materialName}, + material_type = #{materialType}, + standard_amount = #{standardAmount}, + parent_id = #{parentId}, + plant_code = #{plantCode}, + product_line_code = #{productLineCode}, + is_flag = #{isFlag}, + created_by = #{createdBy}, + created_time = #{createdTime}, + updated_by = #{updatedBy}, + updated_time = #{updatedTime}, + ancestors = #{ancestors}, where obj_id = #{objId} @@ -155,7 +162,9 @@ - delete from base_bominfo where obj_id = #{objId} + delete + from base_bominfo + where obj_id = #{objId} diff --git a/aucma-production/src/main/resources/mapper/production/CalendarInfoMapper.xml b/aucma-production/src/main/resources/mapper/production/CalendarInfoMapper.xml index 43a538c..4104400 100644 --- a/aucma-production/src/main/resources/mapper/production/CalendarInfoMapper.xml +++ b/aucma-production/src/main/resources/mapper/production/CalendarInfoMapper.xml @@ -77,7 +77,7 @@ #{objId}, #{sapPlanCode}, #{materialCode}, - #{materialName}, + #{materialName,jdbcType=NVARCHAR}, #{planStartDate}, #{planEndDate}, #{planAmount}, @@ -97,7 +97,7 @@ sap_plan_code = #{sapPlanCode}, material_code = #{materialCode}, - material_name = #{materialName}, + material_name = #{materialName,jdbcType=NVARCHAR}, plan_start_date = #{planStartDate}, plan_end_date = #{planEndDate}, plan_amount = #{planAmount},