change - 订单BOM父子页面

master
yinq 1 year ago
parent 4bdd6471fb
commit 11ad425098

@ -110,6 +110,21 @@ public class OrderBomInfo extends TreeStringEntity {
@Excel(name = "销售单据项目")
private String vbpos;
/**
*
*/
private String ancestors;
@Override
public String getAncestors() {
return ancestors;
}
@Override
public void setAncestors(String ancestors) {
this.ancestors = ancestors;
}
public void setObjId(Long objId) {
this.objId = objId;
}

@ -2,6 +2,7 @@ package com.aucma.base.mapper;
import java.util.List;
import com.aucma.base.domain.OrderBomInfo;
import org.apache.ibatis.annotations.Param;
/**
* BOMMapper
@ -58,4 +59,30 @@ public interface OrderBomInfoMapper
* @return
*/
public int deleteOrderBomInfoByObjIds(Long[] objIds);
/**
* IDBom
* @param materialCode
* @return
*/
List<OrderBomInfo> selectChildrenBomById(String materialCode);
/**
*
*
* @param children
* @return
*/
void updateBomChildren(@Param("depts") List<OrderBomInfo> children);
/**
* BOMBOM
*
* @param materialCode BOM
* @return BOM
*/
public OrderBomInfo selectOrderBomInfoByMaterialCode(@Param("materialCode") String materialCode);
}

