|
|
|
|
@ -6,6 +6,8 @@ import cn.iocoder.yudao.module.mes.controller.admin.plan.vo.PlanRespVO;
|
|
|
|
|
import cn.iocoder.yudao.module.mes.controller.admin.task.vo.TaskPlanParam;
|
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.dataobject.plan.PlanDO;
|
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.dataobject.task.TaskDO;
|
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.dataobject.task.TaskDetailDO;
|
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.mysql.plan.PlanMapper;
|
|
|
|
|
import cn.iocoder.yudao.module.mes.service.bom.BomService;
|
|
|
|
|
import cn.iocoder.yudao.module.mes.service.itemrequisition.ItemAnalysisService;
|
|
|
|
|
import cn.iocoder.yudao.module.mes.service.itemrequisition.entity.ItemRequisitionAndStock;
|
|
|
|
|
@ -38,6 +40,8 @@ public class TaskItemNeedController {
|
|
|
|
|
@Resource
|
|
|
|
|
private PlanService planService;
|
|
|
|
|
@Resource
|
|
|
|
|
private PlanMapper planMapper;
|
|
|
|
|
@Resource
|
|
|
|
|
private ErpProductService productService;
|
|
|
|
|
@Resource
|
|
|
|
|
private BomService bomService;
|
|
|
|
|
@ -130,4 +134,33 @@ public class TaskItemNeedController {
|
|
|
|
|
else return dateTimes[index];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* taskId 为明细id
|
|
|
|
|
* 对生产任务单明细进行计划,以每个计划的产品数优先排产ProductsOfPlan
|
|
|
|
|
* 排出的计划数超过选定的天数,则后续计划堆积在最后一天
|
|
|
|
|
**/
|
|
|
|
|
@GetMapping("/generate-plan/byTaskDetail")
|
|
|
|
|
@Operation(summary = "对生产任务单进行计划")
|
|
|
|
|
public CommonResult<List<PlanRespVO>> generatePlanByTaskDetail(@Valid TaskPlanParam planParam) {
|
|
|
|
|
if(planParam.getPlanDate() != null){
|
|
|
|
|
//对得到的日期做一下排序,防止拿到的是乱序日期
|
|
|
|
|
Arrays.sort(planParam.getPlanDate(), Comparator.naturalOrder());
|
|
|
|
|
}
|
|
|
|
|
TaskDetailDO detailDO = taskService.getTaskDetail(planParam.getTaskId());
|
|
|
|
|
//已经计划数 planMapper.selectSumTaskDetail(detailDO.getId(),null);
|
|
|
|
|
Long number = planParam.getPlanNumber();
|
|
|
|
|
if(number==null)number = detailDO.getNumber();
|
|
|
|
|
//生成计划
|
|
|
|
|
List<PlanDO> planList = taskService.generatePlan3(detailDO.getTaskId(),detailDO.getId(),
|
|
|
|
|
detailDO.getProductId(), number, planParam.getProductsOfPlan());
|
|
|
|
|
//计划排日期
|
|
|
|
|
int dateCount = 0;
|
|
|
|
|
for (int i = 0; i < planList.size(); i++) {
|
|
|
|
|
planList.get(i).setPlanEndTime(getNextDate(dateCount, planParam.getPlanDate()));
|
|
|
|
|
planList.get(i).setPlanStartTime(getNextDate(dateCount, planParam.getPlanDate()));
|
|
|
|
|
dateCount++;
|
|
|
|
|
}
|
|
|
|
|
return success(planService.buildVOList(planList));
|
|
|
|
|
}
|
|
|
|
|
}
|