物料BOM添加itemOrProduct字段

This commit is contained in:
JinLu.Yin 2022-05-09 21:46:54 +08:00
parent 70faef6f1d
commit 39f67f504e
6 changed files with 49 additions and 72 deletions

View File

@ -1,26 +1,33 @@
package com.ktg.mes.md.controller; package com.ktg.mes.md.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.ktg.mes.md.service.IMdProductBomService; import com.ktg.mes.md.service.IMdProductBomService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ktg.common.annotation.Log; import com.ktg.common.annotation.Log;
import com.ktg.common.constant.UserConstants;
import com.ktg.common.core.controller.BaseController; import com.ktg.common.core.controller.BaseController;
import com.ktg.common.core.domain.AjaxResult; import com.ktg.common.core.domain.AjaxResult;
import com.ktg.common.core.page.TableDataInfo;
import com.ktg.common.enums.BusinessType; import com.ktg.common.enums.BusinessType;
import com.ktg.common.utils.poi.ExcelUtil;
import com.ktg.mes.md.domain.MdProductBom; import com.ktg.mes.md.domain.MdProductBom;
import org.springframework.beans.factory.annotation.Autowired; import com.ktg.mes.md.service.IMdProductBomService;
import org.springframework.security.access.prepost.PreAuthorize; import com.ktg.common.utils.poi.ExcelUtil;
import org.springframework.web.bind.annotation.*; import com.ktg.common.core.page.TableDataInfo;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/** /**
* 产品BOM关系Controller * 产品BOM关系Controller
* *
* @author yinjinlu * @author yinjinlu
* @date 2022-05-05 * @date 2022-05-09
*/ */
@RestController @RestController
@RequestMapping("/mes/md/bom") @RequestMapping("/mes/md/bom")
@ -72,9 +79,6 @@ public class MdProductBomController extends BaseController
@PostMapping @PostMapping
public AjaxResult add(@RequestBody MdProductBom mdProductBom) public AjaxResult add(@RequestBody MdProductBom mdProductBom)
{ {
if(UserConstants.NOT_UNIQUE.equals(mdProductBomService.checkBomExist(mdProductBom))){
return AjaxResult.error("物料"+mdProductBom.getBomItemCode()+"已存在!");
}
return toAjax(mdProductBomService.insertMdProductBom(mdProductBom)); return toAjax(mdProductBomService.insertMdProductBom(mdProductBom));
} }

View File

@ -1,17 +1,16 @@
package com.ktg.mes.md.domain; package com.ktg.mes.md.domain;
import com.ktg.common.annotation.Excel; import java.math.BigDecimal;
import com.ktg.common.core.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.commons.lang3.builder.ToStringStyle;
import com.ktg.common.annotation.Excel;
import java.math.BigDecimal; import com.ktg.common.core.domain.BaseEntity;
/** /**
* 产品BOM关系对象 md_product_bom * 产品BOM关系对象 md_product_bom
* *
* @author yinjinlu * @author yinjinlu
* @date 2022-05-05 * @date 2022-05-09
*/ */
public class MdProductBom extends BaseEntity public class MdProductBom extends BaseEntity
{ {
@ -40,12 +39,14 @@ public class MdProductBom extends BaseEntity
@Excel(name = "BOM物料规格") @Excel(name = "BOM物料规格")
private String bomItemSpec; private String bomItemSpec;
/** BOM物料单位 */ /** BOM物料单位 */
@Excel(name = "BOM物料单位") @Excel(name = "BOM物料单位")
private String unitOfMeasure; private String unitOfMeasure;
/** 产品物料标识 */
@Excel(name = "产品物料标识")
private String itemOrProduct;
/** 物料使用比例 */ /** 物料使用比例 */
@Excel(name = "物料使用比例") @Excel(name = "物料使用比例")
private BigDecimal quantity; private BigDecimal quantity;
@ -55,19 +56,15 @@ public class MdProductBom extends BaseEntity
private String enableFlag; private String enableFlag;
/** 预留字段1 */ /** 预留字段1 */
@Excel(name = "预留字段1")
private String attr1; private String attr1;
/** 预留字段2 */ /** 预留字段2 */
@Excel(name = "预留字段2")
private String attr2; private String attr2;
/** 预留字段3 */ /** 预留字段3 */
@Excel(name = "预留字段3")
private Long attr3; private Long attr3;
/** 预留字段4 */ /** 预留字段4 */
@Excel(name = "预留字段4")
private Long attr4; private Long attr4;
public void setBomId(Long bomId) public void setBomId(Long bomId)
@ -133,6 +130,15 @@ public class MdProductBom extends BaseEntity
{ {
return unitOfMeasure; return unitOfMeasure;
} }
public void setItemOrProduct(String itemOrProduct)
{
this.itemOrProduct = itemOrProduct;
}
public String getItemOrProduct()
{
return itemOrProduct;
}
public void setQuantity(BigDecimal quantity) public void setQuantity(BigDecimal quantity)
{ {
this.quantity = quantity; this.quantity = quantity;
@ -198,6 +204,7 @@ public class MdProductBom extends BaseEntity
.append("bomItemName", getBomItemName()) .append("bomItemName", getBomItemName())
.append("bomItemSpec", getBomItemSpec()) .append("bomItemSpec", getBomItemSpec())
.append("unitOfMeasure", getUnitOfMeasure()) .append("unitOfMeasure", getUnitOfMeasure())
.append("itemOrProduct", getItemOrProduct())
.append("quantity", getQuantity()) .append("quantity", getQuantity())
.append("enableFlag", getEnableFlag()) .append("enableFlag", getEnableFlag())
.append("remark", getRemark()) .append("remark", getRemark())

View File

@ -1,14 +1,13 @@
package com.ktg.mes.md.mapper; package com.ktg.mes.md.mapper;
import com.ktg.mes.md.domain.MdProductBom;
import java.util.List; import java.util.List;
import com.ktg.mes.md.domain.MdProductBom;
/** /**
* 产品BOM关系Mapper接口 * 产品BOM关系Mapper接口
* *
* @author yinjinlu * @author yinjinlu
* @date 2022-05-05 * @date 2022-05-09
*/ */
public interface MdProductBomMapper public interface MdProductBomMapper
{ {
@ -28,14 +27,6 @@ public interface MdProductBomMapper
*/ */
public List<MdProductBom> selectMdProductBomList(MdProductBom mdProductBom); public List<MdProductBom> selectMdProductBomList(MdProductBom mdProductBom);
/**
* 检查物料BOM是否已经存在
* @param mdProductBom
* @return
*/
public MdProductBom checkBomExist(MdProductBom mdProductBom);
/** /**
* 新增产品BOM关系 * 新增产品BOM关系
* *

View File

@ -1,14 +1,13 @@
package com.ktg.mes.md.service; package com.ktg.mes.md.service;
import com.ktg.mes.md.domain.MdProductBom;
import java.util.List; import java.util.List;
import com.ktg.mes.md.domain.MdProductBom;
/** /**
* 产品BOM关系Service接口 * 产品BOM关系Service接口
* *
* @author yinjinlu * @author yinjinlu
* @date 2022-05-05 * @date 2022-05-09
*/ */
public interface IMdProductBomService public interface IMdProductBomService
{ {
@ -28,13 +27,6 @@ public interface IMdProductBomService
*/ */
public List<MdProductBom> selectMdProductBomList(MdProductBom mdProductBom); public List<MdProductBom> selectMdProductBomList(MdProductBom mdProductBom);
/**
* 检查物料BOM是否已经存在
* @param mdProductBom
* @return
*/
public String checkBomExist(MdProductBom mdProductBom);
/** /**
* 新增产品BOM关系 * 新增产品BOM关系
* *

View File

@ -1,24 +1,21 @@
package com.ktg.mes.md.service.impl; package com.ktg.mes.md.service.impl;
import java.util.List; import java.util.List;
import com.ktg.mes.md.service.IMdProductBomService;
import com.ktg.common.constant.UserConstants;
import com.ktg.common.utils.DateUtils; import com.ktg.common.utils.DateUtils;
import com.ktg.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.ktg.mes.md.mapper.MdProductBomMapper; import com.ktg.mes.md.mapper.MdProductBomMapper;
import com.ktg.mes.md.domain.MdProductBom; import com.ktg.mes.md.domain.MdProductBom;
import com.ktg.mes.md.service.IMdProductBomService;
/** /**
* 产品BOM关系Service业务层处理 * 产品BOM关系Service业务层处理
* *
* @author yinjinlu * @author yinjinlu
* @date 2022-05-05 * @date 2022-05-09
*/ */
@Service @Service
public class MdProductBomServiceImpl implements IMdProductBomService public class MdProductBomServiceImpl implements IMdProductBomService
{ {
@Autowired @Autowired
private MdProductBomMapper mdProductBomMapper; private MdProductBomMapper mdProductBomMapper;
@ -47,16 +44,6 @@ public class MdProductBomServiceImpl implements IMdProductBomService
return mdProductBomMapper.selectMdProductBomList(mdProductBom); return mdProductBomMapper.selectMdProductBomList(mdProductBom);
} }
@Override
public String checkBomExist(MdProductBom mdProductBom) {
MdProductBom bom = mdProductBomMapper.checkBomExist(mdProductBom);
Long bomId = mdProductBom.getBomId()==null?-1L:mdProductBom.getBomId();
if(StringUtils.isNotNull(bom) && bom.getBomId().longValue() != bomId.longValue()){
return UserConstants.NOT_UNIQUE;
}
return UserConstants.UNIQUE;
}
/** /**
* 新增产品BOM关系 * 新增产品BOM关系
* *

View File

@ -12,6 +12,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="bomItemName" column="bom_item_name" /> <result property="bomItemName" column="bom_item_name" />
<result property="bomItemSpec" column="bom_item_spec" /> <result property="bomItemSpec" column="bom_item_spec" />
<result property="unitOfMeasure" column="unit_of_measure" /> <result property="unitOfMeasure" column="unit_of_measure" />
<result property="itemOrProduct" column="item_or_product" />
<result property="quantity" column="quantity" /> <result property="quantity" column="quantity" />
<result property="enableFlag" column="enable_flag" /> <result property="enableFlag" column="enable_flag" />
<result property="remark" column="remark" /> <result property="remark" column="remark" />
@ -26,7 +27,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap> </resultMap>
<sql id="selectMdProductBomVo"> <sql id="selectMdProductBomVo">
select bom_id, item_id, bom_item_id, bom_item_code, bom_item_name, bom_item_spec, unit_of_measure, quantity, enable_flag, remark, attr1, attr2, attr3, attr4, create_by, create_time, update_by, update_time from md_product_bom select bom_id, item_id, bom_item_id, bom_item_code, bom_item_name, bom_item_spec, unit_of_measure, item_or_product, quantity, enable_flag, remark, attr1, attr2, attr3, attr4, create_by, create_time, update_by, update_time from md_product_bom
</sql> </sql>
<select id="selectMdProductBomList" parameterType="MdProductBom" resultMap="MdProductBomResult"> <select id="selectMdProductBomList" parameterType="MdProductBom" resultMap="MdProductBomResult">
@ -38,12 +39,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="bomItemName != null and bomItemName != ''"> and bom_item_name like concat('%', #{bomItemName}, '%')</if> <if test="bomItemName != null and bomItemName != ''"> and bom_item_name like concat('%', #{bomItemName}, '%')</if>
<if test="bomItemSpec != null and bomItemSpec != ''"> and bom_item_spec = #{bomItemSpec}</if> <if test="bomItemSpec != null and bomItemSpec != ''"> and bom_item_spec = #{bomItemSpec}</if>
<if test="unitOfMeasure != null and unitOfMeasure != ''"> and unit_of_measure = #{unitOfMeasure}</if> <if test="unitOfMeasure != null and unitOfMeasure != ''"> and unit_of_measure = #{unitOfMeasure}</if>
<if test="itemOrProduct != null and itemOrProduct != ''"> and item_or_product = #{itemOrProduct}</if>
<if test="quantity != null "> and quantity = #{quantity}</if> <if test="quantity != null "> and quantity = #{quantity}</if>
<if test="enableFlag != null and enableFlag != ''"> and enable_flag = #{enableFlag}</if> <if test="enableFlag != null and enableFlag != ''"> and enable_flag = #{enableFlag}</if>
<if test="attr1 != null and attr1 != ''"> and attr1 = #{attr1}</if>
<if test="attr2 != null and attr2 != ''"> and attr2 = #{attr2}</if>
<if test="attr3 != null "> and attr3 = #{attr3}</if>
<if test="attr4 != null "> and attr4 = #{attr4}</if>
</where> </where>
</select> </select>
@ -51,12 +49,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectMdProductBomVo"/> <include refid="selectMdProductBomVo"/>
where bom_id = #{bomId} where bom_id = #{bomId}
</select> </select>
<select id="checkBomExist" parameterType="MdProductBom" resultMap="MdProductBomResult">
<include refid="selectMdProductBomVo"/>
where item_id = #{itemId} and bom_item_id = #{bomItemId} limit 1
</select>
<insert id="insertMdProductBom" parameterType="MdProductBom" useGeneratedKeys="true" keyProperty="bomId"> <insert id="insertMdProductBom" parameterType="MdProductBom" useGeneratedKeys="true" keyProperty="bomId">
insert into md_product_bom insert into md_product_bom
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
@ -66,6 +59,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="bomItemName != null and bomItemName != ''">bom_item_name,</if> <if test="bomItemName != null and bomItemName != ''">bom_item_name,</if>
<if test="bomItemSpec != null">bom_item_spec,</if> <if test="bomItemSpec != null">bom_item_spec,</if>
<if test="unitOfMeasure != null and unitOfMeasure != ''">unit_of_measure,</if> <if test="unitOfMeasure != null and unitOfMeasure != ''">unit_of_measure,</if>
<if test="itemOrProduct != null and itemOrProduct != ''">item_or_product,</if>
<if test="quantity != null">quantity,</if> <if test="quantity != null">quantity,</if>
<if test="enableFlag != null and enableFlag != ''">enable_flag,</if> <if test="enableFlag != null and enableFlag != ''">enable_flag,</if>
<if test="remark != null">remark,</if> <if test="remark != null">remark,</if>
@ -85,6 +79,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="bomItemName != null and bomItemName != ''">#{bomItemName},</if> <if test="bomItemName != null and bomItemName != ''">#{bomItemName},</if>
<if test="bomItemSpec != null">#{bomItemSpec},</if> <if test="bomItemSpec != null">#{bomItemSpec},</if>
<if test="unitOfMeasure != null and unitOfMeasure != ''">#{unitOfMeasure},</if> <if test="unitOfMeasure != null and unitOfMeasure != ''">#{unitOfMeasure},</if>
<if test="itemOrProduct != null and itemOrProduct != ''">#{itemOrProduct},</if>
<if test="quantity != null">#{quantity},</if> <if test="quantity != null">#{quantity},</if>
<if test="enableFlag != null and enableFlag != ''">#{enableFlag},</if> <if test="enableFlag != null and enableFlag != ''">#{enableFlag},</if>
<if test="remark != null">#{remark},</if> <if test="remark != null">#{remark},</if>
@ -108,6 +103,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="bomItemName != null and bomItemName != ''">bom_item_name = #{bomItemName},</if> <if test="bomItemName != null and bomItemName != ''">bom_item_name = #{bomItemName},</if>
<if test="bomItemSpec != null">bom_item_spec = #{bomItemSpec},</if> <if test="bomItemSpec != null">bom_item_spec = #{bomItemSpec},</if>
<if test="unitOfMeasure != null and unitOfMeasure != ''">unit_of_measure = #{unitOfMeasure},</if> <if test="unitOfMeasure != null and unitOfMeasure != ''">unit_of_measure = #{unitOfMeasure},</if>
<if test="itemOrProduct != null and itemOrProduct != ''">item_or_product = #{itemOrProduct},</if>
<if test="quantity != null">quantity = #{quantity},</if> <if test="quantity != null">quantity = #{quantity},</if>
<if test="enableFlag != null and enableFlag != ''">enable_flag = #{enableFlag},</if> <if test="enableFlag != null and enableFlag != ''">enable_flag = #{enableFlag},</if>
<if test="remark != null">remark = #{remark},</if> <if test="remark != null">remark = #{remark},</if>