@ -2,7 +2,9 @@ package com.aucma.base.service.impl;
import java.util.List;
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;
import com.aucma.base.mapper.OrderBomInfoMapper;
@ -54,6 +56,16 @@ 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() + "已存在!");
}
if (StringUtils.isNotNull(orderBomInfo.getParentId())){
OrderBomInfo info = orderBomInfoMapper.selectOrderBomInfoByMaterialCode(orderBomInfo.getParentId());
orderBomInfo.setAncestors(info.getAncestors() + "," + orderBomInfo.getMaterialCode());
}else {
orderBomInfo.setAncestors(orderBomInfo.getMaterialCode());
}
orderBomInfo.setCreatedTime(DateUtils.getNowDate());
return orderBomInfoMapper.insertOrderBomInfo(orderBomInfo);
}
@ -65,9 +77,48 @@ public class OrderBomInfoServiceImpl implements IOrderBomInfoService
* @return
*/
@Override
public int updateOrderBomInfo(OrderBomInfo orderBomInfo)
public int updateOrderBomInfo(OrderBomInfo orderBomInfoa)
{
return orderBomInfoMapper.updateOrderBomInfo(orderBomInfo);
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);
}
return orderBomInfoMapper.updateOrderBomInfo(orderBomInfoa);
}
/**
*
*
* @param materialCode ID
* @param newAncestors ID
* @param oldAncestors ID
*/
private void updateBomChildren(String materialCode, String newAncestors, String oldAncestors) {
List<OrderBomInfo> children = orderBomInfoMapper.selectChildrenBomById(materialCode);
for (OrderBomInfo child : children)
{
child.setAncestors(child.getAncestors().replaceFirst(oldAncestors, newAncestors));
}
if (children.size() > 0)
{
orderBomInfoMapper.updateBomChildren(children);
}
}
/**

@ -21,6 +21,7 @@
<result property="sort" column="sort"/>
<result property="vbeln" column="vbeln"/>
<result property="vbpos" column="vbpos"/>
<result property="ancestors" column="ancestors" />
</resultMap>
<sql id="selectOrderBomInfoVo">
@ -28,7 +29,7 @@
ob.bom_code,
ob.material_code,
bm.material_name,
ob.material_type,
bm.material_type,
ob.standard_amount,
ob.parent_id,
ob.is_flag,
@ -38,6 +39,7 @@
ob.updated_time,
ob.factory_code,
ob.sort,
ob.ancestors,
ob.vbeln,
ob.vbpos
from order_bominfo ob
@ -49,7 +51,7 @@
<where>
<if test="bomCode != null and bomCode != ''">and ob.bom_code = #{bomCode}</if>
<if test="materialCode != null and materialCode != ''">and ob.material_code = #{materialCode}</if>
<if test="materialName != null and materialName != ''">and ob.material_name like concat(concat('%',
<if test="materialName != null and materialName != ''">and bm.material_name like concat(concat('%',
#{materialName}), '%')
</if>
<if test="materialType != null and materialType != ''">and ob.material_type = #{materialType}</if>
@ -64,6 +66,7 @@
<if test="sort != null and sort != ''">and ob.sort = #{sort}</if>
<if test="vbeln != null and vbeln != ''">and ob.vbeln = #{vbeln}</if>
<if test="vbpos != null and vbpos != ''">and ob.vbpos = #{vbpos}</if>
<if test="ancestors != null and ancestors != ''">and ob.ancestors like concat(concat('%', #{ancestors}), '%')</if>
</where>
order by ob.parent_id, ob.sort
</select>
@ -73,6 +76,11 @@
where ob.obj_id = #{objId}
</select>
<select id="selectOrderBomInfoByMaterialCode" resultMap="OrderBomInfoResult">
<include refid="selectOrderBomInfoVo"/>
where ob.material_code = #{materialCode}
</select>
<insert id="insertOrderBomInfo" parameterType="OrderBomInfo">
<selectKey keyProperty="objId" resultType="long" order="BEFORE">
SELECT seq_order_bominfo.NEXTVAL as objId FROM DUAL
@ -95,6 +103,7 @@
<if test="sort != null">sort,</if>
<if test="vbeln != null">vbeln,</if>
<if test="vbpos != null">vbpos,</if>
<if test="ancestors != null">ancestors,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="objId != null">#{objId},</if>
@ -113,6 +122,7 @@
<if test="sort != null">#{sort},</if>
<if test="vbeln != null">#{vbeln},</if>
<if test="vbpos != null">#{vbpos},</if>
<if test="ancestors != null">#{ancestors},</if>
</trim>
</insert>
@ -134,6 +144,7 @@
<if test="sort != null">sort = #{sort},</if>
<if test="vbeln != null">vbeln = #{vbeln},</if>
<if test="vbpos != null">vbpos = #{vbpos},</if>
<if test="ancestors != null">ancestors = #{ancestors},</if>
</trim>
where obj_id = #{objId}
</update>
@ -150,4 +161,21 @@
#{objId}
</foreach>
</delete>
<select id="selectChildrenBomById" parameterType="String" resultMap="OrderBomInfoResult">
select * from order_bominfo where FIND_IN_SET(#{materialCode}, ancestors) <![CDATA[ <> ]]> 0
</select>
<update id="updateBomChildren" parameterType="java.util.List">
update order_bominfo set ancestors =
<foreach collection="depts" item="item" index="index"
separator=" " open="case material_code" close="end">
when #{item.materialCode} then #{item.ancestors}
</foreach>
where material_code in
<foreach collection="depts" item="item" index="index"
separator="," open="(" close=")">
#{item.materialCode}
</foreach>
</update>
</mapper>

@ -133,7 +133,10 @@ public class ProductPlanInfoServiceImpl implements IProductPlanInfoService
BaseBomInfo bomInfo = new BaseBomInfo();
bomInfo.setParentId(baseOrderInfo.getMaterialCode());
List<BaseBomInfo> baseBomInfoList = baseBomInfoService.selectBaseBomInfoList(bomInfo);
//若一个工单可下达多计划:则需要根据工单编号和物料编号去重
if (baseBomInfoList.size() == 0){
throw new BaseException("请先维护生产BOM信息");
}
//-- 若一个工单可下达多计划:则需要根据工单编号和物料编号去重
//检查生产BOM是否满足下计划条件
baseBomInfoService.checkBomInfo(baseBomInfoList);

Loading…
Cancel
Save