diff --git a/aucma-base/src/main/java/com/aucma/base/controller/OrderBomInfoController.java b/aucma-base/src/main/java/com/aucma/base/controller/OrderBomInfoController.java index ccfa81b..9989e4b 100644 --- a/aucma-base/src/main/java/com/aucma/base/controller/OrderBomInfoController.java +++ b/aucma-base/src/main/java/com/aucma/base/controller/OrderBomInfoController.java @@ -24,7 +24,7 @@ import com.aucma.base.service.IOrderBomInfoService; import com.aucma.common.utils.poi.ExcelUtil; /** - * 订单BOMController + * 产品BOMController * * @author Yinq * @date 2023-09-28 @@ -36,7 +36,7 @@ public class OrderBomInfoController extends BaseController { private IOrderBomInfoService orderBomInfoService; /** - * 查询订单BOM列表 + * 查询产品BOM列表 */ @PreAuthorize("@ss.hasPermi('base:orderBomInfo:list')") @GetMapping("/list") @@ -47,7 +47,7 @@ public class OrderBomInfoController extends BaseController { } /** - * 查询订单BOM下拉框列表 + * 查询产品BOM下拉框列表 * @param orderBomInfo * @return */ @@ -58,19 +58,19 @@ public class OrderBomInfoController extends BaseController { } /** - * 导出订单BOM列表 + * 导出产品BOM列表 */ @PreAuthorize("@ss.hasPermi('base:orderBomInfo:export')") - @Log(title = "订单BOM", businessType = BusinessType.EXPORT) + @Log(title = "产品BOM", businessType = BusinessType.EXPORT) @PostMapping("/export") public void export(HttpServletResponse response, OrderBomInfo orderBomInfo) { List list = orderBomInfoService.selectOrderBomInfoList(orderBomInfo); ExcelUtil util = new ExcelUtil(OrderBomInfo.class); - util.exportExcel(response, list, "订单BOM数据"); + util.exportExcel(response, list, "产品BOM数据"); } /** - * 获取订单BOM详细信息 + * 获取产品BOM详细信息 */ @PreAuthorize("@ss.hasPermi('base:orderBomInfo:query')") @GetMapping(value = "/{objId}") @@ -79,10 +79,10 @@ public class OrderBomInfoController extends BaseController { } /** - * 新增订单BOM + * 新增产品BOM */ @PreAuthorize("@ss.hasPermi('base:orderBomInfo:add')") - @Log(title = "订单BOM", businessType = BusinessType.INSERT) + @Log(title = "产品BOM", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@RequestBody OrderBomInfo orderBomInfo) { orderBomInfo.setCreatedBy(getUsername()); @@ -90,22 +90,21 @@ public class OrderBomInfoController extends BaseController { } /** - * 修改订单BOM + * 修改产品BOM */ @PreAuthorize("@ss.hasPermi('base:orderBomInfo:edit')") - @Log(title = "订单BOM", businessType = BusinessType.UPDATE) + @Log(title = "产品BOM", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@RequestBody OrderBomInfo orderBomInfo) { orderBomInfo.setUpdatedBy(getUsername()); - orderBomInfo.setUpdatedTime(DateUtils.getNowDate()); return toAjax(orderBomInfoService.updateOrderBomInfo(orderBomInfo)); } /** - * 删除订单BOM + * 删除产品BOM */ @PreAuthorize("@ss.hasPermi('base:orderBomInfo:remove')") - @Log(title = "订单BOM", businessType = BusinessType.DELETE) + @Log(title = "产品BOM", businessType = BusinessType.DELETE) @DeleteMapping("/{objIds}") public AjaxResult remove(@PathVariable Long[] objIds) { return toAjax(orderBomInfoService.deleteOrderBomInfoByObjIds(objIds)); 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 e802c85..1030003 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 @@ -5,7 +5,7 @@ import com.aucma.base.domain.OrderBomInfo; import org.apache.ibatis.annotations.Param; /** - * 订单BOMMapper接口 + * 产品BOMMapper接口 * * @author Yinq * @date 2023-09-28 @@ -13,55 +13,55 @@ import org.apache.ibatis.annotations.Param; public interface OrderBomInfoMapper { /** - * 查询订单BOM + * 查询产品BOM * - * @param objId 订单BOM主键 - * @return 订单BOM + * @param objId 产品BOM主键 + * @return 产品BOM */ public OrderBomInfo selectOrderBomInfoByObjId(Long objId); /** - * 查询订单BOM列表 + * 查询产品BOM列表 * - * @param orderBomInfo 订单BOM - * @return 订单BOM集合 + * @param orderBomInfo 产品BOM + * @return 产品BOM集合 */ public List selectOrderBomInfoList(OrderBomInfo orderBomInfo); /** - * 查询成品订单BOM列表 + * 查询成品产品BOM列表 * - * @param orderBomInfo 订单BOM - * @return 订单BOM集合 + * @param orderBomInfo 产品BOM + * @return 产品BOM集合 */ public List selectFinishedProductBomInfoList(OrderBomInfo orderBomInfo); /** - * 新增订单BOM + * 新增产品BOM * - * @param orderBomInfo 订单BOM + * @param orderBomInfo 产品BOM * @return 结果 */ public int insertOrderBomInfo(OrderBomInfo orderBomInfo); /** - * 修改订单BOM + * 修改产品BOM * - * @param orderBomInfo 订单BOM + * @param orderBomInfo 产品BOM * @return 结果 */ public int updateOrderBomInfo(OrderBomInfo orderBomInfo); /** - * 删除订单BOM + * 删除产品BOM * - * @param objId 订单BOM主键 + * @param objId 产品BOM主键 * @return 结果 */ public int deleteOrderBomInfoByObjId(Long objId); /** - * 批量删除订单BOM + * 批量删除产品BOM * * @param objIds 需要删除的数据主键集合 * @return 结果 @@ -87,10 +87,10 @@ public interface OrderBomInfoMapper /** - * 根据BOM编号查询订单BOM + * 根据BOM编号查询产品BOM * * @param materialCode 生产BOM主键 - * @return 订单BOM + * @return 产品BOM */ public OrderBomInfo selectOrderBomInfoByMaterialCode(@Param("materialCode") String materialCode); } diff --git a/aucma-base/src/main/java/com/aucma/base/service/IOrderBomInfoService.java b/aucma-base/src/main/java/com/aucma/base/service/IOrderBomInfoService.java index d2fed59..ae9555f 100644 --- a/aucma-base/src/main/java/com/aucma/base/service/IOrderBomInfoService.java +++ b/aucma-base/src/main/java/com/aucma/base/service/IOrderBomInfoService.java @@ -4,7 +4,7 @@ import java.util.List; import com.aucma.base.domain.OrderBomInfo; /** - * 订单BOMService接口 + * 产品BOMService接口 * * @author Yinq * @date 2023-09-28 @@ -12,50 +12,58 @@ import com.aucma.base.domain.OrderBomInfo; public interface IOrderBomInfoService { /** - * 查询订单BOM + * 查询产品BOM * - * @param objId 订单BOM主键 - * @return 订单BOM + * @param objId 产品BOM主键 + * @return 产品BOM */ public OrderBomInfo selectOrderBomInfoByObjId(Long objId); /** - * 查询订单BOM列表 + * 查询产品BOM列表 * - * @param orderBomInfo 订单BOM - * @return 订单BOM集合 + * @param orderBomInfo 产品BOM + * @return 产品BOM集合 */ public List selectOrderBomInfoList(OrderBomInfo orderBomInfo); /** - * 新增订单BOM + * 新增产品BOM * - * @param orderBomInfo 订单BOM + * @param orderBomInfo 产品BOM * @return 结果 */ public int insertOrderBomInfo(OrderBomInfo orderBomInfo); /** - * 修改订单BOM + * 修改产品BOM * - * @param orderBomInfo 订单BOM + * @param orderBomInfo 产品BOM * @return 结果 */ public int updateOrderBomInfo(OrderBomInfo orderBomInfo); /** - * 批量删除订单BOM + * 批量删除产品BOM * - * @param objIds 需要删除的订单BOM主键集合 + * @param objIds 需要删除的产品BOM主键集合 * @return 结果 */ public int deleteOrderBomInfoByObjIds(Long[] objIds); /** - * 删除订单BOM信息 + * 删除产品BOM信息 * - * @param objId 订单BOM主键 + * @param objId 产品BOM主键 * @return 结果 */ public int deleteOrderBomInfoByObjId(Long objId); + + /** + * 根据物料小类查询产品BOM列表 + * + * @param materialType 物料小类 + * @return 产品BOM集合 + */ + public List selectOrderBomListByMaterialType(String materialType); } 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 6fd76d7..8427542 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 @@ -12,7 +12,7 @@ import com.aucma.base.domain.OrderBomInfo; import com.aucma.base.service.IOrderBomInfoService; /** - * 订单BOMService业务层处理 + * 产品BOMService业务层处理 * * @author Yinq * @date 2023-09-28 @@ -24,10 +24,10 @@ public class OrderBomInfoServiceImpl implements IOrderBomInfoService private OrderBomInfoMapper orderBomInfoMapper; /** - * 查询订单BOM + * 查询产品BOM * - * @param objId 订单BOM主键 - * @return 订单BOM + * @param objId 产品BOM主键 + * @return 产品BOM */ @Override public OrderBomInfo selectOrderBomInfoByObjId(Long objId) @@ -36,10 +36,10 @@ public class OrderBomInfoServiceImpl implements IOrderBomInfoService } /** - * 查询订单BOM列表 + * 查询产品BOM列表 * - * @param orderBomInfo 订单BOM - * @return 订单BOM + * @param orderBomInfo 产品BOM + * @return 产品BOM */ @Override public List selectOrderBomInfoList(OrderBomInfo orderBomInfo) @@ -48,9 +48,9 @@ public class OrderBomInfoServiceImpl implements IOrderBomInfoService } /** - * 新增订单BOM + * 新增产品BOM * - * @param orderBomInfo 订单BOM + * @param orderBomInfo 产品BOM * @return 结果 */ @Override @@ -60,48 +60,49 @@ public class OrderBomInfoServiceImpl implements IOrderBomInfoService // if (StringUtils.isNotNull(bomInfo)){ // throw new BaseException("该物料编号:" + orderBomInfo.getMaterialCode() + "已存在!"); // } - if (StringUtils.isNotNull(orderBomInfo.getParentId())){ - OrderBomInfo info = orderBomInfoMapper.selectOrderBomInfoByMaterialCode(orderBomInfo.getParentId()); - if (StringUtils.isNotNull(info)){ - orderBomInfo.setAncestors(info.getAncestors() + "," + orderBomInfo.getMaterialCode()); - }else { - orderBomInfo.setAncestors(orderBomInfo.getParentId() + "," + orderBomInfo.getMaterialCode()); - } - }else { - orderBomInfo.setAncestors(orderBomInfo.getMaterialCode()); - } +// if (StringUtils.isNotNull(orderBomInfo.getParentId())){ +// OrderBomInfo info = orderBomInfoMapper.selectOrderBomInfoByMaterialCode(orderBomInfo.getParentId()); +// if (StringUtils.isNotNull(info)){ +// orderBomInfo.setAncestors(info.getAncestors() + "," + orderBomInfo.getMaterialCode()); +// }else { +// orderBomInfo.setAncestors(orderBomInfo.getParentId() + "," + orderBomInfo.getMaterialCode()); +// } +// }else { +// orderBomInfo.setAncestors(orderBomInfo.getMaterialCode()); +// } orderBomInfo.setCreatedTime(DateUtils.getNowDate()); return orderBomInfoMapper.insertOrderBomInfo(orderBomInfo); } /** - * 修改订单BOM + * 修改产品BOM * - * @param orderBom 订单BOM + * @param orderBom 产品BOM * @return 结果 */ @Override 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()); - }else { - OrderBomInfo newParentBomInfo = orderBomInfoMapper.selectOrderBomInfoByMaterialCode(parentId); - OrderBomInfo oldBomInfo = orderBomInfoMapper.selectOrderBomInfoByMaterialCode(orderBomInfo.getMaterialCode()); - if (StringUtils.isNotNull(newParentBomInfo) && StringUtils.isNotNull(oldBomInfo)) - { - String newAncestors = newParentBomInfo.getAncestors() + "," + orderBomInfo.getMaterialCode(); - String oldAncestors = oldBomInfo.getAncestors(); - orderBomInfo.setAncestors(newAncestors); - updateBomChildren(orderBomInfo.getMaterialCode(), newAncestors, oldAncestors); - } - } - orderBomInfo.setUpdatedTime(DateUtils.getNowDate()); - orderBomInfoMapper.updateOrderBomInfo(orderBomInfo); - } +// List orderBomInfos = orderBomInfoMapper.selectOrderBomInfoList(orderBom); +// for (OrderBomInfo orderBomInfo : orderBomInfos) { +// String parentId = orderBomInfo.getParentId(); +// if (StringUtils.isNull(parentId)){ +// orderBomInfo.setAncestors(orderBomInfo.getMaterialCode()); +// }else { +// OrderBomInfo newParentBomInfo = orderBomInfoMapper.selectOrderBomInfoByMaterialCode(parentId); +// OrderBomInfo oldBomInfo = orderBomInfoMapper.selectOrderBomInfoByMaterialCode(orderBomInfo.getMaterialCode()); +// if (StringUtils.isNotNull(newParentBomInfo) && StringUtils.isNotNull(oldBomInfo)) +// { +// String newAncestors = newParentBomInfo.getAncestors() + "," + orderBomInfo.getMaterialCode(); +// String oldAncestors = oldBomInfo.getAncestors(); +// orderBomInfo.setAncestors(newAncestors); +// updateBomChildren(orderBomInfo.getMaterialCode(), newAncestors, oldAncestors); +// } +// } +// orderBomInfo.setUpdatedTime(DateUtils.getNowDate()); +// orderBomInfoMapper.updateOrderBomInfo(orderBomInfo); +// } + orderBom.setUpdatedTime(DateUtils.getNowDate()); return orderBomInfoMapper.updateOrderBomInfo(orderBom); } @@ -125,9 +126,9 @@ public class OrderBomInfoServiceImpl implements IOrderBomInfoService } /** - * 批量删除订单BOM + * 批量删除产品BOM * - * @param objIds 需要删除的订单BOM主键 + * @param objIds 需要删除的产品BOM主键 * @return 结果 */ @Override @@ -137,9 +138,9 @@ public class OrderBomInfoServiceImpl implements IOrderBomInfoService } /** - * 删除订单BOM信息 + * 删除产品BOM信息 * - * @param objId 订单BOM主键 + * @param objId 产品BOM主键 * @return 结果 */ @Override @@ -147,4 +148,17 @@ public class OrderBomInfoServiceImpl implements IOrderBomInfoService { return orderBomInfoMapper.deleteOrderBomInfoByObjId(objId); } + + /** + * 根据物料小类查询产品BOM列表 + * @param materialType 物料小类 + * @return + */ + @Override + public List selectOrderBomListByMaterialType(String materialType) { + OrderBomInfo bomInfo = new OrderBomInfo(); + bomInfo.setMaterialType(materialType); + return orderBomInfoMapper.selectOrderBomInfoList(bomInfo); + } + } diff --git a/aucma-base/src/main/java/com/aucma/base/utils/MaterialConstants.java b/aucma-base/src/main/java/com/aucma/base/utils/MaterialConstants.java new file mode 100644 index 0000000..cbe7327 --- /dev/null +++ b/aucma-base/src/main/java/com/aucma/base/utils/MaterialConstants.java @@ -0,0 +1,63 @@ +package com.aucma.base.utils; + +/** + * @Author YinQ + * @create 2023-12-06 13:51 + */ +public class MaterialConstants { + + + /** + * 成品物料类型 + */ + public static final String FP_MATERIAL_TYPE = "100"; + + /** + * 发泡箱体物料类型 + */ + public static final String BOX_MATERIAL_TYPE = "200"; + + /** + * 门体物料类型 + */ + public static final String DOOR_MATERIAL_TYPE = "300"; + + /** + * 围板物料类型 + */ + public static final String COAMING_MATERIAL_TYPE = "400"; + + /** + * 内胆物料类型 + */ + public static final String LINER_MATERIAL_TYPE = "500"; + + /** + * 前板物料类型 + */ + public static final String FORMER_MATERIAL_TYPE = "600"; + + /** + * 后板物料类型 + */ + public static final String AFTER_MATERIAL_TYPE = "700"; + + + /** + * SAP物料成品 + */ + public static final String SAP_CP_MATERIAL = "FERT"; + + /** + * SAP物料半成品 + */ + public static final String SAP_BCP_MATERIAL = "HALB"; + + /** + * SAP物料原材料 + */ + public static final String SAP_YCL_MATERIAL = "ROH"; + + + +} diff --git a/aucma-production/src/main/java/com/aucma/production/controller/BaseBomInfoController.java b/aucma-production/src/main/java/com/aucma/production/controller/BaseBomInfoController.java index 2166ecf..fe50220 100644 --- a/aucma-production/src/main/java/com/aucma/production/controller/BaseBomInfoController.java +++ b/aucma-production/src/main/java/com/aucma/production/controller/BaseBomInfoController.java @@ -84,7 +84,6 @@ public class BaseBomInfoController extends BaseController { @PostMapping public AjaxResult add(@RequestBody BaseBomInfo baseBomInfo) { baseBomInfo.setCreatedBy(getUsername()); - baseBomInfo.setCreatedTime(DateUtils.getNowDate()); return toAjax(baseBomInfoService.insertBaseBomInfo(baseBomInfo)); } @@ -96,7 +95,6 @@ public class BaseBomInfoController extends BaseController { @PutMapping public AjaxResult edit(@RequestBody BaseBomInfo baseBomInfo) { baseBomInfo.setUpdatedBy(getUsername()); - baseBomInfo.setUpdatedTime(DateUtils.getNowDate()); return toAjax(baseBomInfoService.updateBaseBomInfo(baseBomInfo)); } diff --git a/aucma-production/src/main/java/com/aucma/production/domain/BaseBomInfo.java b/aucma-production/src/main/java/com/aucma/production/domain/BaseBomInfo.java index c185d34..cfdc6d9 100644 --- a/aucma-production/src/main/java/com/aucma/production/domain/BaseBomInfo.java +++ b/aucma-production/src/main/java/com/aucma/production/domain/BaseBomInfo.java @@ -1,5 +1,6 @@ package com.aucma.production.domain; +import java.math.BigDecimal; import java.util.Date; import com.aucma.common.core.domain.model.TreeStringEntity; @@ -50,7 +51,7 @@ public class BaseBomInfo extends TreeStringEntity { * 标准数量 */ @Excel(name = "标准数量") - private Long standardAmount; + private BigDecimal standardAmount; /** * 父物料编号 @@ -200,11 +201,11 @@ public class BaseBomInfo extends TreeStringEntity { return materialType; } - public void setStandardAmount(Long standardAmount) { + public void setStandardAmount(BigDecimal standardAmount) { this.standardAmount = standardAmount; } - public Long getStandardAmount() { + public BigDecimal getStandardAmount() { return standardAmount; } 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 5943840..c38be87 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 @@ -1,9 +1,13 @@ package com.aucma.production.service.impl; +import java.math.BigDecimal; import java.util.List; +import com.aucma.base.domain.BaseMaterialInfo; import com.aucma.base.domain.OrderBomInfo; -import com.aucma.base.mapper.OrderBomInfoMapper; +import com.aucma.base.mapper.BaseMaterialinfoMapper; +import com.aucma.base.service.IOrderBomInfoService; +import com.aucma.base.utils.MaterialConstants; import com.aucma.common.exception.ServiceException; import com.aucma.common.exception.base.BaseException; import com.aucma.common.utils.DateUtils; @@ -16,87 +20,96 @@ import com.aucma.production.service.IBaseBomInfoService; /** * 生产BOMService业务层处理 - * + * * @author Yinq * @date 2023-09-28 */ @Service -public class BaseBomInfoServiceImpl implements IBaseBomInfoService -{ +public class BaseBomInfoServiceImpl implements IBaseBomInfoService { @Autowired private BaseBomInfoMapper baseBomInfoMapper; @Autowired - private OrderBomInfoMapper orderBomInfoMapper; + private IOrderBomInfoService orderBomInfoService; + + @Autowired + private BaseMaterialinfoMapper materialInfoMapper; + /** * 查询生产BOM - * + * * @param objId 生产BOM主键 * @return 生产BOM */ @Override - public BaseBomInfo selectBaseBomInfoByObjId(Long objId) - { + public BaseBomInfo selectBaseBomInfoByObjId(Long objId) { return baseBomInfoMapper.selectBaseBomInfoByObjId(objId); } /** * 查询生产BOM列表 - * + * * @param baseBomInfo 生产BOM * @return 生产BOM */ @Override - public List selectBaseBomInfoList(BaseBomInfo baseBomInfo) - { - return baseBomInfoMapper.selectBaseBomInfoList(baseBomInfo); + public List selectBaseBomInfoList(BaseBomInfo baseBomInfo) { + baseBomInfo.setMaterialCode(baseBomInfo.getMaterialCode()); + baseBomInfo.setAncestors(null); + List baseBomInfos = baseBomInfoMapper.selectBaseBomInfoList(baseBomInfo); + return baseBomInfos; } +// private List recursionSelectBaseBomInfoList(List baseBomInfo) { +// return null; +// +// } + + /** * 新增生产BOM - * + * * @param baseBomInfo 生产BOM * @return 结果 */ @Override - public int insertBaseBomInfo(BaseBomInfo baseBomInfo) - { + public int insertBaseBomInfo(BaseBomInfo baseBomInfo) { List baseBomInfos = baseBomInfoMapper.selectBaseBomInfoList(baseBomInfo); - if (StringUtils.isNotNull(baseBomInfos)){ + if (baseBomInfos.size() > 0) { throw new BaseException("该物料编号:" + baseBomInfo.getMaterialCode() + "已存在!"); } - if (StringUtils.isNotNull(baseBomInfo.getParentId())){ - BaseBomInfo info = baseBomInfoMapper.selectBaseBomInfoByMaterialCode(baseBomInfo.getParentId()); - baseBomInfo.setAncestors(info.getAncestors() + "," + baseBomInfo.getMaterialCode()); - }else { - baseBomInfo.setAncestors(baseBomInfo.getMaterialCode()); - } +// if (StringUtils.isNotNull(baseBomInfo.getParentId())) { +// BaseBomInfo info = baseBomInfoMapper.selectBaseBomInfoByMaterialCode(baseBomInfo.getParentId()); +// baseBomInfo.setAncestors(info.getAncestors() + "," + baseBomInfo.getMaterialCode()); +// } else { +// baseBomInfo.setAncestors(baseBomInfo.getMaterialCode()); +// } + baseBomInfo.setCreatedTime(DateUtils.getNowDate()); return baseBomInfoMapper.insertBaseBomInfo(baseBomInfo); } /** * 修改生产BOM - * + * * @param baseBomInfo 生产BOM * @return 结果 */ @Override - public int updateBaseBomInfo(BaseBomInfo baseBomInfo) - { - String parentId = baseBomInfo.getParentId(); - if (StringUtils.isNull(parentId)){ - baseBomInfo.setAncestors(baseBomInfo.getMaterialCode()); - }else { - BaseBomInfo newParentBomInfo = baseBomInfoMapper.selectBaseBomInfoByMaterialCode(parentId); - BaseBomInfo oldBomInfo = baseBomInfoMapper.selectBaseBomInfoByMaterialCode(baseBomInfo.getMaterialCode()); - if (StringUtils.isNotNull(newParentBomInfo) && StringUtils.isNotNull(oldBomInfo)) - { - String newAncestors = newParentBomInfo.getAncestors() + "," + baseBomInfo.getMaterialCode(); - String oldAncestors = oldBomInfo.getAncestors(); - baseBomInfo.setAncestors(newAncestors); - updateBomChildren(baseBomInfo.getMaterialCode(), newAncestors, oldAncestors); - } - } + public int updateBaseBomInfo(BaseBomInfo baseBomInfo) { +// String parentId = baseBomInfo.getParentId(); +// if (StringUtils.isNull(parentId)) { +// baseBomInfo.setAncestors(baseBomInfo.getMaterialCode()); +// } else { +// BaseBomInfo newParentBomInfo = baseBomInfoMapper.selectBaseBomInfoByMaterialCode(parentId); +// BaseBomInfo oldBomInfo = baseBomInfoMapper.selectBaseBomInfoByMaterialCode(baseBomInfo.getMaterialCode()); +// if (StringUtils.isNotNull(newParentBomInfo) && StringUtils.isNotNull(oldBomInfo)) { +// String newAncestors = newParentBomInfo.getAncestors() + "," + baseBomInfo.getMaterialCode(); +// String oldAncestors = oldBomInfo.getAncestors(); +// baseBomInfo.setAncestors(newAncestors); +// updateBomChildren(baseBomInfo.getMaterialCode(), newAncestors, oldAncestors); +// } +// } + baseBomInfo.setUpdatedTime(DateUtils.getNowDate()); return baseBomInfoMapper.updateBaseBomInfo(baseBomInfo); } @@ -109,12 +122,10 @@ public class BaseBomInfoServiceImpl implements IBaseBomInfoService */ private void updateBomChildren(String materialCode, String newAncestors, String oldAncestors) { List children = baseBomInfoMapper.selectChildrenBomById(materialCode); - for (BaseBomInfo child : children) - { + for (BaseBomInfo child : children) { child.setAncestors(child.getAncestors().replaceFirst(oldAncestors, newAncestors)); } - if (children.size() > 0) - { + if (children.size() > 0) { baseBomInfoMapper.updateBomChildren(children); } @@ -122,39 +133,35 @@ public class BaseBomInfoServiceImpl implements IBaseBomInfoService /** * 批量删除生产BOM - * + * * @param objIds 需要删除的生产BOM主键 * @return 结果 */ @Override - public int deleteBaseBomInfoByObjIds(Long[] objIds) - { + public int deleteBaseBomInfoByObjIds(Long[] objIds) { return baseBomInfoMapper.deleteBaseBomInfoByObjIds(objIds); } /** * 删除生产BOM信息 - * + * * @param objId 生产BOM主键 * @return 结果 */ @Override - public int deleteBaseBomInfoByObjId(Long objId) - { + public int deleteBaseBomInfoByObjId(Long objId) { return baseBomInfoMapper.deleteBaseBomInfoByObjId(objId); } /** * 检查生产BOM是否满足下计划条件 + * * @param baseBomInfoList */ @Override public void checkBomInfo(List baseBomInfoList) { for (BaseBomInfo baseBomInfo : baseBomInfoList) { - if (baseBomInfo.getStandardAmount() < 1){ - throw new ServiceException("生产BOM:" + baseBomInfo.getMaterialName() + " 标准数量小于1!"); - } - if (StringUtils.isEmpty(baseBomInfo.getProductLineCode())){ + if (StringUtils.isEmpty(baseBomInfo.getProductLineCode())) { throw new ServiceException("生产BOM:" + baseBomInfo.getMaterialName() + " 未分配工位!"); } } @@ -162,36 +169,145 @@ 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); + // 获取成品物料 + BaseMaterialInfo materialInfo = new BaseMaterialInfo(); + materialInfo.setMaterialSubclass(MaterialConstants.FP_MATERIAL_TYPE); + List baseMaterialInfos = materialInfoMapper.selectBaseMaterialInfoList(materialInfo); + // 保存成品BOM信息 - for (OrderBomInfo orderBomInfo : orderBomInfos) { - try { + for (BaseMaterialInfo baseMaterialInfo : baseMaterialInfos) { + BaseBomInfo bomInfo = new BaseBomInfo(); + bomInfo.setMaterialCode(baseMaterialInfo.getMaterialCode()); + List baseBomInfos = baseBomInfoMapper.selectBaseBomInfoList(bomInfo); + if (StringUtils.isNull(baseBomInfos)){ 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.setBomCode(baseMaterialInfo.getMaterialCode()); + info.setMaterialCode(baseMaterialInfo.getMaterialCode()); + info.setMaterialName(baseMaterialInfo.getMaterialName()); + info.setMaterialType(MaterialConstants.FP_MATERIAL_TYPE); + info.setStandardAmount(new BigDecimal(1)); + info.setPlantCode(baseMaterialInfo.getPlantCode()); info.setCreatedTime(DateUtils.getNowDate()); - this.insertBaseBomInfo(info); - } catch (Exception e) { - e.printStackTrace(); + try { + this.insertBaseBomInfo(info); + } catch (Exception e) { + e.printStackTrace(); + } } } - // 获取子BOM信息 - // 保存子成品BOM信息 + for (BaseMaterialInfo baseMaterialInfo : baseMaterialInfos) { + OrderBomInfo cpPomInfo = new OrderBomInfo(); + cpPomInfo.setParentId(baseMaterialInfo.getMaterialCode()); + List orderBomInfos = orderBomInfoService.selectOrderBomInfoList(cpPomInfo); + if (orderBomInfos.size() == 0) { + continue; + } + //根据成品产品BOM存箱体、门体 + for (OrderBomInfo orderBomInfo : orderBomInfos) { + //箱体 + if (orderBomInfo.getMaterialType().equals(MaterialConstants.BOX_MATERIAL_TYPE)) { + this.saveBaseBomInfoByMaterialType(orderBomInfo, MaterialConstants.BOX_MATERIAL_TYPE); + } + //门体 + if (orderBomInfo.getMaterialType().equals(MaterialConstants.DOOR_MATERIAL_TYPE)) { + this.saveBaseBomInfoByMaterialType(orderBomInfo, MaterialConstants.DOOR_MATERIAL_TYPE); + } + } + } + + //获取箱体产品BOM信息 + BaseBomInfo selectBoxBomInfo = new BaseBomInfo(); + selectBoxBomInfo.setMaterialType(MaterialConstants.BOX_MATERIAL_TYPE); + List boxBaseBomInfoList = baseBomInfoMapper.selectBaseBomInfoList(selectBoxBomInfo); + for (BaseBomInfo boxBomInfo : boxBaseBomInfoList) { + OrderBomInfo selectBomInfo = new OrderBomInfo(); + selectBomInfo.setParentId(boxBomInfo.getMaterialCode()); + List bomInfoList = orderBomInfoService.selectOrderBomInfoList(selectBomInfo); + //Boolean flag = false; // 判断BOM是否含有预装箱体 + for (OrderBomInfo orderBomInfo : bomInfoList) { + //内胆 + if (orderBomInfo.getMaterialType().equals(MaterialConstants.LINER_MATERIAL_TYPE)) { + this.saveBaseBomInfoByMaterialType(orderBomInfo, MaterialConstants.LINER_MATERIAL_TYPE); + } + //围板 + if (orderBomInfo.getMaterialType().equals(MaterialConstants.COAMING_MATERIAL_TYPE)) { + this.saveBaseBomInfoByMaterialType(orderBomInfo, MaterialConstants.COAMING_MATERIAL_TYPE); + } + } + } + + //获取围板产品BOM信息 + BaseBomInfo selectWBomInfo = new BaseBomInfo(); + selectWBomInfo.setMaterialType(MaterialConstants.COAMING_MATERIAL_TYPE); + List boxBaseWBomInfoList = baseBomInfoMapper.selectBaseBomInfoList(selectWBomInfo); + for (BaseBomInfo boxBomInfo : boxBaseWBomInfoList) { + OrderBomInfo selectBomInfo = new OrderBomInfo(); + selectBomInfo.setParentId(boxBomInfo.getMaterialCode()); + List bomInfoList = orderBomInfoService.selectOrderBomInfoList(selectBomInfo); + for (OrderBomInfo orderBomInfo : bomInfoList) { + //前板 + if (orderBomInfo.getMaterialType().equals(MaterialConstants.FORMER_MATERIAL_TYPE)) { + this.saveBaseBomInfoByMaterialType(orderBomInfo, MaterialConstants.FORMER_MATERIAL_TYPE); + } + //后板 + if (orderBomInfo.getMaterialType().equals(MaterialConstants.AFTER_MATERIAL_TYPE)) { + this.saveBaseBomInfoByMaterialType(orderBomInfo, MaterialConstants.AFTER_MATERIAL_TYPE); + } + } + } return null; } + /** + * 根据物料类型存生产BOM + * + * @param orderBomInfo + * @param materialType + */ + private void saveBaseBomInfoByMaterialType(OrderBomInfo orderBomInfo, String materialType) { + List baseBomInfos = this.checkDuplicateBaseBom(orderBomInfo); + if (baseBomInfos.size() > 0) { + // 排除异常情况:生产BOM信息重复 + return; + } + // 保存BOM信息 + BaseBomInfo info = new BaseBomInfo(); + info.setBomCode(orderBomInfo.getMaterialCode()); + info.setMaterialCode(orderBomInfo.getMaterialCode()); + info.setMaterialName(orderBomInfo.getMaterialName()); + info.setMaterialType(materialType); + info.setParentId(orderBomInfo.getParentId()); + info.setStandardAmount(orderBomInfo.getStandardAmount()); + info.setPlantCode(orderBomInfo.getFactoryCode()); + try { + info.setCreatedTime(DateUtils.getNowDate()); + baseBomInfoMapper.insertBaseBomInfo(info); + } catch (Exception e) { + System.out.println("+++++根据物料类型存生产BOM异常++++:" + e); + ; + } + } + + /** + * 检测重复生产BOM + * + * @param bomInfo + * @return + */ + private List checkDuplicateBaseBom(OrderBomInfo bomInfo) { + BaseBomInfo baseBomOne = new BaseBomInfo(); + baseBomOne.setMaterialCode(bomInfo.getMaterialCode()); + baseBomOne.setParentId(bomInfo.getParentId()); + baseBomOne.setPlantCode(bomInfo.getFactoryCode()); + return baseBomInfoMapper.selectBaseBomInfoList(baseBomOne); + } + } diff --git a/aucma-production/src/main/resources/mapper/production/BaseBomInfoMapper.xml b/aucma-production/src/main/resources/mapper/production/BaseBomInfoMapper.xml index c0ec575..f544395 100644 --- a/aucma-production/src/main/resources/mapper/production/BaseBomInfoMapper.xml +++ b/aucma-production/src/main/resources/mapper/production/BaseBomInfoMapper.xml @@ -53,7 +53,7 @@ and bb.bom_code = #{bomCode} - and bb.material_code like concat(#{material_code}, '%') + and bb.material_code like concat(#{materialCode}, '%') and bb.material_name like concat(concat('%',#{materialName}), '%') and bb.material_type = #{materialType} diff --git a/aucma-production/src/main/resources/mapper/production/CalendarInfoMapper.xml b/aucma-production/src/main/resources/mapper/production/CalendarInfoMapper.xml index 4104400..71624f8 100644 --- a/aucma-production/src/main/resources/mapper/production/CalendarInfoMapper.xml +++ b/aucma-production/src/main/resources/mapper/production/CalendarInfoMapper.xml @@ -5,116 +5,142 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - select obj_id, sap_plan_code, material_code, material_name, plan_start_date, plan_end_date, plan_amount, scheduling_date, is_scheduling, scheduling_team, is_flag, created_by, created_time, updated_by, updated_time from product_calendar_info + select obj_id, + sap_plan_code, + material_code, + material_name, + plan_start_date, + plan_end_date, + plan_amount, + scheduling_date, + is_scheduling, + scheduling_team, + is_flag, + created_by, + created_time, + updated_by, + updated_time + from product_calendar_info - - SELECT seq_product_calendar_info.NEXTVAL as objId FROM DUAL - + + SELECT seq_product_calendar_info.NEXTVAL as objId FROM DUAL + insert into product_calendar_info - obj_id, - sap_plan_code, - material_code, - material_name, - plan_start_date, - plan_end_date, - plan_amount, - scheduling_date, - is_scheduling, - scheduling_team, - is_flag, - created_by, - created_time, - updated_by, - updated_time, + obj_id, + sap_plan_code, + material_code, + material_name, + plan_start_date, + plan_end_date, + plan_amount, + scheduling_date, + is_scheduling, + scheduling_team, + is_flag, + created_by, + created_time, + updated_by, + updated_time, - #{objId}, - #{sapPlanCode}, - #{materialCode}, - #{materialName,jdbcType=NVARCHAR}, - #{planStartDate}, - #{planEndDate}, - #{planAmount}, - #{schedulingDate}, - #{isScheduling}, - #{schedulingTeam}, - #{isFlag}, - #{createdBy}, - #{createdTime}, - #{updatedBy}, - #{updatedTime}, + #{objId}, + #{sapPlanCode}, + #{materialCode}, + #{materialName,jdbcType=NVARCHAR}, + #{planStartDate}, + #{planEndDate}, + #{planAmount}, + #{schedulingDate}, + #{isScheduling}, + #{schedulingTeam}, + #{isFlag}, + #{createdBy}, + #{createdTime}, + #{updatedBy}, + #{updatedTime}, update product_calendar_info - sap_plan_code = #{sapPlanCode}, - material_code = #{materialCode}, - material_name = #{materialName,jdbcType=NVARCHAR}, - plan_start_date = #{planStartDate}, - plan_end_date = #{planEndDate}, - plan_amount = #{planAmount}, - scheduling_date = #{schedulingDate}, - is_scheduling = #{isScheduling}, - scheduling_team = #{schedulingTeam}, - is_flag = #{isFlag}, - created_by = #{createdBy}, - created_time = #{createdTime}, - updated_by = #{updatedBy}, - updated_time = #{updatedTime}, + sap_plan_code = #{sapPlanCode}, + material_code = #{materialCode}, + material_name = #{materialName,jdbcType=NVARCHAR}, + plan_start_date = #{planStartDate}, + plan_end_date = #{planEndDate}, + plan_amount = #{planAmount}, + scheduling_date = #{schedulingDate}, + is_scheduling = #{isScheduling}, + scheduling_team = #{schedulingTeam}, + is_flag = #{isFlag}, + created_by = #{createdBy}, + created_time = #{createdTime}, + updated_by = #{updatedBy}, + updated_time = #{updatedTime}, where obj_id = #{objId} - delete from product_calendar_info where obj_id = #{objId} + delete + from product_calendar_info + where obj_id = #{objId}