Merge branch 'dev' of http://192.168.50.149:8085/r/aps-backend into dev
| | |
| | | import com.aps.common.log.enums.BusinessType; |
| | | import com.aps.common.security.annotation.RequiresPermissions; |
| | | import com.aps.core.domain.ApsStandardProcessRouteLine; |
| | | import com.aps.core.mapper.ApsStandardProcessRouteLineMapper; |
| | | import com.aps.core.service.IApsStandardProcessRouteLineService; |
| | | import jakarta.annotation.Resource; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | @Autowired |
| | | private IApsStandardProcessRouteLineService apsStandardProcessRouteLineService; |
| | | |
| | | @Resource |
| | | private ApsStandardProcessRouteLineMapper mapper; |
| | | /** |
| | | * 查询标准工艺路线Line列表 |
| | | */ |
| | |
| | | { |
| | | return toAjax(apsStandardProcessRouteLineService.deleteApsStandardProcessRouteLineByIds(ids)); |
| | | } |
| | | |
| | | |
| | | |
| | | @PostMapping("/getStandardTime") |
| | | public AjaxResult getStandardTime(@RequestBody ApsStandardProcessRouteLine apsStandardProcessRouteLine) |
| | | { |
| | | BigDecimal standardTime = mapper.selectTotalStandTime(apsStandardProcessRouteLine.getRouteId()).getStandardTime(); |
| | | return toAjax(standardTime.intValue()); |
| | | } |
| | | } |
| | |
| | | |
| | | import com.aps.common.core.annotation.Excel; |
| | | import com.aps.common.core.web.domain.BaseEntity; |
| | | import lombok.Builder; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | |
| | | private Long delFlag; |
| | | |
| | | private BigDecimal routeTime; |
| | | |
| | | /** 工序编码 */ |
| | | @Excel(name = "工序编码") |
| | | @Schema(description = "工序编码") |
| | | private String routeCode; |
| | | |
| | | /** 标准工时 */ |
| | | @Excel(name = "标准工时") |
| | | @Schema(description = "标准工时") |
| | | private BigDecimal standardTime; |
| | | } |
| | |
| | | * @return 结果 |
| | | */ |
| | | public int deleteApsStandardProcessRouteLineByIds(Long[] ids); |
| | | |
| | | ApsStandardProcessRouteLine selectTotalStandTime(String routeHeaderId); |
| | | } |
| | |
| | | import com.aps.core.mapper.ApsPlateStandardRequireBomOrderDetailMapper; |
| | | import com.aps.core.domain.ApsPlateStandardRequireBomOrderDetail; |
| | | import com.aps.core.service.IApsPlateStandardRequireBomOrderDetailService; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | /** |
| | | * ApsPlateStandardRequireBomOrderDetailService业务层处理 |
| | |
| | | { |
| | | return apsPlateStandardRequireBomOrderDetailMapper.deleteApsPlateStandardRequireBomOrderDetailById(id); |
| | | } |
| | | |
| | | @Transactional |
| | | @Override |
| | | public void savePlastPlanAndBomOrderDetail(ApsPlateStandardRequire require, ApsPlatePlan platePlan, BigDecimal subtract, BigDecimal stock, BigDecimal netRequirement) { |
| | | platePlan.setUnmatchedQuantity(subtract); |
| | |
| | | import org.springframework.stereotype.Service; |
| | | import com.aps.core.mapper.ApsPlateStandardRequireBomStockDetailMapper; |
| | | import com.aps.core.service.IApsPlateStandardRequireBomStockDetailService; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | /** |
| | | * ApsPlateStandardRequireBomStockDetailService业务层处理 |
| | |
| | | /** |
| | | * 计算物料剩余库存 并保存物料剩余库存明细。 |
| | | * */ |
| | | @Transactional |
| | | @Override |
| | | public void saveStorageAndDetail(ApsMaterialStorageManagement itemStorage, ApsPlatePlan plan, String bomLineId,String itemCode, String batchNum, BigDecimal deductionAmount, BigDecimal afterStockAmount,Long requireId){ |
| | | /*更新物料剩余库存*/ |
| | |
| | | /*定义工厂为南通 */ |
| | | String plantCode="FORTUNA"; |
| | | /*定义主单类型为钣金主单*/ |
| | | String mainOrderType = "0"; |
| | | String mainOrderType = "main"; |
| | | /*生成新批次号*/ |
| | | String batchNum= requireBatchService.getNewBatchNumber(); |
| | | /*获取钣金主单信息*/ |
| | |
| | | /*计算需求数量*/ |
| | | if (level == 0) { |
| | | require.setBomUseAmount(BigDecimal.ONE); |
| | | require.setCompleteDate(plan.getPlanEndDay()); |
| | | require.setDemandDate(plan.getPlanEndDay()); |
| | | } else { |
| | | require.setBomUseAmount(itemNum.multiply(plan.getProductionQuantity())); |
| | | } |
| | |
| | | require.setProcessRouteId(routeId); |
| | | require.setProcessRouteHours(String.valueOf(totalRouteTime)); |
| | | |
| | | /*完成时间,level=0 时默认为工单的计划完成日期*/ |
| | | Date completeDate = plan.getPlanEndDay(); |
| | | |
| | | /*预留天数*/ |
| | | Long reservedDay = getReservedDays(); |
| | | if (level > 0) { |
| | | /*设置完成日期*/ |
| | | if(level==0){ |
| | | /*完成时间,level=0 时默认为工单的计划完成日期*/ |
| | | require.setCompleteDate(plan.getPlanEndDay()); |
| | | require.setDemandDate(plan.getPlanEndDay()); |
| | | } else { |
| | | /* 当前需求完成日期为上阶层需求的开始时间 - 预留天数(转换为毫秒)*/ |
| | | long reservedMillisecond = reservedDay * 24 * millisecond; |
| | | Date completeDate = new Date(); |
| | | completeDate.setTime(upLevelStartDate.getTime() - reservedMillisecond); |
| | | } |
| | | /*设置完成日期*/ |
| | | require.setCompleteDate(completeDate); |
| | | require.setDemandDate(completeDate); |
| | | } |
| | | |
| | | |
| | | /*设置开始时间*/ |
| | | Date startDay = new Date(); |
| | | startDay.setTime(completeDate.getTime() - totalRouteMillisecond); |
| | | startDay.setTime(require.getCompleteDate().getTime() - totalRouteMillisecond); |
| | | require.setStartDate(startDay); |
| | | |
| | | /*计算是否有风险*/ |
| | |
| | | * 获取钣金计划 预留天数 |
| | | * */ |
| | | private Long getReservedDays(){ |
| | | Long days=0L; |
| | | List<SysDictData> dictDataList = DictUtils.getDictCache("aps_is_suspended"); |
| | | if (dictDataList != null) { |
| | | Long.getLong(dictDataList.get(0).getDictValue()); |
| | | long days=0L; |
| | | List<SysDictData> dictDataList = DictUtils.getDictCache("plate_plan_param"); |
| | | if (dictDataList != null && !dictDataList.isEmpty()) { |
| | | days = Long.parseLong(dictDataList.get(0).getDictValue()); |
| | | } |
| | | return days; |
| | | } |
| | |
| | | bomOrderDetailService.savePlastPlanAndBomOrderDetail(require, platePlan, subtract, stock, netRequirement); |
| | | netRequirement = BigDecimal.ZERO; |
| | | require.setMatchState("已匹配"); |
| | | require.setUnmatchedDemandAmount(netRequirement); |
| | | require.setUnmatchedDemandAmount(BigDecimal.ZERO); |
| | | /*净需求已经被满足,不需要继续匹配*/ |
| | | |
| | | } else if (netRequirement.compareTo(stock) == 0) { |
| | |
| | | bomOrderDetailService.savePlastPlanAndBomOrderDetail(require, platePlan, subtract, stock, netRequirement); |
| | | netRequirement = BigDecimal.ZERO; |
| | | require.setMatchState("已匹配"); |
| | | require.setUnmatchedDemandAmount(netRequirement); |
| | | require.setUnmatchedDemandAmount(BigDecimal.ZERO); |
| | | /*净需求已经被满足,不需要继续匹配*/ |
| | | } |
| | | if (netRequirement.compareTo(stock) > 0) { |
| | |
| | | platePlan = apsPlatePlanMapper.selectUnMatchPlateSubPlan(require.getOrgCode(), require.getBomLineCode()); |
| | | /*剩余净需求*/ |
| | | netRequirement = rest; |
| | | require.setUnmatchedDemandAmount(netRequirement); |
| | | require.setUnmatchedDemandAmount(rest); |
| | | } |
| | | } |
| | | } |
| | | require.setUnmatchedDemandAmount(require.getNetRequirement()); |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | import java.util.Hashtable; |
| | | import java.util.List; |
| | | import java.util.Optional; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import cn.hutool.core.util.IdUtil; |
| | | import com.aps.common.core.utils.DateUtils; |
| | |
| | | */ |
| | | @Override |
| | | public ApsStandardProcessRouteLine getRouteLineTotalTime(ApsPlateStandardRequire require) { |
| | | // 定义独占生产模式常量 |
| | | String productivityModel_monopolize = "独占"; |
| | | // 初始化总工时为0 |
| | | BigDecimal totalRouteTime = BigDecimal.ZERO; |
| | | //工厂 |
| | |
| | | ApsStandardProcessRouteLine ret=new ApsStandardProcessRouteLine(); |
| | | ret.setRouteId(String.valueOf(routId)); |
| | | ret.setRouteTime(BigDecimal.ZERO); |
| | | |
| | | // 查询标准工艺路线头部信息 |
| | | Optional<ApsStandardProcessRouteHeader> firstProcessRoute = standardProcessRouteHeaderMapper.queryStandardProcessRouteHeaderByPlantAndItemCode(plant, itemNumber).stream().findFirst(); |
| | | if (firstProcessRoute.isPresent()) { |
| | |
| | | // 构建工艺路线行参数对象 |
| | | ApsStandardProcessRouteLine routeLineParam =new ApsStandardProcessRouteLine(); |
| | | routeLineParam.setRouteId(routeHeader.getRouteId()); |
| | | |
| | | // 查询标准工艺路线行信息 |
| | | List<ApsStandardProcessRouteLine> apsStandardProcessRouteLines = apsStandardProcessRouteLineMapper.selectApsStandardProcessRouteLineList(routeLineParam); |
| | | /*工艺路线Line 总工时*/ |
| | | |
| | | if(apsStandardProcessRouteLines.isEmpty()){ |
| | | saveRequireError(require,"工序不存在"); |
| | | }else { |
| | | // 遍历每个工艺路线行 |
| | | apsStandardProcessRouteLines.forEach(line -> { |
| | | // 默认将设计产能设置为路线时间 |
| | | line.setRouteTime(line.getDesignCapacity()); |
| | | // 如果生产模式为独占,则路线时间为设计产能乘以净需求量 |
| | | if (line.getProductivityModel().equals(productivityModel_monopolize)) { |
| | | line.setRouteTime(line.getDesignCapacity().multiply(require.getNetRequirement())); |
| | | } |
| | | // 累加路线时间到总工时中 |
| | | totalRouteTime.add(line.getRouteTime()); |
| | | }); |
| | | } |
| | | BigDecimal standardTime = apsStandardProcessRouteLineMapper.selectTotalStandTime(routeHeader.getRouteId()).getStandardTime(); |
| | | totalRouteTime =standardTime.multiply(require.getNetRequirement()); |
| | | ret.setRouteTime(totalRouteTime); |
| | | ret.setRouteId(routeHeader.getRouteId()); |
| | | }else { |
| | |
| | | |
| | | <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, |
| | | (case when custom_time is null then plan_end_day else custom_time end ) as plan_end_day |
| | | unmatched_quantity,version, production_base,plan_end_day |
| | | from aps_plate_plan |
| | | <where> |
| | | <if test="plant != null "> and plant = #{plant}</if> |
| | |
| | | select id,document_number,main_part_number,item_number,plant,professional_affiliation,production_quantity, |
| | | unmatched_quantity,version |
| | | from aps_plate_plan |
| | | where del_flag='0' and professional_affiliation !='0' and unmatched_quantity > 0 |
| | | where del_flag='0' and professional_affiliation ='sub' and unmatched_quantity > 0 |
| | | <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 |
| | |
| | | <if test="orgCode != null and orgCode != ''"> and org_code = #{orgCode}</if> |
| | | and del_flag = '0' |
| | | </where> |
| | | ORDER BY version desc |
| | | </select> |
| | | |
| | | <select id="selectApsStandardProcessRouteHeaderById" parameterType="Long" resultMap="ApsStandardProcessRouteHeaderResult"> |
| | |
| | | <result property="createBy" column="create_by" /> |
| | | <result property="updateBy" column="update_by" /> |
| | | <result property="updateTime" column="update_time" /> |
| | | <result property="routeCode" column="route_code" /> |
| | | <result property="standardTime" column="standard_time" /> |
| | | </resultMap> |
| | | |
| | | <sql id="selectApsStandardProcessRouteLineVo"> |
| | | select id, route_id, route_num, route_name, start_date, end_date, create_time, org_code, |
| | | shop_code, productivity_model, design_capacity, del_flag, create_by, update_by, |
| | | update_time |
| | | update_time, route_code, standard_time |
| | | from aps_standard_process_route_line |
| | | </sql> |
| | | |
| | |
| | | <if test="designCapacity != null and designCapacity != ''"> and design_capacity = #{designCapacity}</if> |
| | | and del_flag = '0' |
| | | </where> |
| | | |
| | | </select> |
| | | |
| | | <select id="selectApsStandardProcessRouteLineById" parameterType="Long" resultMap="ApsStandardProcessRouteLineResult"> |
| | |
| | | #{id} |
| | | </foreach> |
| | | </delete> |
| | | |
| | | <select id="selectTotalStandTime" parameterType="String" resultMap="ApsStandardProcessRouteLineResult"> |
| | | select sum(standard_time) as standard_time |
| | | from aps_standard_process_route_line |
| | | where route_id = #{routeId} |
| | | ; |
| | | </select> |
| | | </mapper> |
| | |
| | | param.setDocState(Arrays.asList(0,1,2,4)); |
| | | param.setBeginDate(yesterdayMidnight.format(formatter)); |
| | | param.setEndDate(today.format(formatter)); |
| | | param.setPageSize(100); |
| | | param.setPageSize(500); |
| | | while (continueFlag){ |
| | | param.setPageIndex(currentPage); |
| | | continueFlag= batchSaveByPager(param); |
| | |
| | | order.setProcessStatus("0"); |
| | | order.setOpStatus(jsonObject.getString("OpStatus")); |
| | | order.setNextOpName(jsonObject.getString("NextOpName")); |
| | | order.setLowOrderCode(jsonObject.getString("LowLevelCode")); |
| | | jobs.add(order); |
| | | orderIds.add(order.getOrderId()); |
| | | } catch (Exception e) { |
| | |
| | | op_num,work_center,dept, |
| | | start_date,complete_date,next_dept, |
| | | is_hold_release,is_out_source,org_code, |
| | | order_id,now(),'0',org_code,doc_status,std_op,op_status,next_op_name, |
| | | case when low_order_code='0' then 'main' else 'sub' end as professional_affiliation, |
| | | cast(order_id as bigint) as id,now(),'0',org_code,doc_status,std_op,op_status,next_op_name, |
| | | (case when low_order_code='0' then 'main' else 'sub' end ) as professional_affiliation, |
| | | order_create_time |
| | | from aps_work_order_job |
| | | where ( doc_status in (0,1,2,4) and is_hold_release='0' |