Merge remote-tracking branch 'origin/dev' into dev
| | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** 主键id */ |
| | | private String id; |
| | | private Long id; |
| | | |
| | | /** 主计划员 */ |
| | | @Excel(name = "主计划") |
| | |
| | | private String requireTrackId; |
| | | /**单号*/ |
| | | private String docNum; |
| | | |
| | | /**上级物料编码*/ |
| | | private String bomHeaderCode; |
| | | /** bom_line_id */ |
| | | // @Excel(name = "bom_line_id") |
| | | private String bomLineId; |
| | |
| | | /** |
| | | * 获取未匹配的子计划 |
| | | * */ |
| | | ApsPlatePlan selectUnMatchPlateSubPlan(String plant); |
| | | ApsPlatePlan selectUnMatchPlateSubPlan(String plant,String itemNumber); |
| | | |
| | | /** |
| | | * 更新子计划未匹配数量 |
| | |
| | | package com.aps.core.service.impl; |
| | | |
| | | import cn.hutool.core.util.IdUtil; |
| | | import com.aps.common.core.utils.DateUtils; |
| | | import com.aps.common.core.utils.uuid.IdUtils; |
| | | import com.aps.common.security.utils.DictUtils; |
| | |
| | | @Override |
| | | public int insertApsPlatePlan(ApsPlatePlan apsPlatePlan) |
| | | { |
| | | apsPlatePlan.setId(IdUtils.fastUUID()); |
| | | apsPlatePlan.setId(IdUtil.getSnowflakeNextId()); |
| | | apsPlatePlan.setCreateTime(DateUtils.getNowDate()); |
| | | return apsPlatePlanMapper.insertApsPlatePlan(apsPlatePlan); |
| | | } |
| | |
| | | ids[i]=apsPartPlanTemps.get(i).getId(); |
| | | ApsPlatePlan platePlan=new ApsPlatePlan(); |
| | | BeanUtils.copyProperties(apsPartPlanTemps.get(i), platePlan); |
| | | platePlan.setId(IdUtils.fastUUID()); |
| | | platePlan.setId(IdUtil.getSnowflakeNextId()); |
| | | platePlan.setCreateTime(DateUtils.getNowDate()); |
| | | //插入正式表,并记录 |
| | | apsPlatePlanMapper.insertApsPlatePlan(platePlan); |
| | |
| | | |
| | | List<ApsPlateStandardRequire> requiresList=new ArrayList<>(); |
| | | |
| | | getBomRequires(plantCode, "0",itemNumber,BigDecimal.ONE, batchNum, null, mainPlan, requiresList, 0L); |
| | | getBomRequires(plantCode, "0","0",itemNumber,BigDecimal.ONE, batchNum, null, mainPlan, requiresList, 0L); |
| | | |
| | | // 批量插入以提高性能 |
| | | if (!requiresList.isEmpty()) { |
| | |
| | | * 构建需求信息 |
| | | * |
| | | * @param plant 工厂代码 |
| | | * @param bomHeaderCode BOM上级物料编码 |
| | | * @param bomLineId BOM行ID |
| | | * @param itemCode 物料代码 |
| | | * @param itemNum 物料数量 |
| | |
| | | * @param allRequires 所有需求的列表 |
| | | * @param level 层级 |
| | | */ |
| | | private void getBomRequires(String plant, String bomLineId,String itemCode,BigDecimal itemNum, String batchNum, Date upLevelStartDate, ApsPlatePlan plan, List<ApsPlateStandardRequire> allRequires, Long level) { |
| | | private void getBomRequires(String plant, String bomHeaderCode, String bomLineId,String itemCode,BigDecimal itemNum, String batchNum, Date upLevelStartDate, ApsPlatePlan plan, List<ApsPlateStandardRequire> allRequires, Long level) { |
| | | /*构建需求信息*/ |
| | | ApsPlateStandardRequire require = new ApsPlateStandardRequire(); |
| | | require.setId(IdUtil.getSnowflakeNextId()); |
| | | require.setRequireTrackId(plan.getId()); |
| | | require.setRequireTrackId(plan.getId() + ""); |
| | | require.setBatchNumber(batchNum); |
| | | require.setDocNum(plan.getDocumentNumber()); |
| | | require.setOrgCode(plant); |
| | | require.setBomHeaderCode(bomHeaderCode); |
| | | require.setBomLineId(bomLineId); |
| | | require.setBomLineCode(itemCode); |
| | | require.setBomLineLevel(level); |
| | |
| | | bomStockDetailService.saveStorageAndDetail(storage, plan, bomLineId,itemCode, batchNum, deductionAmount, afterStockAmount,require.getId()); |
| | | } |
| | | } |
| | | /*未匹配数量,默认为净需求*/ |
| | | require.setUnmatchedDemandAmount(require.getNetRequirement()); |
| | | /*工艺路线总需求*/ |
| | | ApsStandardProcessRouteLine routeHeader = routeLineService.getRouteLineTotalTime(require); |
| | | String routeId = routeHeader.getRouteId(); |
| | |
| | | List<ApsBom> bomLineList = bomLineService.selectApsBomLineList(plant, itemCode); |
| | | if (!bomLineList.isEmpty()) { |
| | | bomLineList.forEach(line -> { |
| | | getBomRequires(plant, line.getBomLineId(),line.getItemCode() ,line.getNum() , batchNum, require.getStartDate(), plan, allRequires, nextLevel); |
| | | getBomRequires(plant, itemCode, line.getBomLineId(),line.getItemCode() ,line.getNum() , batchNum, require.getStartDate(), plan, allRequires, nextLevel); |
| | | }); |
| | | } |
| | | } |
| | |
| | | |
| | | private void matchRequireAndSubPlan(ApsPlateStandardRequire require) { |
| | | BigDecimal netRequirement = require.getNetRequirement(); |
| | | require.setMatchMode("工单匹配"); |
| | | if (netRequirement.compareTo(BigDecimal.ZERO) > 0) { |
| | | ApsPlatePlan platePlan = apsPlatePlanMapper.selectUnMatchPlateSubPlan(require.getOrgCode()); |
| | | ApsPlatePlan platePlan = apsPlatePlanMapper.selectUnMatchPlateSubPlan(require.getOrgCode(), require.getBomLineCode()); |
| | | /*子件工单的未匹配数量 作为当前的库存*/ |
| | | while (platePlan != null && netRequirement.compareTo(BigDecimal.ZERO) > 0) { |
| | | BigDecimal stock = platePlan.getUnmatchedQuantity(); |
| | | if (netRequirement.compareTo(stock) < 0) { |
| | | /* 库存数量 大于 净需求数量*/ |
| | | /* 净需求数量=0 ,子件工单未匹配数量= 库存-净需求*/ |
| | | netRequirement = BigDecimal.ZERO; |
| | | require.setNetRequirement(netRequirement); |
| | | BigDecimal subtract = stock.subtract(netRequirement); |
| | | bomOrderDetailService.savePlastPlanAndBomOrderDetail(require, platePlan, subtract, stock, netRequirement); |
| | | netRequirement = BigDecimal.ZERO; |
| | | require.setMatchState("已匹配"); |
| | | require.setUnmatchedDemandAmount(netRequirement); |
| | | /*净需求已经被满足,不需要继续匹配*/ |
| | | |
| | | } else if (netRequirement.compareTo(stock) == 0) { |
| | | /*净需求数量 == 库存数量*/ |
| | | netRequirement = BigDecimal.ZERO; |
| | | require.setNetRequirement(netRequirement); |
| | | |
| | | BigDecimal subtract = BigDecimal.ZERO; |
| | | bomOrderDetailService.savePlastPlanAndBomOrderDetail(require, platePlan, subtract, stock, netRequirement); |
| | | netRequirement = BigDecimal.ZERO; |
| | | require.setMatchState("已匹配"); |
| | | require.setUnmatchedDemandAmount(netRequirement); |
| | | /*净需求已经被满足,不需要继续匹配*/ |
| | | } |
| | | if (netRequirement.compareTo(stock) > 0) { |
| | | /*需求大于库存*/ |
| | | /*净需求 被部分满足 */ |
| | | BigDecimal rest = netRequirement.subtract(stock); |
| | | require.setNetRequirement(rest); |
| | | require.setMatchState("匹配中"); |
| | | /*工单 未匹配数量为0 全部用于匹配需求*/ |
| | | bomOrderDetailService.savePlastPlanAndBomOrderDetail(require, platePlan, BigDecimal.ZERO, stock, netRequirement); |
| | | /*净需求未被满足,需要继续匹配*/ |
| | | platePlan = apsPlatePlanMapper.selectUnMatchPlateSubPlan(require.getOrgCode()); |
| | | platePlan = apsPlatePlanMapper.selectUnMatchPlateSubPlan(require.getOrgCode(), require.getBomLineCode()); |
| | | /*剩余净需求*/ |
| | | netRequirement = rest; |
| | | require.setUnmatchedDemandAmount(netRequirement); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | <select id="selectPlatePlanByPlantMajor" parameterType="ApsPlatePlan" resultMap="ApsPlatePlanResult"> |
| | | select id,document_number,main_part_number,item_number,plant,professional_affiliation,production_quantity,require_id, |
| | | unmatched_quantity,version, production_base |
| | | unmatched_quantity,version, production_base, |
| | | (case when custom_time is null then plan_end_day else custom_time end ) as plan_end_day |
| | | from aps_plate_plan |
| | | <where> |
| | | <if test="plant != null "> and plant = #{plant}</if> |
| | | <if test="professionalAffiliation != null "> and professional_affiliation = #{professionalAffiliation}</if> |
| | |
| | | unmatched_quantity,version |
| | | from aps_plate_plan |
| | | where del_flag='0' and professional_affiliation !='0' and unmatched_quantity > 0 |
| | | <if test="plant != null and plan !='' "> and plant = #{plant}</if> |
| | | <if test="plant != null and plant !='' "> and plant = #{plant}</if> |
| | | <if test="itemNumber != null and itemNumber !='' "> and item_number = #{itemNumber}</if> |
| | | order by document_number asc,id asc |
| | | limit 1 |
| | | </select> |
| | |
| | | |
| | | <update id="updatePlanDateByBatch" parameterType="ApsPlateOrderPlanRequireDate"> |
| | | update aps_plate_plan set |
| | | plan_start_day = #{planRequireDate.start}, |
| | | plan_end_day = #{planRequireDate.end}, |
| | | update_by = #{planRequireDate.updateBy}, |
| | | plan_start_day = #{start}, |
| | | plan_end_day = #{end}, |
| | | update_by = #{updateBy}, |
| | | update_time = now() |
| | | where id = #{planRequireDate.id} |
| | | where id = #{id} |
| | | </update> |
| | | |
| | | <update id="updatePlanDateByCustom" parameterType="ApsPlateOrderPlanDate"> |
| | |
| | | |
| | | <insert id="batchInsert" parameterType="java.util.List"> |
| | | insert into aps_plate_standard_require |
| | | (id, require_track_id,doc_num,batch_number, org_code, bom_line_id, bom_line_code, bom_line_level, bom_use_amount, process_route_id, |
| | | (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) |
| | |
| | | #{item.docNum}, |
| | | #{item.batchNumber}, |
| | | #{item.orgCode}, |
| | | #{item.bomHeaderCode}, |
| | | #{item.bomLineId}, |
| | | #{item.bomLineCode}, |
| | | #{item.bomLineLevel}, |