| | |
| | | |
| | | /** 需求数量 */ |
| | | // @Excel(name = "需求数量") |
| | | private String requireAmount; |
| | | private BigDecimal requireAmount; |
| | | |
| | | /** 净需求量 */ |
| | | // @Excel(name = "净需求量") |
| | |
| | | |
| | | private String delFlag; |
| | | |
| | | /**工单创建时间*/ |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @Excel(name = "工单创建时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") |
| | | private Date orderCreateTime; |
| | | } |
| | |
| | | import jakarta.annotation.Resource; |
| | | import com.aps.core.domain.ApsPlateStandardRequire; |
| | | import com.aps.core.mapper.ApsPlateStandardRequireMapper; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import com.aps.core.service.IApsPlateStandardRequireService; |
| | |
| | | * @author zhl |
| | | * @date 2025-05-06 |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class ApsPlateStandardRequireServiceImpl implements IApsPlateStandardRequireService |
| | | { |
| | |
| | | /*获取钣金主单信息*/ |
| | | List<ApsPlatePlan> mainPlans = platePlanMapper.selectPlatePlanByPlantMajor(plantCode,mainOrderType); |
| | | Hashtable<String, ApsMaterialStorageManagement> usedStorage = new Hashtable<>(); |
| | | |
| | | log.info("开始生成需求:"); |
| | | for (ApsPlatePlan mainPlan : mainPlans) { |
| | | String itemNumber = mainPlan.getItemNumber(); |
| | | /*根据料号 获取BOM Header */ |
| | |
| | | List<ApsPlateStandardRequireBomStockDetail> stockDetailsList=new ArrayList<>(); |
| | | List<ApsPlateStandardRequireBomOrderDetail> orderDetailsList=new ArrayList<>(); |
| | | |
| | | |
| | | log.info("开始生成需求:工单号:"+mainPlan.getDocumentNumber()); |
| | | getBomRequires(plantCode, "0","0",itemNumber,BigDecimal.ONE, batchNum, null |
| | | , mainPlan, requiresList, 0L,stockDetailsList,orderDetailsList,usedStorage |
| | | ); |
| | |
| | | apsPlateStandardRequireMapper.batchInsert(batch); |
| | | } |
| | | } |
| | | |
| | | log.info("生成完成"); |
| | | // if(!stockDetailsList.isEmpty()){ |
| | | // int batchSize = 1000; |
| | | // stockDetailsList.forEach(x->x.setId(IdUtil.getSnowflakeNextId())); |
| | |
| | | require.setBomLineId(bomLineId); |
| | | require.setBomLineCode(itemCode); |
| | | require.setBomLineLevel(level); |
| | | require.setBomUseAmount(itemNum); |
| | | require.setOrderCreateTime(plan.getOrderCreateTime()); |
| | | require.setCreateTime(DateUtils.getNowDate()); |
| | | require.setCreateBy(SecurityUtils.getUsername()); |
| | | require.setDelFlag("0"); |
| | | require.setProductionBase(plan.getProductionBase()); |
| | | /*计算需求数量*/ |
| | | /*BOM用量 level0=1 */ |
| | | if (level == 0) { |
| | | require.setBomUseAmount(BigDecimal.ONE); |
| | | } else { |
| | | require.setBomUseAmount(itemNum.multiply(plan.getProductionQuantity())); |
| | | require.setBomUseAmount(itemNum); |
| | | } |
| | | /*计算需求数量*/ |
| | | require.setRequireAmount(itemNum.multiply(plan.getProductionQuantity())); |
| | | /*查找库存,计算净需求,保存剩余库存,保存库存扣减明细*/ |
| | | /*默认净需求为BOM用量*/ |
| | | require.setNetRequirement(require.getBomUseAmount()); |
| | | require.setNetRequirement(require.getRequireAmount()); |
| | | |
| | | /*读取库存信息的优先级-> 内存、redis、db*/ |
| | | /* ApsMaterialStorageManagement storage = usedStorage.get(itemCode); |
| | |
| | | |
| | | /*设置开始时间*/ |
| | | Date startDay = new Date(); |
| | | startDay.setTime(require.getCompleteDate().getTime() - totalRouteMillisecond); |
| | | /*开始时间 默认为 完成时间 如果净需求>0 开始时间=结束时间-工序总工时*/ |
| | | startDay.setTime(require.getCompleteDate().getTime()); |
| | | if(require.getNetRequirement().compareTo(BigDecimal.ZERO)>0){ |
| | | startDay.setTime(require.getCompleteDate().getTime() - totalRouteMillisecond); |
| | | } |
| | | |
| | | require.setStartDate(startDay); |
| | | |
| | | /*计算是否有风险*/ |
| | |
| | | matchRequireAndSubPlan(require,orderDetailsList); |
| | | } |
| | | allRequires.add(require); |
| | | log.info("已生成需求:"+plan.getDocumentNumber()+"bomHeaderCode:"+bomHeaderCode+"bomLineCode:"+itemCode+"bomLevel:"+level); |
| | | if (require.getNetRequirement().compareTo(BigDecimal.ZERO) > 0) { |
| | | /*当前Bom节点处理完成后,处理下级BOM*/ |
| | | long nextLevel=level+1; |
| | |
| | | Object routeHeaderObj = redisTemplate.opsForValue().get(key); |
| | | if (routeHeaderObj != null) { |
| | | totalRouteTime = (BigDecimal) routeHeaderObj; |
| | | ret.setRouteTime(totalRouteTime); |
| | | ret.setRouteId("0"); |
| | | ret.setRouteTime(totalRouteTime.multiply(netRequirement)); |
| | | return ret; |
| | | } else { |
| | | // 查询标准工艺路线头部信息 |
| | |
| | | ret.setRouteId(routeHeader.getRouteId()); |
| | | /*存储至Redis*/ |
| | | redisTemplate.opsForValue().set(key, standardTime); |
| | | }else { |
| | | saveRequireError(require,"标准工艺路线不存在"); |
| | | } |
| | | return ret; |
| | | } |
| | |
| | | "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.aps.core.mapper.ApsPlatePlanMapper"> |
| | | |
| | | <resultMap type="ApsPlatePlan" id="ApsPlatePlanResult"> |
| | | <resultMap type="com.aps.core.domain.ApsPlatePlan" id="ApsPlatePlanResult"> |
| | | <result property="id" column="id" /> |
| | | <result property="masterPlanner" column="master_planner" /> |
| | | <result property="weekDay" column="week_day" /> |
| | |
| | | from aps_plate_plan |
| | | </sql> |
| | | |
| | | <select id="selectApsPlatePlanList" parameterType="ApsPlatePlan" resultMap="ApsPlatePlanResult"> |
| | | <select id="selectApsPlatePlanList" parameterType="com.aps.core.domain.ApsPlatePlan" resultMap="ApsPlatePlanResult"> |
| | | <include refid="selectApsPlatePlanVo"/> |
| | | <where> |
| | | <if test="masterPlanner != null and masterPlanner != ''"> and master_planner like '%'|| #{masterPlanner}|| '%'</if> |
| | |
| | | where id = #{id} |
| | | </select> |
| | | |
| | | <insert id="insertApsPlatePlan" parameterType="ApsPlatePlan"> |
| | | <insert id="insertApsPlatePlan" parameterType="com.aps.core.domain.ApsPlatePlan"> |
| | | insert into aps_plate_plan |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null and id != ''">id,</if> |
| | |
| | | </trim> |
| | | </insert> |
| | | |
| | | <update id="updateApsPlatePlan" parameterType="ApsPlatePlan"> |
| | | <update id="updateApsPlatePlan" parameterType="com.aps.core.domain.ApsPlatePlan"> |
| | | update aps_plate_plan |
| | | <trim prefix="SET" suffixOverrides=","> |
| | | <if test="masterPlanner != null">master_planner = #{masterPlanner},</if> |
| | |
| | | update aps_plate_plan set del_flag='1' where del_flag ='0' |
| | | </update> |
| | | |
| | | <select id="selectPlatePlanByPlantMajor" parameterType="ApsPlatePlan" resultMap="ApsPlatePlanResult"> |
| | | <select id="selectPlatePlanByPlantMajor" parameterType="com.aps.core.domain.ApsPlatePlan" resultMap="ApsPlatePlanResult"> |
| | | select id,document_number,main_part_number,item_number,plant,professional_affiliation,production_quantity,require_id, |
| | | unmatched_quantity,version, production_base,plan_end_day |
| | | unmatched_quantity,version, production_base,plan_end_day,order_create_time |
| | | from aps_plate_plan |
| | | <where> |
| | | <if test="plant != null "> and plant = #{plant}</if> |
| | | <if test="professionalAffiliation != null "> and professional_affiliation = #{professionalAffiliation}</if> |
| | | and del_flag='0' |
| | | <if test="plant != null "> and plant = #{plant} </if> |
| | | <if test="professionalAffiliation != null "> and professional_affiliation = 'main' </if> |
| | | and del_flag='0' |
| | | </where> |
| | | order by document_number asc,id asc |
| | | </select> |
| | | |
| | | <select id="selectUnMatchPlateSubPlan" parameterType="ApsPlatePlan" resultMap="ApsPlatePlanResult"> |
| | | <select id="selectUnMatchPlateSubPlan" parameterType="com.aps.core.domain.ApsPlatePlan" resultMap="ApsPlatePlanResult"> |
| | | select id,document_number,main_part_number,item_number,plant,professional_affiliation,production_quantity, |
| | | unmatched_quantity,version |
| | | from aps_plate_plan |
| | |
| | | </select> |
| | | |
| | | |
| | | <update id="updatePlanUnMatchQtyByVersion" parameterType="ApsPlatePlan"> |
| | | <update id="updatePlanUnMatchQtyByVersion" parameterType="com.aps.core.domain.ApsPlatePlan"> |
| | | update aps_plate_plan |
| | | set unmatched_quantity=#{unmatchedQuantity},version=version+1 |
| | | where id=#{id} and version=#{version} |
| | | </update> |
| | | <select id="selectPlateRedundantOrderList" parameterType="ApsPlatePlan" resultMap="ApsPlatePlanResult"> |
| | | <select id="selectPlateRedundantOrderList" parameterType="com.aps.core.domain.ApsPlatePlan" resultMap="ApsPlatePlanResult"> |
| | | select document_number, item_number, production_quantity, unmatched_quantity, plant, production_base, plan_start_day, plan_end_day, order_create_time |
| | | from aps_plate_plan where unmatched_quantity>0 and professional_affiliation!='0' and del_flag='0' |
| | | from aps_plate_plan where unmatched_quantity>0 and professional_affiliation='sub' and del_flag='0' |
| | | <if test="documentNumber != null and documentNumber != ''"> |
| | | and document_number like '%' || #{documentNumber} || '%' |
| | | </if> |
| | |
| | | "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.aps.core.mapper.ApsPlateOrderPlanManagerMapper"> |
| | | |
| | | <resultMap type="ApsPlateOrderPlanManager" id="ApsPlateOrderPlanManagerResult"> |
| | | <resultMap type="com.aps.core.domain.ApsPlateOrderPlanManager" id="ApsPlateOrderPlanManagerResult"> |
| | | <result property="id" column="id" /> |
| | | <result property="require_id" column="requireId" /> |
| | | <result property="requireId" column="require_id" /> |
| | | <result property="requireTrackId" column="require_track_id" /> |
| | | <result property="workOrderNo" column="doc_no" /> |
| | | <result property="deductionAmount" column="deduction_amount" /> |
| | |
| | | <result property="hasDelayRisk" column="has_delay_risk" /> |
| | | <result property="startDate" column="start_date" /> |
| | | <result property="completeDate" column="complete_date" /> |
| | | <!-- <result property="customTime" column="custom_time" />--> |
| | | <result property="orderCreateTime" column="order_create_time" /> |
| | | </resultMap> |
| | | |
| | | <select id="selectApsPlanOrderManager" parameterType="ApsPlateOrderPlanManager" resultMap="ApsPlateOrderPlanManagerResult"> |
| | | <select id="selectApsPlanOrderManager" parameterType="com.aps.core.domain.ApsPlateOrderPlanManager" resultMap="ApsPlateOrderPlanManagerResult"> |
| | | select |
| | | detail.require_id, |
| | | detail.require_track_id, |
| | |
| | | require.has_delay_risk, |
| | | plan.id, |
| | | require.start_date, |
| | | require.complete_date |
| | | from aps_plate_standard_require_bom_order_detail detail |
| | | left join aps_plate_standard_require require on detail.require_id = require.id |
| | | require.complete_date, |
| | | plan.order_create_time |
| | | from aps_plate_standard_require_bom_order_detail detail |
| | | left join aps_plate_standard_require require on detail.require_id =require.id |
| | | left join aps_plate_plan plan on detail.doc_no = plan.document_number |
| | | <where> |
| | | where detail.del_flag='0' |
| | | <if test="workOrderNo != null and workOrderNo != ''"> and detail.doc_no = #{workOrderNo}</if> |
| | | <if test="requireTrackId != null and requireTrackId != ''"> and detail.require_track_id = '${requireTrackId}'</if> |
| | | <if test="mainPartNumber != null and mainPartNumber != ''"> and plan.main_part_number = #{mainPartNumber}</if> |
| | | <if test="hasDelayRisk != null and hasDelayRisk != ''"> and require.has_delay_risk = #{hasDelayRisk}</if> |
| | | and where detail.del_flag='0' |
| | | </where> |
| | | <if test="requireTrackId != null and requireTrackId != ''"> and detail.require_track_id = #{requireTrackId} </if> |
| | | <if test="mainPartNumber != null and mainPartNumber != ''"> and plan.main_part_number = #{mainPartNumber} </if> |
| | | <if test="hasDelayRisk != null and hasDelayRisk != ''"> and require.has_delay_risk = #{hasDelayRisk} </if> |
| | | </select> |
| | | |
| | | |
| | | <resultMap type="ApsPlateStandardRequire" id="ApsPlateStandardRequireResult"> |
| | | <resultMap type="com.aps.core.domain.ApsPlateStandardRequire" id="ApsPlateStandardRequireResult"> |
| | | <result property="id" column="id" /> |
| | | <result property="requireTrackId" column="require_track_id" /> |
| | | <result property="bomLineId" column="bom_line_id" /> |
| | |
| | | |
| | | <select id="selectApsPlanStandardRequire" parameterType="String" resultMap="ApsPlateStandardRequireResult"> |
| | | <include refid="selectApsPlateStandardRequireVo"/> |
| | | <where> |
| | | <if test="workOrderNo != null and workOrderNo != ''"> and detail.doc_no = #{workOrderNo}</if> |
| | | and require.del_flag = '0' |
| | | </where> |
| | | where require.del_flag = '0' |
| | | <if test="workOrderNo != null and workOrderNo != ''"> and detail.doc_no = #{workOrderNo}</if> |
| | | </select> |
| | | |
| | | <resultMap type="ApsPlateOrderPlanRequireDate" id="selectPlanRequireIdsResult"> |
| | | <resultMap type="com.aps.core.domain.ApsPlateOrderPlanRequireDate" id="selectPlanRequireIdsResult"> |
| | | <result property="id" column="id" /> |
| | | <result property="start" column="start_date" /> |
| | | <result property="end" column="end_date" /> |
| | |
| | | group by plan.id |
| | | </select> |
| | | |
| | | <update id="updatePlanDateByBatch" parameterType="ApsPlateOrderPlanRequireDate"> |
| | | <update id="updatePlanDateByBatch" parameterType="com.aps.core.domain.ApsPlateOrderPlanRequireDate"> |
| | | update aps_plate_plan set |
| | | plan_start_day = #{start}, |
| | | plan_end_day = #{end}, |
| | |
| | | where id = #{id} |
| | | </update> |
| | | |
| | | <update id="updatePlanDateByCustom" parameterType="ApsPlateOrderPlanDate"> |
| | | <update id="updatePlanDateByCustom" parameterType="com.aps.core.domain.ApsPlateOrderPlanDate"> |
| | | update aps_plate_plan set |
| | | plan_end_day = #{customDate}, |
| | | update_by = #{updateBy}, |
| | |
| | | "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.aps.core.mapper.ApsPlateStandardRequireMapper"> |
| | | |
| | | <resultMap type="ApsPlateStandardRequire" id="ApsPlateStandardRequireResult"> |
| | | <resultMap type="com.aps.core.domain.ApsPlateStandardRequire" id="ApsPlateStandardRequireResult"> |
| | | <result property="id" column="id" /> |
| | | <result property="requireTrackId" column="require_track_id" /> |
| | | <result property="bomLineId" column="bom_line_id" /> |
| | |
| | | <result property="createBy" column="create_by" /> |
| | | <result property="updateBy" column="update_by" /> |
| | | <result property="updateTime" column="update_time" /> |
| | | <result property="orderCreateTime" column="order_create_time" /> |
| | | </resultMap> |
| | | |
| | | <sql id="selectApsPlateStandardRequireVo"> |
| | |
| | | process_route_id, process_route_hours, require_amount, net_requirement, start_date, |
| | | complete_date, demand_date, org_code, production_base, match_state, match_mode, |
| | | unmatched_demand_amount, suggested_completion_date, has_delay_risk, batch_number, |
| | | del_flag, create_time, create_by, update_by, update_time |
| | | del_flag, create_time, create_by, update_by, update_time,order_create_time |
| | | from aps_plate_standard_require |
| | | </sql> |
| | | |
| | | <select id="selectApsPlateStandardRequireList" parameterType="ApsPlateStandardRequire" resultMap="ApsPlateStandardRequireResult"> |
| | | <select id="selectApsPlateStandardRequireList" parameterType="com.aps.core.domain.ApsPlateStandardRequire" resultMap="ApsPlateStandardRequireResult"> |
| | | <include refid="selectApsPlateStandardRequireVo"/> |
| | | <where> |
| | | <if test="requireTrackId != null and requireTrackId != ''"> and require_track_id = #{requireTrackId}</if> |
| | |
| | | where id = #{id} |
| | | </select> |
| | | |
| | | <insert id="insertApsPlateStandardRequire" parameterType="ApsPlateStandardRequire"> |
| | | <insert id="insertApsPlateStandardRequire" parameterType="com.aps.core.domain.ApsPlateStandardRequire"> |
| | | insert into aps_plate_standard_require |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">id,</if> |
| | |
| | | </trim> |
| | | </insert> |
| | | |
| | | <update id="updateApsPlateStandardRequire" parameterType="ApsPlateStandardRequire"> |
| | | <update id="updateApsPlateStandardRequire" parameterType="com.aps.core.domain.ApsPlateStandardRequire"> |
| | | update aps_plate_standard_require |
| | | <trim prefix="SET" suffixOverrides=","> |
| | | <if test="requireTrackId != null">require_track_id = #{requireTrackId},</if> |
| | |
| | | </foreach> |
| | | </delete> |
| | | |
| | | <select id="selectPlateSupplyGapList" parameterType="ApsPlateStandardRequire" resultMap="ApsPlateStandardRequireResult"> |
| | | <select id="selectPlateSupplyGapList" parameterType="com.aps.core.domain.ApsPlateStandardRequire" resultMap="ApsPlateStandardRequireResult"> |
| | | select id, require_track_id, bom_line_code, bom_line_level, |
| | | match_state, match_mode, unmatched_demand_amount, start_date, |
| | | complete_date, demand_date, org_code, production_base |
| | |
| | | (id, require_track_id,doc_num,batch_number, org_code, bom_header_code,bom_line_id, bom_line_code, bom_line_level, bom_use_amount, process_route_id, |
| | | process_route_hours, require_amount, net_requirement, start_date, complete_date, demand_date, |
| | | production_base, match_state, match_mode, unmatched_demand_amount, suggested_completion_date, |
| | | has_delay_risk, del_flag, create_time, create_by) |
| | | has_delay_risk, del_flag, create_time, create_by,order_create_time) |
| | | values |
| | | <foreach collection="list" item="item" separator=","> |
| | | ( |
| | |
| | | #{item.hasDelayRisk}, |
| | | #{item.delFlag}, |
| | | #{item.createTime}, |
| | | #{item.createBy} |
| | | #{item.createBy}, |
| | | #{item.orderCreateTime} |
| | | ) |
| | | </foreach> |
| | | </insert> |