|
|
|
|
@ -3,12 +3,14 @@ package org.dromara.mes.service.impl;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
|
import com.github.yulichang.toolkit.JoinWrappers;
|
|
|
|
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
|
|
|
|
import jakarta.servlet.http.HttpServletResponse;
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
import org.dromara.common.constant.DatabaseConstants;
|
|
|
|
|
import org.dromara.common.core.exception.ServiceException;
|
|
|
|
|
import org.dromara.common.core.utils.MapstructUtils;
|
|
|
|
|
import org.dromara.common.core.utils.StringUtils;
|
|
|
|
|
import org.dromara.common.core.utils.uuid.Seq;
|
|
|
|
|
import org.dromara.common.excel.utils.ExcelUtil;
|
|
|
|
|
import org.dromara.common.mapper.DynamicBaseSqlMapper;
|
|
|
|
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
|
|
|
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
|
|
|
@ -17,29 +19,27 @@ import org.dromara.mes.domain.bo.ProdPlanInfoBo;
|
|
|
|
|
import org.dromara.mes.domain.vo.MesProductPlanEditVo;
|
|
|
|
|
import org.dromara.mes.domain.vo.PlanMonitorVo;
|
|
|
|
|
import org.dromara.mes.domain.vo.ProdPlanInfoVo;
|
|
|
|
|
import org.dromara.mes.domain.vo.ShiftGroupVo;
|
|
|
|
|
import org.dromara.mes.enums.PlanEventEnum;
|
|
|
|
|
import org.dromara.mes.enums.PlanStatusEnum;
|
|
|
|
|
import org.dromara.mes.mapper.ProdPlanInfoMapper;
|
|
|
|
|
import org.dromara.mes.service.IProdPlanInfoService;
|
|
|
|
|
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import org.springframework.util.ObjectUtils;
|
|
|
|
|
|
|
|
|
|
import java.util.Collection;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
import org.springframework.messaging.Message;
|
|
|
|
|
import org.springframework.messaging.support.MessageBuilder;
|
|
|
|
|
import org.springframework.statemachine.StateMachine;
|
|
|
|
|
import org.springframework.statemachine.config.StateMachineFactory;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.statemachine.support.DefaultStateMachineContext;
|
|
|
|
|
import org.springframework.statemachine.StateMachine;
|
|
|
|
|
import org.springframework.statemachine.service.StateMachineService;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import org.springframework.util.ObjectUtils;
|
|
|
|
|
import org.dromara.common.core.service.DictService;
|
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 生产工单信息Service业务层处理
|
|
|
|
|
@ -57,6 +57,8 @@ public class ProdPlanInfoServiceImpl implements IProdPlanInfoService {
|
|
|
|
|
|
|
|
|
|
private final DynamicBaseSqlMapper<ProdPlanInfo> dynamicBaseSqlMapper;
|
|
|
|
|
|
|
|
|
|
private final DictService dictService;//字典服务服务
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private StateMachineFactory<PlanStatusEnum, PlanEventEnum> stateMachineFactory;
|
|
|
|
|
@ -367,8 +369,6 @@ public class ProdPlanInfoServiceImpl implements IProdPlanInfoService {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private PlanEventEnum determineEvent(PlanStatusEnum currentStatus, PlanStatusEnum targetStatus) {
|
|
|
|
|
// 根据当前状态和目标状态确定需要触发的事件
|
|
|
|
|
if (currentStatus == PlanStatusEnum.CREATED && targetStatus == PlanStatusEnum.PLANNED) {
|
|
|
|
|
@ -422,4 +422,69 @@ public class ProdPlanInfoServiceImpl implements IProdPlanInfoService {
|
|
|
|
|
return sm;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 导出生产计划监控列表
|
|
|
|
|
* @param bo 查询条件
|
|
|
|
|
* @param response response
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public void exportMonitor(ProdPlanInfoBo bo, HttpServletResponse response) {
|
|
|
|
|
List<PlanMonitorVo> list = queryMoritorList(bo);
|
|
|
|
|
// 获取所有班次
|
|
|
|
|
List<String> shiftNames = list.stream()
|
|
|
|
|
.flatMap(machine -> machine.getShifts().stream())
|
|
|
|
|
.map(ShiftGroupVo::getShiftName)
|
|
|
|
|
.distinct()
|
|
|
|
|
.sorted()
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
// 构建动态表头
|
|
|
|
|
List<List<String>> head = new ArrayList<>();
|
|
|
|
|
head.add(Arrays.asList("机台"));
|
|
|
|
|
head.add(Arrays.asList("物料名称"));
|
|
|
|
|
head.add(Arrays.asList("计划产量"));
|
|
|
|
|
head.add(Arrays.asList("实际产量"));
|
|
|
|
|
head.add(Arrays.asList("差异"));
|
|
|
|
|
head.add(Arrays.asList("计划开始时间"));
|
|
|
|
|
head.add(Arrays.asList("计划结束时间"));
|
|
|
|
|
for (String shiftName : shiftNames) {
|
|
|
|
|
head.add(Arrays.asList(shiftName));
|
|
|
|
|
}
|
|
|
|
|
head.add(Arrays.asList("状态"));
|
|
|
|
|
|
|
|
|
|
// 构建数据
|
|
|
|
|
List<List<Object>> data = new ArrayList<>();
|
|
|
|
|
for (PlanMonitorVo machine : list) {
|
|
|
|
|
for (ShiftGroupVo shift : machine.getShifts()) {
|
|
|
|
|
for (ProdPlanInfoVo plan : shift.getPlans()) {
|
|
|
|
|
List<Object> row = new ArrayList<>();
|
|
|
|
|
row.add(machine.getMachineName());
|
|
|
|
|
row.add(plan.getMaterialName());
|
|
|
|
|
row.add(plan.getPlanAmount());
|
|
|
|
|
row.add(plan.getCompleteAmount());
|
|
|
|
|
BigDecimal difference = (plan.getPlanAmount() == null ? BigDecimal.ZERO : plan.getPlanAmount())
|
|
|
|
|
.subtract(plan.getCompleteAmount() == null ? BigDecimal.ZERO : plan.getCompleteAmount());
|
|
|
|
|
row.add(difference);
|
|
|
|
|
row.add(plan.getPlanBeginTime());
|
|
|
|
|
row.add(plan.getPlanEndTime());
|
|
|
|
|
|
|
|
|
|
for (String shiftName : shiftNames) {
|
|
|
|
|
if (shiftName.equals(shift.getShiftName())) {
|
|
|
|
|
row.add(plan.getPlanAmount());
|
|
|
|
|
} else {
|
|
|
|
|
row.add("");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 工单计划状态(0未下发 1已下发 2已开始 3已完成 4已撤回) 使用字典mes_plan_status
|
|
|
|
|
String statusLabel = dictService.getDictLabel("mes_plan_status", plan.getPlanStatus(), ",");
|
|
|
|
|
row.add(statusLabel);
|
|
|
|
|
data.add(row);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ExcelUtil.exportExcelWithDynamicHead(data, head, "生产计划监控", response);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|