Commit 1939a180 authored by wzc's avatar wzc

去掉核心逻辑

parent 48289352
......@@ -232,7 +232,7 @@ public class ProTaskMobController extends BaseController {
@PostMapping("/feedback")
@ResponseBody
public AjaxResult<List<ProPackagePrintResult>> feedBack(ProFeedback feedback) {
return AjaxResult.success(proTaskService.feedBack(feedback));
return AjaxResult.success(null);
}
/**
......@@ -241,7 +241,7 @@ public class ProTaskMobController extends BaseController {
@Log(title = "外协报工", businessType = BusinessType.INSERT)
@RequestMapping(value = "/assistFeedback", method = RequestMethod.POST)
public AjaxResult assistFeedback(@RequestBody ProFeedback proFeedback) {
return toAjax(proTaskAssistProcessService.feedBack(proFeedback));
return toAjax(null);
}
/**
......
......@@ -314,12 +314,7 @@ public class ProTaskController extends BaseController {
@Log(title = "生产任务排产", businessType = BusinessType.OTHER)
@PostMapping("/schedule")
public AjaxResult schedule(@ApiParam(value = "工单属性集合", required = true) @RequestBody List<WorkorderScheduleParams> params) {
params.forEach(s->{
if(s.getScheduleQuantity().compareTo(BigDecimal.ZERO)<=0){
throw new ServiceException(MessageUtils.message("pro.schedule.limit.min.quantity"));
}
});
proTaskService.schedule(params);
return AjaxResult.success();
}
......
......@@ -98,7 +98,7 @@ public class ProTaskWorkunitController extends BaseController {
@Log(title = "任务工作单元", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody ProTaskWorkunit proTaskWorkunit) {
return toAjax(proTaskWorkunitService.insertProTaskWorkunit(proTaskWorkunit));
return toAjax(1);
}
/**
......@@ -145,7 +145,6 @@ public class ProTaskWorkunitController extends BaseController {
@Log(title = "转外委", businessType = BusinessType.UPDATE)
@PostMapping(value = "/toOutsource")
public AjaxResult toOutsource(@RequestBody List<TaskWorkunitToOutsourceParam> taskWorkunitToOutsourceParam) {
proTaskWorkunitService.toOutsource(taskWorkunitToOutsourceParam);
return AjaxResult.success();
}
@ApiOperation("转自制")
......
......@@ -10,14 +10,5 @@ import java.time.LocalDateTime;
@Data
public class WorkorderScheduleParams {
@ApiModelProperty("工单ID")
Long workorderId;
@ApiModelProperty("排产开始日期")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm")
LocalDateTime scheduleDate;
@ApiModelProperty("本次排产数量")
BigDecimal scheduleQuantity;
}
......@@ -103,106 +103,8 @@ public class AlgorithmDataSourceImpl implements AlgorithmDataSource {
@Override
public List<Job> getJob(LocalDateTime schedulingStartedDate, List<WorkorderScheduleParams> workorderScheduleParams, List<Resource> resources) {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
List<Job> algJobs = new ArrayList<Job>();
//查询相关工单,工单编排单号也需一并查询出来
QueryWrapper<ProWorkorder> queryWrapper = new QueryWrapper<ProWorkorder>();
queryWrapper.in("workorder_id", workorderScheduleParams.stream().map(s->s.getWorkorderId()).collect(Collectors.toList()));
List<ProWorkorder> workorderList = proWorkorderService.selectListByQw(queryWrapper);
Map<Long,WorkorderScheduleParams> workorderScheduleParamsMap= workorderScheduleParams.stream().collect(Collectors.toMap(s->s.getWorkorderId(),s->s));
List<ScheduleJobGroup> scheduleJobGroupList = new ArrayList<ScheduleJobGroup>();
for (ProWorkorder workorder : workorderList) {
ScheduleJobGroup scheduleJobGroup = new ScheduleJobGroup();
List<ProWorkorder> list = new ArrayList<>();
list.add(workorder);
scheduleJobGroup.setWorkorderList(list);
if(ObjectUtil.isEmpty(workorder.getRequestDate())){
throw new ServiceException(MessageUtils.message("pro.workOrder.error.not.null.requestDate"));
}
LocalDateTime recentDate = list.stream().map(s -> DateUtil.toLocalDateTime(s.getRequestDate())).min(Comparator.comparing(LocalDateTime::toLocalDate)).get();
scheduleJobGroup.setQuantity(workorderScheduleParamsMap.get(workorder.getWorkorderId()).getScheduleQuantity());
scheduleJobGroup.setDemandDate(recentDate);
scheduleJobGroup.setWorkorderCode(workorder.getWorkorderCode());
scheduleJobGroupList.add(scheduleJobGroup);
}
//按交期近,数量少排序
scheduleJobGroupList.sort(Comparator.comparing(ScheduleJobGroup::getDemandDate).thenComparing(ScheduleJobGroup::getQuantity));
Long i = 0l;
StringBuilder msg = new StringBuilder();
for (ScheduleJobGroup scheduleJobGroup : scheduleJobGroupList) {
ProWorkorder firstWorkorder = scheduleJobGroup.getWorkorderList().get(0);
QueryWrapper<ProWorkOrderProcess> processQuery = new QueryWrapper<ProWorkOrderProcess>();
processQuery.eq("t1.workorder_id", firstWorkorder.getWorkorderId());
processQuery.orderByAsc("t1.idx");
List<ProWorkOrderProcess> productionOrderRoutings = proWorkOrderProcessService.selectListByQw(processQuery);
//
if(productionOrderRoutings.size() < 1){
msg.append(MessageUtils.message("pro.schedule.error.not.exist.process", firstWorkorder.getWorkorderCode()));
msg.append(System.lineSeparator());
continue;
}
// 工序分组 生成Job及Task
Job job = new Job(scheduleJobGroup.getWorkorderCode(), Duration.between(schedulingStartedDate, DateUtil.date(scheduleJobGroup.getDemandDate()).toLocalDateTime())) {{
setFixed(false);
}};
JobExtent jobExtent = new JobExtent();
jobExtent.setWorkorderList(scheduleJobGroup.getWorkorderList());
job.setJobExtend(jobExtent);
job.getLmtStartedTime().addOptional(Duration.ZERO);
job.getLmtEndedTime().addOptional(Duration.between(schedulingStartedDate, DateUtil.date(scheduleJobGroup.getDemandDate()).toLocalDateTime()));
job.setQuantity(scheduleJobGroup.getQuantity());
for (ProWorkOrderProcess routingItem : productionOrderRoutings) {
Task task = new Task(i, job);
task.setStandardWorkingTime(Duration.ZERO);
task.setSetupTime(Duration.ZERO);
task.setProcessId(routingItem.getProcessId());
task.setUnitPrice(routingItem.getUnitPrice());
task.setStdWorkingTime(routingItem.getStdWorkingTime());
task.setStdWorkingTimeUom(routingItem.getStdWorkingTimeUom());
task.setIdx(routingItem.getIdx());
task.setProcessName(routingItem.getProcessName());
task.setOrderQuantity(scheduleJobGroup.getQuantity());
task.setWorkCenterId(routingItem.getWorkstationId());
task.setWorkCenterName(routingItem.getWorkstationName());
if("Y".equalsIgnoreCase(routingItem.getOutsourced())){
task.setOutsourced(true);
}
//HOUR\SECOND\MINUTE
Long unitMultiple = 0l;
if ("HOUR".equalsIgnoreCase(routingItem.getStdWorkingTimeUom())) {
unitMultiple = unitMultiple * 60;
} else if ("SECOND".equalsIgnoreCase(routingItem.getStdWorkingTimeUom())) {
unitMultiple = 1000l * 1000 * 1000;
} else if("MIN".equalsIgnoreCase(routingItem.getStdWorkingTimeUom())){
unitMultiple = 1000l * 1000 * 1000 * 60;
}else {
throw new ServiceException(MessageUtils.message("pro.schedule.error.canNot.use.standardTime", routingItem.getStdWorkingTimeUom()));
}
if (routingItem.getStdWorkingTime() != null) {
//单件标准工时
Long standardSd = routingItem.getStdWorkingTime().multiply(BigDecimal.valueOf(unitMultiple)).longValue();
if (routingItem.getQuantity() != null) {
standardSd = standardSd / routingItem.getQuantity().longValue();
}
task.setStandardWorkingTime(Duration.ofNanos(standardSd));
}
if (routingItem.getLineBreakTime() != null) {
task.setSetupTime(Duration.ofNanos(routingItem.getLineBreakTime().multiply(BigDecimal.valueOf(unitMultiple)).longValue()));
}
task.getTaskData().put("SeqNo", routingItem.getProcessRef());
job.getTasks().add(task);
i++;
}
algJobs.add(job);
}
if(msg.length() > 0){
throw new ServiceException(msg.toString());
}
stopWatch.stop();
logger.info(String.format("待排产数据加载耗时:%s", stopWatch.getTotalTimeSeconds()));
return algJobs;
return null;
}
@Override
......
......@@ -102,107 +102,8 @@ public class AlgorithmDataSourceThXMImpl implements AlgorithmDataSource {
@Override
public List<Job> getJob(LocalDateTime scheduleStartedDate, List<WorkorderScheduleParams> workorderScheduleParams, List<Resource> resources) {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
List<Job> algJobs = new ArrayList<Job>();
//查询相关工单,工单编排单号也需一并查询出来
QueryWrapper<ProWorkorder> queryWrapper = new QueryWrapper<ProWorkorder>();
queryWrapper.in("workorder_id", workorderScheduleParams.stream().map(s->s.getWorkorderId()).collect(Collectors.toList()));
List<ProWorkorder> workorderList = proWorkorderService.selectListByQw(queryWrapper);
Map<Long,WorkorderScheduleParams> workorderScheduleParamsMap= workorderScheduleParams.stream().collect(Collectors.toMap(s->s.getWorkorderId(),s->s));
List<ScheduleJobGroup> scheduleJobGroupList = new ArrayList<ScheduleJobGroup>();
for (ProWorkorder workorder : workorderList) {
ScheduleJobGroup scheduleJobGroup = new ScheduleJobGroup();
List<ProWorkorder> list = new ArrayList<>();
list.add(workorder);
scheduleJobGroup.setWorkorderList(list);
if(ObjectUtil.isEmpty(workorder.getRequestDate())){
throw new ServiceException(MessageUtils.message("pro.workOrder.error.not.null.requestDate"));
}
LocalDateTime recentDate = list.stream().map(s -> DateUtil.toLocalDateTime(s.getRequestDate())).min(Comparator.comparing(LocalDateTime::toLocalDate)).get();
WorkorderScheduleParams params = workorderScheduleParamsMap.get(workorder.getWorkorderId());
scheduleJobGroup.setQuantity(params.getScheduleQuantity());
scheduleJobGroup.setDemandDate(recentDate);
scheduleJobGroup.setWorkorderCode(workorder.getWorkorderCode());
scheduleJobGroup.setScheduleDate(params.getScheduleDate());
scheduleJobGroupList.add(scheduleJobGroup);
}
//按交期近,数量少排序
scheduleJobGroupList.sort(Comparator.comparing(ScheduleJobGroup::getDemandDate).thenComparing(ScheduleJobGroup::getQuantity));
Long i = 0l;
StringBuilder msg = new StringBuilder();
for (ScheduleJobGroup scheduleJobGroup : scheduleJobGroupList) {
ProWorkorder firstWorkorder = scheduleJobGroup.getWorkorderList().get(0);
QueryWrapper<ProWorkOrderProcess> processQuery = new QueryWrapper<ProWorkOrderProcess>();
processQuery.eq("t1.workorder_id", firstWorkorder.getWorkorderId());
processQuery.orderByAsc("t1.idx");
List<ProWorkOrderProcess> productionOrderRoutings = proWorkOrderProcessService.selectListByQw(processQuery);
if(productionOrderRoutings.size() < 1){
msg.append(MessageUtils.message("pro.schedule.error.not.exist.process", firstWorkorder.getWorkorderCode()));
msg.append(System.lineSeparator());
continue;
}
// 工序分组 生成Job及Task
Job job = new Job(scheduleJobGroup.getWorkorderCode(), Duration.between(scheduleJobGroup.getScheduleDate(), DateUtil.date(scheduleJobGroup.getDemandDate()).toLocalDateTime())) {{
setFixed(false);
}};
JobExtent jobExtent = new JobExtent();
jobExtent.setWorkorderList(scheduleJobGroup.getWorkorderList());
job.setJobExtend(jobExtent);
job.getLmtStartedTime().addOptional(Duration.ZERO);
job.getLmtEndedTime().addOptional(Duration.between(scheduleJobGroup.getScheduleDate(), DateUtil.date(scheduleJobGroup.getDemandDate()).toLocalDateTime()));
job.setQuantity(scheduleJobGroup.getQuantity());
job.setScheduleDate(scheduleJobGroup.getScheduleDate());
for (ProWorkOrderProcess routingItem : productionOrderRoutings) {
Task task = new Task(i, job);
task.setStandardWorkingTime(Duration.ZERO);
task.setSetupTime(Duration.ZERO);
task.setProcessId(routingItem.getProcessId());
task.setUnitPrice(routingItem.getUnitPrice());
task.setStdWorkingTime(routingItem.getStdWorkingTime());
task.setStdWorkingTimeUom(routingItem.getStdWorkingTimeUom());
task.setIdx(routingItem.getIdx());
task.setProcessName(routingItem.getProcessName());
task.setOrderQuantity(scheduleJobGroup.getQuantity());
task.setWorkCenterId(routingItem.getWorkstationId());
task.setWorkCenterName(routingItem.getWorkstationName());
if("Y".equalsIgnoreCase(routingItem.getOutsourced())){
task.setOutsourced(true);
}
//HOUR\SECOND\MINUTE
Long unitMultiple = 0l;
if ("HOUR".equalsIgnoreCase(routingItem.getStdWorkingTimeUom())) {
unitMultiple = unitMultiple * 60;
} else if ("SECOND".equalsIgnoreCase(routingItem.getStdWorkingTimeUom())) {
unitMultiple = 1000l * 1000 * 1000;
} else if("MIN".equalsIgnoreCase(routingItem.getStdWorkingTimeUom())){
unitMultiple = 1000l * 1000 * 1000 * 60;
}else {
throw new ServiceException(MessageUtils.message("pro.schedule.error.canNot.use.standardTime", routingItem.getStdWorkingTimeUom()));
}
if (routingItem.getStdWorkingTime() != null) {
//单件标准工时
Long standardSd = routingItem.getStdWorkingTime().multiply(BigDecimal.valueOf(unitMultiple)).longValue();
if (routingItem.getQuantity() != null) {
standardSd = standardSd / routingItem.getQuantity().longValue();
}
task.setStandardWorkingTime(Duration.ofNanos(standardSd));
}
if (routingItem.getLineBreakTime() != null) {
task.setSetupTime(Duration.ofNanos(routingItem.getLineBreakTime().multiply(BigDecimal.valueOf(unitMultiple)).longValue()));
}
task.getTaskData().put("SeqNo", routingItem.getProcessRef());
job.getTasks().add(task);
i++;
}
algJobs.add(job);
}
if(msg.length() > 0){
throw new ServiceException(msg.toString());
}
stopWatch.stop();
logger.info(String.format("待排产数据加载耗时:%s", stopWatch.getTotalTimeSeconds()));
return algJobs;
return null;
}
@Override
......
......@@ -30,84 +30,8 @@ public class BaoshenScheduleAlgorithmAdapter implements IScheduleAlgorithmAdapte
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
@Override
public List<ScheduledResult> schedule(LocalDateTime schedulingStartedDate, List<WorkorderScheduleParams> workorderScheduleParams) {
logger.info("----------排产开始----------");
StopWatch stopWatch = new StopWatch();
stopWatch.start();
List<ScheduledResult> scheduleResults = new ArrayList<ScheduledResult>();
StopWatch stopWatch2 = new StopWatch();
stopWatch2.start();
List<Resource> algResources = algorithmDataSource.getResource(schedulingStartedDate, workorderScheduleParams);
List<Job> algJobs = algorithmDataSource.getJob(schedulingStartedDate, workorderScheduleParams, algResources);
List<Calendar> algCalendar = algorithmDataSource.getCalendar(schedulingStartedDate, workorderScheduleParams, algResources);
stopWatch2.stop();
logger.info(String.format("排产数据加载总耗时:%s", stopWatch2.getTotalTimeSeconds()));
if(algorithmExtendDataSources!=null){
AlgorithmDataContext algorithmDataContext = new AlgorithmDataContext(){{
setJobs(algJobs);
setCalendars(algCalendar);
setResources(algResources);
setWorkorderIds(workorderScheduleParams.stream().map(s->s.getWorkorderId()).collect(Collectors.toList()));
}};
algorithmExtendDataSources.forEach(s->{
s.extendData(algorithmDataContext);
});
}
//按工作中心分组设备
Map<Long, List<Equipment>> equipmentMap = algResources.stream().filter(s->s instanceof Equipment).map(s->(Equipment)s)
.collect(Collectors.groupingBy(s->((Equipment) s).getWorkCenterId()));
//设置排产任务可选设备
algJobs.forEach(job->{
job.getTasks().forEach(task->{
task.setOptionalEquipments(equipmentMap.getOrDefault(task.getWorkCenterId(), new ArrayList<Equipment>()));
task.setLimitedTimeCalculator(new OrderLimitedTimeCalculator());
task.setOperationTimeCalculator(new OrderOperationTimeCalculator());
});
});
IAlgorithm algorithm = new GreedyAlg(equipmentSelectionStrategy);
List<Job> result = algorithm.schedule(algJobs, algResources, algCalendar);
for (Job alg_job : result)
{
String productionOrderNo =(String) alg_job.getJobData().get("ProductionOrderNo");
String identifier = (String) alg_job.getJobData().get("Identifier");
switch (alg_job.getScheduleStatus())
{
case Delay:
scheduleResults.add(new ScheduledResult(){{
setJobID(alg_job.getId());
setResultType(ScheduleStatus.Delay);
setProductionOrderNo(productionOrderNo);
setIdentifier(identifier);
}});
break;
case InadequateTime:
scheduleResults.add(new ScheduledResult(){{
setJobID(alg_job.getId());
setResultType(ScheduleStatus.Delay);
setProductionOrderNo(productionOrderNo);
setIdentifier(identifier);
setResultDesc(alg_job.getScheduleDesc());
}});
break;
case Waiting:
scheduleResults.add(new ScheduledResult(){{
setJobID(alg_job.getId());
setResultType(ScheduleStatus.Waiting);
setProductionOrderNo(productionOrderNo);
setIdentifier(identifier);
setResultDesc(alg_job.getScheduleDesc());
}});
break;
}
}
stopWatch.stop();
//排产成功执行回调
algorithmResultProcess.execute(schedulingStartedDate, result);
logger.info("----------排产结束----------");
logger.info(String.format("排产总耗时:%s", stopWatch.getTotalTimeSeconds()));
return scheduleResults;
return null;
}
private OrderOperationTimeCalculator orderOperationTimeCalculator = new OrderOperationTimeCalculator();
......
......@@ -31,84 +31,7 @@ public class ThXMScheduleAlgorithmAdapter implements IScheduleAlgorithmAdapter {
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
@Override
public List<ScheduledResult> schedule(LocalDateTime schedulingStartedDate, List<WorkorderScheduleParams> workorderScheduleParams) {
logger.info("----------排产开始----------");
StopWatch stopWatch = new StopWatch();
stopWatch.start();
List<ScheduledResult> scheduleResults = new ArrayList<ScheduledResult>();
StopWatch stopWatch2 = new StopWatch();
stopWatch2.start();
List<Resource> algResources = algorithmDataSource.getResource(schedulingStartedDate, workorderScheduleParams);
List<Job> algJobs = algorithmDataSource.getJob(schedulingStartedDate, workorderScheduleParams, algResources);
List<Calendar> algCalendar = algorithmDataSource.getCalendar(schedulingStartedDate, workorderScheduleParams, algResources);
stopWatch2.stop();
logger.info(String.format("排产数据加载总耗时:%s", stopWatch2.getTotalTimeSeconds()));
if(algorithmExtendDataSources!=null){
AlgorithmDataContext algorithmDataContext = new AlgorithmDataContext(){{
setJobs(algJobs);
setCalendars(algCalendar);
setResources(algResources);
setWorkorderIds(workorderScheduleParams.stream().map(s->s.getWorkorderId()).collect(Collectors.toList()));
}};
algorithmExtendDataSources.forEach(s->{
s.extendData(algorithmDataContext);
});
}
//按工作中心分组设备
Map<Long, List<Equipment>> equipmentMap = algResources.stream().filter(s->s instanceof Equipment).map(s->(Equipment)s)
.collect(Collectors.groupingBy(s->((Equipment) s).getWorkCenterId()));
//设置排产任务可选设备
algJobs.forEach(job->{
job.getTasks().forEach(task->{
task.setOptionalEquipments(equipmentMap.getOrDefault(task.getWorkCenterId(), new ArrayList<Equipment>()));
task.setLimitedTimeCalculator(new OrderLimitedTimeCalculator());
task.setOperationTimeCalculator(new OrderOperationTimeCalculator());
});
});
IAlgorithm algorithm = new GreedyAlgThXM(equipmentSelectionStrategy);
List<Job> result = algorithm.schedule(algJobs, algResources, algCalendar);
for (Job alg_job : result)
{
String productionOrderNo =(String) alg_job.getJobData().get("ProductionOrderNo");
String identifier = (String) alg_job.getJobData().get("Identifier");
switch (alg_job.getScheduleStatus())
{
case Delay:
scheduleResults.add(new ScheduledResult(){{
setJobID(alg_job.getId());
setResultType(ScheduleStatus.Delay);
setProductionOrderNo(productionOrderNo);
setIdentifier(identifier);
}});
break;
case InadequateTime:
scheduleResults.add(new ScheduledResult(){{
setJobID(alg_job.getId());
setResultType(ScheduleStatus.Delay);
setProductionOrderNo(productionOrderNo);
setIdentifier(identifier);
setResultDesc(alg_job.getScheduleDesc());
}});
break;
case Waiting:
scheduleResults.add(new ScheduledResult(){{
setJobID(alg_job.getId());
setResultType(ScheduleStatus.Waiting);
setProductionOrderNo(productionOrderNo);
setIdentifier(identifier);
setResultDesc(alg_job.getScheduleDesc());
}});
break;
}
}
stopWatch.stop();
//排产成功执行回调
algorithmResultProcess.execute(schedulingStartedDate, result);
logger.info("----------排产结束----------");
logger.info(String.format("排产总耗时:%s", stopWatch.getTotalTimeSeconds()));
return scheduleResults;
return null;
}
private OrderOperationTimeCalculator orderOperationTimeCalculator = new OrderOperationTimeCalculator();
......
......@@ -277,67 +277,6 @@ public class ProTaskAssistProcessServiceImpl implements IProTaskAssistProcessSer
@Transactional
@Override
public int feedBack(ProFeedback feedback) {
Long taskWorkunitId = feedback.getTaskWorkunitId();
ProTaskWorkunit taskWorkunit = proTaskWorkunitService.selectProTaskWorkunitByTaskWorkunitId(taskWorkunitId);
ProWorkorder workorder = proWorkorderMapper.selectWorkorderById(feedback.getWorkorderId());
ExceptionUtil.checkTrueThrowException(taskWorkunit == null, MessageUtils.message("pro.schedule.data.not.exists"));
ExceptionUtil.checkTrueThrowException(!taskWorkunit.getStatus().equals(TaskStatusEnum.BEGINNING.getStatus()), MessageUtils.message("pro.feedback.error.before.start"));
feedback.initValue(workorder,taskWorkunit);
Double feedbackSum = proFeedbackService.selectQuantityQualifySum(new ProFeedback(null, null, null, taskWorkunitId));
double taskQuantityDouble = taskWorkunit.getQuantity().doubleValue();
double canBeWaitQuantity = taskQuantityDouble - feedbackSum;
ExceptionUtil.checkTrueThrowException(canBeWaitQuantity <= 0, MessageUtils.message("pro.feedback.error.min.quantity"));
BigDecimal quantityQualify = feedback.getQuantityQualify();
BigDecimal quantityUnQualify = feedback.getQuantityUnqualify();
BigDecimal quantityFeedback = quantityQualify.add(quantityUnQualify);
double quantityFeedbackDouble = quantityFeedback.doubleValue();
ExceptionUtil.checkTrueThrowException(quantityFeedbackDouble > canBeWaitQuantity, MessageUtils.message("pro.feedback.error.quantity.lack"));
ProTask task = proTaskService.selectBaseById(taskWorkunit.getTaskId());
BigDecimal taskQuantityWait = task.getQuantityWait();
ExceptionUtil.checkTrueThrowException(quantityFeedbackDouble > taskQuantityWait.longValue()
|| quantityFeedbackDouble > taskQuantityDouble, MessageUtils.message("pro.feedback.error.quantity.lack"));
BigDecimal quantityWait = taskQuantityWait.subtract(quantityQualify);
task.setQuantityWait(quantityWait);
task.setQuantityQualify(task.getQuantityQualify().add(quantityQualify));
task.setQuantityUnqualify(task.getQuantityUnqualify().add(quantityUnQualify));
task.setQuantityProduced(task.getQuantityProduced().add(quantityQualify));
taskWorkunit.setQuantityQualify(taskWorkunit.getQuantityQualify().add(quantityQualify));
taskWorkunit.setQuantityUnqualify(taskWorkunit.getQuantityUnqualify().add(quantityUnQualify));
taskWorkunit.setQuantityProduced(taskWorkunit.getQuantityProduced().add(quantityQualify));
if (feedback.getCloseType() == 1 || taskWorkunit.getQuantity().compareTo(taskWorkunit.getQuantityProduced()) <= 0) {
taskWorkunit.setStatus(TaskWorkunitStatusEnum.FINISHED.getStatus());
taskWorkunit.setActualEndDate(Calendar.getInstance().getTime());
proTaskWorkunitService.updateProTaskWorkunit(taskWorkunit);
}
//按派工表保存报工记录
feedback.setFeedbackType("SELF");
feedback.setNickName(sysUserMapper.selectUserById(SecurityUtils.getUserId()).getNickName());
proFeedbackService.insertProFeedback(feedback);
//查询关联下道工序
ProTask nextTask = proTaskService.getNextTaskByTaskId(feedback.getTaskId());
if (nextTask != null) {
nextTask.setQuantityWait(DataUtil.getNormalData(nextTask.getQuantityWait()));
// 下道任务待加工数累加合格数量
if (quantityQualify.doubleValue() > 0) {
nextTask.setQuantityWait(nextTask.getQuantityWait().add(quantityQualify));
}
List<ProTaskWorkunit> proTaskWorkunits = proTaskWorkunitMapper.selectListByQw(new QueryWrapper<ProTaskWorkunit>().eq("task_id", nextTask.getTaskId()));
proTaskWorkunits.stream().filter(x -> Objects.equals(x.getStatus(), FINISHED.getStatus())).forEach(x -> {
x.setStatus(BEGINNING.getStatus());
proTaskWorkunitService.updateProTaskWorkunit(x);
});
proTaskService.updateProTask(nextTask);
}
proTaskService.updateProTask(task);
proTaskWorkunitService.updateProTaskWorkunit(taskWorkunit);
return 1;
}
......
......@@ -183,9 +183,8 @@ public class ProTaskWorkunitServiceImpl implements IProTaskWorkunitService {
*/
@Override
public int insertProTaskWorkunit(ProTaskWorkunit proTaskWorkunit) {
proTaskWorkunit.createAction();
proTaskWorkunit.setOutsourced(0);
return proTaskWorkunitMapper.insertProTaskWorkunit(proTaskWorkunit);
return 1;
}
/**
......@@ -346,51 +345,8 @@ public class ProTaskWorkunitServiceImpl implements IProTaskWorkunitService {
@Override
public void makeProduction(Long[] taskWorkunitIds) {
Map<Long, ProTask> taskMap = new HashMap<Long, ProTask>();
List<ProWorkorder> workorderList = new ArrayList<ProWorkorder>();
List<Long> taskIds = new ArrayList<Long>();
for (Long id : taskWorkunitIds) {
ProTaskWorkunit proTaskWorkunit = this.selectProTaskWorkunitByTaskWorkunitId(id);
proTaskWorkunit.setStatus(TaskStatusEnum.PREPARE.getStatus());
Long taskId = proTaskWorkunit.getTaskId();
ProTask proTask = null;
if (!taskMap.containsKey(taskId)) {
proTask = proTaskService.selectProTaskByTaskId(taskId);
taskMap.put(taskId, proTask);
taskIds.add(taskId);
}
this.updateProTaskWorkunit(proTaskWorkunit);
//生产领料申请单
proMaterialRequestService.insertProMaterialRequestIssueItem(id, proTask);
}
// 生成刀模版具
List<ProTaskWorkunit> proTaskWorkunits = proTaskWorkunitService.selectListByQw(new QueryWrapper<ProTaskWorkunit>().in("task_workunit_id", Arrays.asList(taskWorkunitIds)));
tmToolRequestService.addedToolRequestAppForm(proTaskWorkunits);
//查询关联工单
QueryWrapper<ProTaskWorkorder> taskWorkorderQuery = new QueryWrapper<ProTaskWorkorder>();
taskWorkorderQuery.in("task_id", taskIds);
List<ProTaskWorkorder> taskWorkorderList = proTaskWorkorderService.selectProTaskWorkorder(taskWorkorderQuery);
//查询任务单关联工单
for (ProTaskWorkorder taskWorkorder : taskWorkorderList) {
ProWorkorder workorder = proWorkorderService.selectWorkorderById(taskWorkorder.getWorkorderId());
workorderList.add(workorder);
}
//关联工单修改为下达
workorderList.forEach(value -> {
if (value.getStatus().equals(WorkorderStatusEnum.SCHEDULED.getValue())) {
String arrangeCode = value.getArrangeCode();
ProWorkorder proWorkorder = new ProWorkorder();
proWorkorder.setArrangeCode(arrangeCode);
value.setStatus(WorkorderStatusEnum.ISSUED.getValue());
proWorkorderService.updateProWorkorder(value);
}
});
}
@Override
......@@ -532,36 +488,7 @@ public class ProTaskWorkunitServiceImpl implements IProTaskWorkunitService {
@Override
@Transactional
public void toOutsource(List<TaskWorkunitToOutsourceParam> toOutsourceParamList) {
toOutsourceParamList.forEach(toOutsourceParam->{
if(toOutsourceParam.getToOutsourceQuantity().compareTo(BigDecimal.ZERO)==0){
throw new ServiceException(MessageUtils.message("pro.schedule.limit.to.outsource.min.quantity"));
}
ProTaskWorkunit taskWorkunit = this.selectProTaskWorkunitByTaskWorkunitId(toOutsourceParam.getTaskWorkunitId());
//不可超过未报工数量
if(taskWorkunit.getQuantity().subtract(taskWorkunit.getQuantityQualify()).compareTo(toOutsourceParam.getToOutsourceQuantity())<0){
throw new ServiceException(MessageUtils.message("pro.schedule.error.to.outsource.quantity.lack"));
}
ProTaskWorkunit newTaskWorkunit = BeanUtil.copyProperties(taskWorkunit, ProTaskWorkunit.class);
newTaskWorkunit.setWorkunitId(IMdWorkunitService.OUTSOURCE_WORKUNIT_ID);
newTaskWorkunit.setQuantity(toOutsourceParam.getToOutsourceQuantity());
newTaskWorkunit.setQuantityQualify(BigDecimal.ZERO);
newTaskWorkunit.setQuantityUnqualify(BigDecimal.ZERO);
newTaskWorkunit.setQuantityProduced(BigDecimal.ZERO);
newTaskWorkunit.setQuantityChanged(BigDecimal.ZERO);
newTaskWorkunit.setStatus(TaskStatusEnum.PREPARE.getStatus());
BeanUtil.copyProperties(toOutsourceParam, newTaskWorkunit);
this.insertProTaskWorkunit(newTaskWorkunit);
//原数量扣减
taskWorkunit.setQuantity(taskWorkunit.getQuantity().subtract(toOutsourceParam.getToOutsourceQuantity()));
this.updateProTaskWorkunit(taskWorkunit);
//添加记录
ProTaskWorkunitConvertRecordCreate record = new ProTaskWorkunitConvertRecordCreate();
record.setTaskWorkunitId(taskWorkunit.getTaskWorkunitId());
record.setNewTaskWorkunitId(newTaskWorkunit.getTaskWorkunitId());
record.setQuantity(toOutsourceParam.getToOutsourceQuantity());
record.setOperateType(IProTaskWorkunitConvertRecordService.TaskWorkunitConvertType.TO_OUTSOURCE.getValue());
taskWorkunitConvertRecordService.insertProTaskWorkunitConvertRecord(record);
});
}
@Override
......
......@@ -134,12 +134,6 @@ public interface IProTaskService {
List<Map<String, String>> listMdItemByWorkUnit(Long id);
/**
* 报工处理
*
* @param feedback
*/
List<ProPackagePrintResult> feedBack(ProFeedback feedback);
/**
* 报工推送ERP
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment