update - 改生产BOM

master
yinq 10 months ago
parent d84cd4bf8f
commit 43c2e012b3

@ -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<OrderBomInfo> list = orderBomInfoService.selectOrderBomInfoList(orderBomInfo);
ExcelUtil<OrderBomInfo> util = new ExcelUtil<OrderBomInfo>(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));

@ -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<OrderBomInfo> selectOrderBomInfoList(OrderBomInfo orderBomInfo);
/**
* BOM
* BOM
*
* @param orderBomInfo BOM
* @return BOM
* @param orderBomInfo BOM
* @return BOM
*/
public List<OrderBomInfo> 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
/**
* BOMBOM
* BOMBOM
*
* @param materialCode BOM
* @return BOM
* @return BOM
*/
public OrderBomInfo selectOrderBomInfoByMaterialCode(@Param("materialCode") String materialCode);
}

@ -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<OrderBomInfo> 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<OrderBomInfo> selectOrderBomListByMaterialType(String materialType);
}

@ -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<OrderBomInfo> 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<OrderBomInfo> 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<OrderBomInfo> 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<OrderBomInfo> selectOrderBomListByMaterialType(String materialType) {
OrderBomInfo bomInfo = new OrderBomInfo();
bomInfo.setMaterialType(materialType);
return orderBomInfoMapper.selectOrderBomInfoList(bomInfo);
}
}

@ -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";
}

@ -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));
}

@ -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;
}

@ -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<BaseBomInfo> selectBaseBomInfoList(BaseBomInfo baseBomInfo)
{
return baseBomInfoMapper.selectBaseBomInfoList(baseBomInfo);
public List<BaseBomInfo> selectBaseBomInfoList(BaseBomInfo baseBomInfo) {
baseBomInfo.setMaterialCode(baseBomInfo.getMaterialCode());
baseBomInfo.setAncestors(null);
List<BaseBomInfo> baseBomInfos = baseBomInfoMapper.selectBaseBomInfoList(baseBomInfo);
return baseBomInfos;
}
// private List<BaseBomInfo> recursionSelectBaseBomInfoList(List<BaseBomInfo> baseBomInfo) {
// return null;
//
// }
/**
* BOM
*
*
* @param baseBomInfo BOM
* @return
*/
@Override
public int insertBaseBomInfo(BaseBomInfo baseBomInfo)
{
public int insertBaseBomInfo(BaseBomInfo baseBomInfo) {
List<BaseBomInfo> 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<BaseBomInfo> 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<BaseBomInfo> 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<BaseBomInfo> addAutomaticSynchronizationBOM(BaseBomInfo baseBomInfo) {
// 获取成品BOM
OrderBomInfo bomInfo = new OrderBomInfo();
bomInfo.setMaterialCode("90");
List<OrderBomInfo> orderBomInfos = orderBomInfoMapper.selectFinishedProductBomInfoList(bomInfo);
// 获取成品物料
BaseMaterialInfo materialInfo = new BaseMaterialInfo();
materialInfo.setMaterialSubclass(MaterialConstants.FP_MATERIAL_TYPE);
List<BaseMaterialInfo> baseMaterialInfos = materialInfoMapper.selectBaseMaterialInfoList(materialInfo);
// 保存成品BOM信息
for (OrderBomInfo orderBomInfo : orderBomInfos) {
try {
for (BaseMaterialInfo baseMaterialInfo : baseMaterialInfos) {
BaseBomInfo bomInfo = new BaseBomInfo();
bomInfo.setMaterialCode(baseMaterialInfo.getMaterialCode());
List<BaseBomInfo> 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<OrderBomInfo> 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<BaseBomInfo> boxBaseBomInfoList = baseBomInfoMapper.selectBaseBomInfoList(selectBoxBomInfo);
for (BaseBomInfo boxBomInfo : boxBaseBomInfoList) {
OrderBomInfo selectBomInfo = new OrderBomInfo();
selectBomInfo.setParentId(boxBomInfo.getMaterialCode());
List<OrderBomInfo> 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<BaseBomInfo> boxBaseWBomInfoList = baseBomInfoMapper.selectBaseBomInfoList(selectWBomInfo);
for (BaseBomInfo boxBomInfo : boxBaseWBomInfoList) {
OrderBomInfo selectBomInfo = new OrderBomInfo();
selectBomInfo.setParentId(boxBomInfo.getMaterialCode());
List<OrderBomInfo> 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<BaseBomInfo> 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<BaseBomInfo> checkDuplicateBaseBom(OrderBomInfo bomInfo) {
BaseBomInfo baseBomOne = new BaseBomInfo();
baseBomOne.setMaterialCode(bomInfo.getMaterialCode());
baseBomOne.setParentId(bomInfo.getParentId());
baseBomOne.setPlantCode(bomInfo.getFactoryCode());
return baseBomInfoMapper.selectBaseBomInfoList(baseBomOne);
}
}

@ -53,7 +53,7 @@
<include refid="selectBaseBomInfoVo"/>
<where>
<if test="bomCode != null and bomCode != ''">and bb.bom_code = #{bomCode}</if>
<if test="materialCode != null and materialCode != ''">and bb.material_code like concat(#{material_code}, '%')</if>
<if test="materialCode != null and materialCode != ''">and bb.material_code like concat(#{materialCode}, '%')</if>
<if test="materialName != null and materialName != ''">and bb.material_name like concat(concat('%',#{materialName}), '%')
</if>
<if test="materialType != null and materialType != ''">and bb.material_type = #{materialType}</if>

@ -5,116 +5,142 @@
<mapper namespace="com.aucma.production.mapper.CalendarInfoMapper">
<resultMap type="CalendarInfo" id="CalendarInfoResult">
<result property="objId" column="obj_id" />
<result property="sapPlanCode" column="sap_plan_code" />
<result property="materialCode" column="material_code" />
<result property="materialName" column="material_name" />
<result property="planStartDate" column="plan_start_date" />
<result property="planEndDate" column="plan_end_date" />
<result property="planAmount" column="plan_amount" />
<result property="schedulingDate" column="scheduling_date" />
<result property="isScheduling" column="is_scheduling" />
<result property="schedulingTeam" column="scheduling_team" />
<result property="isFlag" column="is_flag" />
<result property="createdBy" column="created_by" />
<result property="createdTime" column="created_time" />
<result property="updatedBy" column="updated_by" />
<result property="updatedTime" column="updated_time" />
<result property="objId" column="obj_id"/>
<result property="sapPlanCode" column="sap_plan_code"/>
<result property="materialCode" column="material_code"/>
<result property="materialName" column="material_name"/>
<result property="planStartDate" column="plan_start_date"/>
<result property="planEndDate" column="plan_end_date"/>
<result property="planAmount" column="plan_amount"/>
<result property="schedulingDate" column="scheduling_date"/>
<result property="isScheduling" column="is_scheduling"/>
<result property="schedulingTeam" column="scheduling_team"/>
<result property="isFlag" column="is_flag"/>
<result property="createdBy" column="created_by"/>
<result property="createdTime" column="created_time"/>
<result property="updatedBy" column="updated_by"/>
<result property="updatedTime" column="updated_time"/>
</resultMap>
<sql id="selectCalendarInfoVo">
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
</sql>
<select id="selectCalendarInfoList" parameterType="CalendarInfo" resultMap="CalendarInfoResult">
<include refid="selectCalendarInfoVo"/>
<where>
<if test="sapPlanCode != null and sapPlanCode != ''"> and sap_plan_code = #{sapPlanCode}</if>
<if test="materialCode != null and materialCode != ''"> and material_code = #{materialCode}</if>
<if test="materialName != null and materialName != ''"> and material_name like concat(concat('%', #{materialName}), '%')</if>
<if test="params.beginPlanStartDate != null and params.beginPlanStartDate != '' and params.endPlanStartDate != null and params.endPlanStartDate != ''"> and plan_start_date between to_date(#{params.beginPlanStartDate}, 'yyyy-mm-dd hh24:mi:ss') and to_date(#{params.endPlanStartDate}, 'yyyy-mm-dd hh24:mi:ss')</if>
<if test="planEndDate != null "> and plan_end_date = #{planEndDate}</if>
<if test="planAmount != null "> and plan_amount = #{planAmount}</if>
<if test="params.beginSchedulingDate != null and params.beginSchedulingDate != '' and params.endSchedulingDate != null and params.endSchedulingDate != ''"> and scheduling_date between to_date(#{params.beginSchedulingDate}, 'yyyy-mm-dd hh24:mi:ss') and to_date(#{params.endSchedulingDate}, 'yyyy-mm-dd hh24:mi:ss')</if>
<if test="isScheduling != null "> and is_scheduling = #{isScheduling}</if>
<if test="schedulingTeam != null and schedulingTeam != ''"> and scheduling_team = #{schedulingTeam}</if>
<if test="isFlag != null "> and is_flag = #{isFlag}</if>
<if test="createdBy != null and createdBy != ''"> and created_by = #{createdBy}</if>
<if test="createdTime != null "> and created_time = #{createdTime}</if>
<if test="updatedBy != null and updatedBy != ''"> and updated_by = #{updatedBy}</if>
<if test="updatedTime != null "> and updated_time = #{updatedTime}</if>
material_code like concat('90', '%')
<if test="sapPlanCode != null and sapPlanCode != ''">and sap_plan_code = #{sapPlanCode}</if>
<if test="materialCode != null and materialCode != ''">and material_code = #{materialCode}</if>
<if test="materialName != null and materialName != ''">and material_name like concat(concat('%',
#{materialName}), '%')
</if>
<if test="params.beginPlanStartDate != null and params.beginPlanStartDate != '' and params.endPlanStartDate != null and params.endPlanStartDate != ''">
and plan_start_date between to_date(#{params.beginPlanStartDate}, 'yyyy-mm-dd hh24:mi:ss') and
to_date(#{params.endPlanStartDate}, 'yyyy-mm-dd hh24:mi:ss')
</if>
<if test="planEndDate != null ">and plan_end_date = #{planEndDate}</if>
<if test="planAmount != null ">and plan_amount = #{planAmount}</if>
<if test="params.beginSchedulingDate != null and params.beginSchedulingDate != '' and params.endSchedulingDate != null and params.endSchedulingDate != ''">
and scheduling_date between to_date(#{params.beginSchedulingDate}, 'yyyy-mm-dd hh24:mi:ss') and
to_date(#{params.endSchedulingDate}, 'yyyy-mm-dd hh24:mi:ss')
</if>
<if test="isScheduling != null ">and is_scheduling = #{isScheduling}</if>
<if test="schedulingTeam != null and schedulingTeam != ''">and scheduling_team = #{schedulingTeam}</if>
<if test="isFlag != null ">and is_flag = #{isFlag}</if>
<if test="createdBy != null and createdBy != ''">and created_by = #{createdBy}</if>
<if test="createdTime != null ">and created_time = #{createdTime}</if>
<if test="updatedBy != null and updatedBy != ''">and updated_by = #{updatedBy}</if>
<if test="updatedTime != null ">and updated_time = #{updatedTime}</if>
</where>
</select>
<select id="selectCalendarInfoByObjId" parameterType="Long" resultMap="CalendarInfoResult">
<include refid="selectCalendarInfoVo"/>
where obj_id = #{objId}
<include refid="selectCalendarInfoVo"/>
where obj_id = #{objId}
</select>
<insert id="insertCalendarInfo" parameterType="CalendarInfo">
<selectKey keyProperty="objId" resultType="long" order="BEFORE">
SELECT seq_product_calendar_info.NEXTVAL as objId FROM DUAL
</selectKey>
<selectKey keyProperty="objId" resultType="long" order="BEFORE">
SELECT seq_product_calendar_info.NEXTVAL as objId FROM DUAL
</selectKey>
insert into product_calendar_info
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="objId != null">obj_id,</if>
<if test="sapPlanCode != null">sap_plan_code,</if>
<if test="materialCode != null">material_code,</if>
<if test="materialName != null">material_name,</if>
<if test="planStartDate != null">plan_start_date,</if>
<if test="planEndDate != null">plan_end_date,</if>
<if test="planAmount != null">plan_amount,</if>
<if test="schedulingDate != null">scheduling_date,</if>
<if test="isScheduling != null">is_scheduling,</if>
<if test="schedulingTeam != null">scheduling_team,</if>
<if test="isFlag != null">is_flag,</if>
<if test="createdBy != null">created_by,</if>
<if test="createdTime != null">created_time,</if>
<if test="updatedBy != null">updated_by,</if>
<if test="updatedTime != null">updated_time,</if>
<if test="objId != null">obj_id,</if>
<if test="sapPlanCode != null">sap_plan_code,</if>
<if test="materialCode != null">material_code,</if>
<if test="materialName != null">material_name,</if>
<if test="planStartDate != null">plan_start_date,</if>
<if test="planEndDate != null">plan_end_date,</if>
<if test="planAmount != null">plan_amount,</if>
<if test="schedulingDate != null">scheduling_date,</if>
<if test="isScheduling != null">is_scheduling,</if>
<if test="schedulingTeam != null">scheduling_team,</if>
<if test="isFlag != null">is_flag,</if>
<if test="createdBy != null">created_by,</if>
<if test="createdTime != null">created_time,</if>
<if test="updatedBy != null">updated_by,</if>
<if test="updatedTime != null">updated_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="objId != null">#{objId},</if>
<if test="sapPlanCode != null">#{sapPlanCode},</if>
<if test="materialCode != null">#{materialCode},</if>
<if test="materialName != null">#{materialName,jdbcType=NVARCHAR},</if>
<if test="planStartDate != null">#{planStartDate},</if>
<if test="planEndDate != null">#{planEndDate},</if>
<if test="planAmount != null">#{planAmount},</if>
<if test="schedulingDate != null">#{schedulingDate},</if>
<if test="isScheduling != null">#{isScheduling},</if>
<if test="schedulingTeam != null">#{schedulingTeam},</if>
<if test="isFlag != null">#{isFlag},</if>
<if test="createdBy != null">#{createdBy},</if>
<if test="createdTime != null">#{createdTime},</if>
<if test="updatedBy != null">#{updatedBy},</if>
<if test="updatedTime != null">#{updatedTime},</if>
<if test="objId != null">#{objId},</if>
<if test="sapPlanCode != null">#{sapPlanCode},</if>
<if test="materialCode != null">#{materialCode},</if>
<if test="materialName != null">#{materialName,jdbcType=NVARCHAR},</if>
<if test="planStartDate != null">#{planStartDate},</if>
<if test="planEndDate != null">#{planEndDate},</if>
<if test="planAmount != null">#{planAmount},</if>
<if test="schedulingDate != null">#{schedulingDate},</if>
<if test="isScheduling != null">#{isScheduling},</if>
<if test="schedulingTeam != null">#{schedulingTeam},</if>
<if test="isFlag != null">#{isFlag},</if>
<if test="createdBy != null">#{createdBy},</if>
<if test="createdTime != null">#{createdTime},</if>
<if test="updatedBy != null">#{updatedBy},</if>
<if test="updatedTime != null">#{updatedTime},</if>
</trim>
</insert>
<update id="updateCalendarInfo" parameterType="CalendarInfo">
update product_calendar_info
<trim prefix="SET" suffixOverrides=",">
<if test="sapPlanCode != null">sap_plan_code = #{sapPlanCode},</if>
<if test="materialCode != null">material_code = #{materialCode},</if>
<if test="materialName != null">material_name = #{materialName,jdbcType=NVARCHAR},</if>
<if test="planStartDate != null">plan_start_date = #{planStartDate},</if>
<if test="planEndDate != null">plan_end_date = #{planEndDate},</if>
<if test="planAmount != null">plan_amount = #{planAmount},</if>
<if test="schedulingDate != null">scheduling_date = #{schedulingDate},</if>
<if test="isScheduling != null">is_scheduling = #{isScheduling},</if>
<if test="schedulingTeam != null">scheduling_team = #{schedulingTeam},</if>
<if test="isFlag != null">is_flag = #{isFlag},</if>
<if test="createdBy != null">created_by = #{createdBy},</if>
<if test="createdTime != null">created_time = #{createdTime},</if>
<if test="updatedBy != null">updated_by = #{updatedBy},</if>
<if test="updatedTime != null">updated_time = #{updatedTime},</if>
<if test="sapPlanCode != null">sap_plan_code = #{sapPlanCode},</if>
<if test="materialCode != null">material_code = #{materialCode},</if>
<if test="materialName != null">material_name = #{materialName,jdbcType=NVARCHAR},</if>
<if test="planStartDate != null">plan_start_date = #{planStartDate},</if>
<if test="planEndDate != null">plan_end_date = #{planEndDate},</if>
<if test="planAmount != null">plan_amount = #{planAmount},</if>
<if test="schedulingDate != null">scheduling_date = #{schedulingDate},</if>
<if test="isScheduling != null">is_scheduling = #{isScheduling},</if>
<if test="schedulingTeam != null">scheduling_team = #{schedulingTeam},</if>
<if test="isFlag != null">is_flag = #{isFlag},</if>
<if test="createdBy != null">created_by = #{createdBy},</if>
<if test="createdTime != null">created_time = #{createdTime},</if>
<if test="updatedBy != null">updated_by = #{updatedBy},</if>
<if test="updatedTime != null">updated_time = #{updatedTime},</if>
</trim>
where obj_id = #{objId}
</update>
<delete id="deleteCalendarInfoByObjId" parameterType="Long">
delete from product_calendar_info where obj_id = #{objId}
delete
from product_calendar_info
where obj_id = #{objId}
</delete>
<delete id="deleteCalendarInfoByObjIds" parameterType="String">

Loading…
Cancel
Save