change - 通过生产BOM生成生产计划

master
yinq 1 year ago
parent fc396bf8ae
commit 0d4f9898e4

@ -108,6 +108,12 @@ public class BaseOrderInfo extends BaseEntity {
@Excel(name = "启用标识")
private Long isFlag;
/**
* 0-1-
*/
@Excel(name = "是否已下达计划")
private Long isRelease;
/**
*
*/
@ -141,6 +147,14 @@ public class BaseOrderInfo extends BaseEntity {
@Excel(name = "完成日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date completeDate;
public Long getIsRelease() {
return isRelease;
}
public void setIsRelease(Long isRelease) {
this.isRelease = isRelease;
}
public void setObjId(Long objId) {
this.objId = objId;
}

@ -25,6 +25,7 @@
<result property="updatedBy" column="updated_by"/>
<result property="updatedTime" column="updated_time"/>
<result property="completeDate" column="complete_date"/>
<result property="isRelease" column="is_release"/>
</resultMap>
<sql id="selectBaseOrderInfoVo">
@ -43,6 +44,7 @@
end_date,
factory_code,
is_flag,
is_release,
created_by,
created_time,
updated_by,
@ -77,7 +79,9 @@
<if test="updatedBy != null and updatedBy != ''">and updated_by = #{updatedBy}</if>
<if test="updatedTime != null ">and updated_time = #{updatedTime}</if>
<if test="completeDate != null ">and complete_date = #{completeDate}</if>
<if test="isRelease != null ">and is_release = #{isRelease}</if>
</where>
order by order_code desc
</select>
<select id="selectBaseOrderInfoByObjId" parameterType="Long" resultMap="BaseOrderInfoResult">
@ -106,6 +110,7 @@
<if test="endDate != null">end_date,</if>
<if test="factoryCode != null">factory_code,</if>
<if test="isFlag != null">is_flag,</if>
<if test="isRelease != null">is_release,</if>
<if test="createdBy != null">created_by,</if>
<if test="createdTime != null">created_time,</if>
<if test="updatedBy != null">updated_by,</if>
@ -128,6 +133,7 @@
<if test="endDate != null">#{endDate},</if>
<if test="factoryCode != null">#{factoryCode},</if>
<if test="isFlag != null">#{isFlag},</if>
<if test="isRelease != null">#{isRelease},</if>
<if test="createdBy != null">#{createdBy},</if>
<if test="createdTime != null">#{createdTime},</if>
<if test="updatedBy != null">#{updatedBy},</if>
@ -153,6 +159,7 @@
<if test="endDate != null">end_date = #{endDate},</if>
<if test="factoryCode != null">factory_code = #{factoryCode},</if>
<if test="isFlag != null">is_flag = #{isFlag},</if>
<if test="isRelease != null">is_release = #{isRelease},</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>

@ -3,7 +3,7 @@ package com.aucma.production.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.aucma.common.utils.DateUtils;
import com.aucma.base.domain.BaseOrderInfo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
@ -98,4 +98,15 @@ public class ProductPlanInfoController extends BaseController {
public AjaxResult remove(@PathVariable Long[] objIds) {
return toAjax(productPlanInfoService.deleteProductPlanInfoByObjIds(objIds));
}
/**
*
* @param baseOrderInfo
* @return
*/
@PostMapping("/releaseOrderPlan")
public AjaxResult releaseOrderPlan(@RequestBody BaseOrderInfo baseOrderInfo) {
return success(productPlanInfoService.releaseOrderPlan(baseOrderInfo));
}
}

@ -59,11 +59,17 @@ public class ProductPlanInfo extends BaseEntity {
private String materialName;
/**
*
*
*/
@Excel(name = "计划工位")
@Excel(name = "计划工位编号")
private String productLineCode;
/**
*
*/
@Excel(name = "计划工位名称")
private String productLineName;
/**
*
*/
@ -122,6 +128,14 @@ public class ProductPlanInfo extends BaseEntity {
@Excel(name = "更新时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date updatedTime;
public String getProductLineName() {
return productLineName;
}
public void setProductLineName(String productLineName) {
this.productLineName = productLineName;
}
public void setObjId(Long objId) {
this.objId = objId;
}

@ -58,4 +58,11 @@ public interface IBaseBomInfoService
* @return
*/
public int deleteBaseBomInfoByObjId(Long objId);
/**
* BOM
* @param baseBomInfoList
*/
void checkBomInfo(List<BaseBomInfo> baseBomInfoList);
}

@ -1,6 +1,8 @@
package com.aucma.production.service;
import java.util.List;
import com.aucma.base.domain.BaseOrderInfo;
import com.aucma.production.domain.ProductPlanInfo;
/**
@ -60,4 +62,10 @@ public interface IProductPlanInfoService
public int deleteProductPlanInfoByObjId(Long objId);
/**
*
* @param baseOrderInfo
* @return
*/
public Boolean releaseOrderPlan(BaseOrderInfo baseOrderInfo);
}

@ -2,7 +2,6 @@ package com.aucma.production.service.impl;
import java.util.List;
import com.aucma.common.core.domain.entity.SysDept;
import com.aucma.common.exception.base.BaseException;
import com.aucma.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -138,4 +137,21 @@ public class BaseBomInfoServiceImpl implements IBaseBomInfoService
{
return baseBomInfoMapper.deleteBaseBomInfoByObjId(objId);
}
/**
* BOM
* @param baseBomInfoList
*/
@Override
public void checkBomInfo(List<BaseBomInfo> baseBomInfoList) {
for (BaseBomInfo baseBomInfo : baseBomInfoList) {
if (baseBomInfo.getStandardAmount() < 1){
throw new BaseException("生产BOM" + baseBomInfo.getMaterialName() + " 标准数量小于1");
}
if (StringUtils.isEmpty(baseBomInfo.getProductLineCode())){
throw new BaseException("生产BOM" + baseBomInfo.getMaterialName() + " 未分配工位!");
}
}
}
}

@ -2,13 +2,22 @@ package com.aucma.production.service.impl;
import java.util.List;
import com.aucma.base.domain.BaseOrderInfo;
import com.aucma.base.service.IBaseOrderInfoService;
import com.aucma.common.exception.base.BaseException;
import com.aucma.common.utils.DateUtils;
import com.aucma.common.utils.StringUtils;
import com.aucma.common.utils.uuid.PlanCodeUtils;
import com.aucma.production.domain.BaseBomInfo;
import com.aucma.production.service.IBaseBomInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.aucma.production.mapper.ProductPlanInfoMapper;
import com.aucma.production.domain.ProductPlanInfo;
import com.aucma.production.service.IProductPlanInfoService;
import static com.aucma.common.utils.SecurityUtils.getUsername;
/**
* Service
*
@ -21,6 +30,12 @@ public class ProductPlanInfoServiceImpl implements IProductPlanInfoService
@Autowired
private ProductPlanInfoMapper productPlanInfoMapper;
@Autowired
private IBaseOrderInfoService baseOrderInfoService;
@Autowired
private IBaseBomInfoService baseBomInfoService;
/**
*
*
@ -54,6 +69,9 @@ public class ProductPlanInfoServiceImpl implements IProductPlanInfoService
@Override
public int insertProductPlanInfo(ProductPlanInfo productPlanInfo)
{
if (StringUtils.isEmpty(productPlanInfo.getCreatedBy())){
productPlanInfo.setCreatedBy(getUsername());
}
productPlanInfo.setCreatedTime(DateUtils.getNowDate());
return productPlanInfoMapper.insertProductPlanInfo(productPlanInfo);
}
@ -95,6 +113,49 @@ public class ProductPlanInfoServiceImpl implements IProductPlanInfoService
return productPlanInfoMapper.deleteProductPlanInfoByObjId(objId);
}
/**
*
* @param baseOrderInfo
* @return
*/
@Override
public Boolean releaseOrderPlan(BaseOrderInfo baseOrderInfo) {
try {
String orderCode = baseOrderInfo.getOrderCode();
String saleOrderCode = baseOrderInfo.getSaleOrderCode();
String saleOrderLineNumber = baseOrderInfo.getSaleOrderLineNumber();
Long orderAmount = baseOrderInfo.getOrderAmount();
if (StringUtils.isNull(orderAmount) || orderAmount < 1L){
throw new BaseException("该工单计划数量不合法!");
}
//获取生产BOM信息
BaseBomInfo bomInfo = new BaseBomInfo();
bomInfo.setParentId(baseOrderInfo.getMaterialCode());
List<BaseBomInfo> baseBomInfoList = baseBomInfoService.selectBaseBomInfoList(bomInfo);
//检查生产BOM是否满足下计划条件
baseBomInfoService.checkBomInfo(baseBomInfoList);
//维护生产计划
for (BaseBomInfo baseBomInfo : baseBomInfoList) {
ProductPlanInfo planInfo = new ProductPlanInfo();
planInfo.setPlanCode(PlanCodeUtils.getPlanCode());
planInfo.setOrderCode(orderCode);
planInfo.setSaleOrderCode(saleOrderCode);
planInfo.setSaleorderLinenumber(saleOrderLineNumber);
planInfo.setMaterialCode(baseBomInfo.getMaterialCode());
planInfo.setMaterialName(baseBomInfo.getMaterialName());
planInfo.setProductLineCode(baseBomInfo.getProductLineCode());
planInfo.setPlanAmount(baseBomInfo.getStandardAmount() * orderAmount);
this.insertProductPlanInfo(planInfo);
}
baseOrderInfo.setIsRelease(0L);
baseOrderInfoService.updateBaseOrderInfo(baseOrderInfo);
} catch (Exception e) {
throw new BaseException(e.getMessage());
}
return true;
}
}

@ -13,6 +13,7 @@
<result property="materialCode" column="material_code"/>
<result property="materialName" column="material_name"/>
<result property="productLineCode" column="productline_code"/>
<result property="productLineName" column="productLineName"/>
<result property="planAmount" column="plan_amount"/>
<result property="completeAmount" column="complete_amount"/>
<result property="beginTime" column="begin_time"/>
@ -25,62 +26,65 @@
</resultMap>
<sql id="selectProductPlanInfoVo">
select obj_id,
plan_code,
order_code,
saleorder_code,
saleorder_linenumber,
material_code,
material_name,
productline_code,
plan_amount,
complete_amount,
begin_time,
end_time,
is_flag,
created_by,
created_time,
updated_by,
updated_time
from product_planinfo
select pp.obj_id,
pp.plan_code,
pp.order_code,
pp.saleorder_code,
pp.saleorder_linenumber,
pp.material_code,
pp.material_name,
pp.productline_code,
pl.PRODUCT_LINE_NAME productLineName,
pp.plan_amount,
pp.complete_amount,
pp.begin_time,
pp.end_time,
pp.is_flag,
pp.created_by,
pp.created_time,
pp.updated_by,
pp.updated_time
from product_planinfo pp
left join BASE_PRODUCTLINE pl on pl.PRODUCT_LINE_CODE = pp.productline_code
</sql>
<select id="selectProductPlanInfoList" parameterType="ProductPlanInfo" resultMap="ProductPlanInfoResult">
<include refid="selectProductPlanInfoVo"/>
<where>
<if test="planCode != null and planCode != ''">and plan_code like concat(concat('%', #{planCode}), '%')
<if test="planCode != null and planCode != ''">and pp.plan_code like concat(concat('%', #{planCode}), '%')
</if>
<if test="orderCode != null and orderCode != ''">and order_code = #{orderCode}</if>
<if test="saleOrderCode != null and saleOrderCode != ''">and saleorder_code = #{saleOrderCode}</if>
<if test="saleorderLinenumber != null and saleorderLinenumber != ''">and saleorder_linenumber =
<if test="orderCode != null and orderCode != ''">and pp.order_code = #{orderCode}</if>
<if test="saleOrderCode != null and saleOrderCode != ''">and pp.saleorder_code = #{saleOrderCode}</if>
<if test="saleorderLinenumber != null and saleorderLinenumber != ''">and pp.saleorder_linenumber =
#{saleorderLinenumber}
</if>
<if test="materialCode != null and materialCode != ''">and material_code = #{materialCode}</if>
<if test="materialName != null and materialName != ''">and material_name like concat(concat('%',
<if test="materialCode != null and materialCode != ''">and pp.material_code = #{materialCode}</if>
<if test="materialName != null and materialName != ''">and pp.material_name like concat(concat('%',
#{materialName}), '%')
</if>
<if test="productLineCode != null and productLineCode != ''">and productline_code = #{productLineCode}</if>
<if test="planAmount != null ">and plan_amount = #{planAmount}</if>
<if test="completeAmount != null ">and complete_amount = #{completeAmount}</if>
<if test="productLineCode != null and productLineCode != ''">and pp.productline_code = #{productLineCode}</if>
<if test="planAmount != null ">and pp.plan_amount = #{planAmount}</if>
<if test="completeAmount != null ">and pp.complete_amount = #{completeAmount}</if>
<if test="params.beginBeginTime != null and params.beginBeginTime != '' and params.endBeginTime != null and params.endBeginTime != ''">
and begin_time between to_date(#{params.beginBeginTime}, 'yyyy-mm-dd hh24:mi:ss') and
and pp.begin_time between to_date(#{params.beginBeginTime}, 'yyyy-mm-dd hh24:mi:ss') and
to_date(#{params.endBeginTime}, 'yyyy-mm-dd hh24:mi:ss')
</if>
<if test="params.beginEndTime != null and params.beginEndTime != '' and params.endEndTime != null and params.endEndTime != ''">
and end_time between to_date(#{params.beginEndTime}, 'yyyy-mm-dd hh24:mi:ss') and
and pp.end_time between to_date(#{params.beginEndTime}, 'yyyy-mm-dd hh24:mi:ss') and
to_date(#{params.endEndTime}, 'yyyy-mm-dd hh24:mi:ss')
</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>
<if test="isFlag != null ">and pp.is_flag = #{isFlag}</if>
<if test="createdBy != null and createdBy != ''">and pp.created_by = #{createdBy}</if>
<if test="createdTime != null ">and pp.created_time = #{createdTime}</if>
<if test="updatedBy != null and updatedBy != ''">and pp.updated_by = #{updatedBy}</if>
<if test="updatedTime != null ">and pp.updated_time = #{updatedTime}</if>
</where>
order by pp.plan_code desc
</select>
<select id="selectProductPlanInfoByObjId" parameterType="Long" resultMap="ProductPlanInfoResult">
<include refid="selectProductPlanInfoVo"/>
where obj_id = #{objId}
where pp.obj_id = #{objId}
</select>
<insert id="insertProductPlanInfo" parameterType="ProductPlanInfo">

Loading…
Cancel
Save