|
|
|
|
@ -10,11 +10,14 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
|
|
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
|
|
|
|
import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductRespVO;
|
|
|
|
|
import cn.iocoder.yudao.module.iot.framework.mqtt.utils.DateUtils;
|
|
|
|
|
import cn.iocoder.yudao.module.mes.controller.admin.dashboard.vo.DeviceTypePieOptionsVO;
|
|
|
|
|
import cn.iocoder.yudao.module.mes.controller.admin.itemrequisition.vo.ItemRequisitionRespVO;
|
|
|
|
|
import cn.iocoder.yudao.module.mes.controller.admin.itemrequisition.vo.ItemRequisitionSaveReqVO;
|
|
|
|
|
import cn.iocoder.yudao.module.mes.controller.admin.plan.vo.*;
|
|
|
|
|
import cn.iocoder.yudao.module.mes.controller.admin.zjproductrecord.vo.ZjProductRecordRespVO;
|
|
|
|
|
import cn.iocoder.yudao.module.mes.controller.admin.zjproductrecord.vo.ZjProductRecordSaveReqVO;
|
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.dataobject.deviceledger.DeviceLedgerDO;
|
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.dataobject.dvrepair.DvRepairDO;
|
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.dataobject.itemrequisition.ItemRequisitionDO;
|
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.dataobject.organization.OrganizationDO;
|
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.dataobject.plan.PlanDO;
|
|
|
|
|
@ -27,6 +30,8 @@ import cn.iocoder.yudao.module.mes.service.organization.OrganizationService;
|
|
|
|
|
import cn.iocoder.yudao.module.mes.service.plan.PlanService;
|
|
|
|
|
import cn.iocoder.yudao.module.mes.service.zjproduct.ZjProductService;
|
|
|
|
|
import cn.iocoder.yudao.module.mes.service.zjproductrecord.ZjProductRecordService;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
|
|
@ -40,15 +45,16 @@ import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import javax.validation.Valid;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Collections;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.time.DayOfWeek;
|
|
|
|
|
import java.time.LocalDate;
|
|
|
|
|
import java.time.ZoneId;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
|
|
|
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.error;
|
|
|
|
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
|
|
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
|
|
|
|
import static org.apache.ibatis.ognl.OgnlOps.getIntValue;
|
|
|
|
|
|
|
|
|
|
@Tag(name = "管理后台 - 生产计划")
|
|
|
|
|
@RestController
|
|
|
|
|
@ -129,6 +135,7 @@ public class PlanController {
|
|
|
|
|
PageResult<PlanRespVO> pageResult = planService.getPlanPage(pageReqVO);
|
|
|
|
|
return success(new PageResult<>(buildVOList(pageResult.getList()), pageResult.getTotal()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<PlanRespVO> buildVOList(List<PlanRespVO> list) {
|
|
|
|
|
if (CollUtil.isEmpty(list)) {
|
|
|
|
|
return Collections.emptyList();
|
|
|
|
|
@ -174,6 +181,7 @@ public class PlanController {
|
|
|
|
|
planService.arrangePlan(saveReqVO, planDO, list);
|
|
|
|
|
return success(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PutMapping("/typePaigong")
|
|
|
|
|
@Operation(summary = "工序派工")
|
|
|
|
|
//@PreAuthorize("@ss.hasPermission('mes:plan:update')")
|
|
|
|
|
@ -208,7 +216,7 @@ public class PlanController {
|
|
|
|
|
// 入库
|
|
|
|
|
else if ("store".equals(statusUpdateVO.getCode())) {
|
|
|
|
|
planDO.setStatus(PlanStatusEnum.已入库.getValue());
|
|
|
|
|
planService.createPlanStockIn(statusUpdateVO,planDO);
|
|
|
|
|
planService.createPlanStockIn(statusUpdateVO, planDO);
|
|
|
|
|
}
|
|
|
|
|
planMapper.updateById(planDO);
|
|
|
|
|
return success(true);
|
|
|
|
|
@ -235,6 +243,7 @@ public class PlanController {
|
|
|
|
|
List<ErpProductRespVO> proList = planService.getProductByPlanStatus(status);
|
|
|
|
|
return success(proList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GetMapping("/getByStatus")
|
|
|
|
|
@Operation(summary = "获得生产计划")
|
|
|
|
|
@Parameter(name = "status", description = "状态", required = true, example = "1024")
|
|
|
|
|
@ -250,6 +259,24 @@ public class PlanController {
|
|
|
|
|
return success(planRespVOList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GetMapping("/getProductPlans")
|
|
|
|
|
@Operation(summary = "获得生产计划")
|
|
|
|
|
@Parameter(name = "status", description = "状态", required = true, example = "1024")
|
|
|
|
|
public CommonResult<List<PlanRespVO>> getProductPlans() {
|
|
|
|
|
List<Integer> statusList = new ArrayList<>();
|
|
|
|
|
statusList.add(PlanStatusEnum.试产.getValue());
|
|
|
|
|
statusList.add(PlanStatusEnum.量产.getValue());
|
|
|
|
|
statusList.add(PlanStatusEnum.暂停.getValue());
|
|
|
|
|
statusList.add(PlanStatusEnum.待入库.getValue());
|
|
|
|
|
//statusList.add(PlanStatusEnum.开工.getValue());
|
|
|
|
|
// statusList.add(PlanStatusEnum.派工.getValue());
|
|
|
|
|
// statusList.add(PlanStatusEnum.计划.getValue());
|
|
|
|
|
// statusList.add(PlanStatusEnum.暂停.getValue());
|
|
|
|
|
List<PlanDO> proList = planService.getPlanByStatus(statusList);
|
|
|
|
|
List<PlanRespVO> planRespVOList = planService.buildVOList(proList);
|
|
|
|
|
return success(planRespVOList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GetMapping("/getByTicketType")
|
|
|
|
|
@Operation(summary = "获得质检工单下拉")
|
|
|
|
|
@Parameter(name = "status", description = "状态", required = true, example = "1024")
|
|
|
|
|
@ -258,9 +285,9 @@ public class PlanController {
|
|
|
|
|
List<Integer> statusList = new ArrayList<>();
|
|
|
|
|
statusList.add(status);
|
|
|
|
|
statusList.add(PlanStatusEnum.已排产.getValue());
|
|
|
|
|
statusList.add(PlanStatusEnum.试产.getValue());
|
|
|
|
|
statusList.add(PlanStatusEnum.量产.getValue());
|
|
|
|
|
statusList.add(PlanStatusEnum.暂停.getValue());
|
|
|
|
|
statusList.add(PlanStatusEnum.试产.getValue());
|
|
|
|
|
statusList.add(PlanStatusEnum.量产.getValue());
|
|
|
|
|
statusList.add(PlanStatusEnum.暂停.getValue());
|
|
|
|
|
List<PlanDO> proList = planService.getPlanByStatus(statusList);
|
|
|
|
|
List<PlanRespVO> planRespVOList = planService.buildVOList(proList);
|
|
|
|
|
return success(planRespVOList);
|
|
|
|
|
@ -285,5 +312,97 @@ public class PlanController {
|
|
|
|
|
return success(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GetMapping("/getWeekTrend")
|
|
|
|
|
@Operation(summary = "综合大屏-周生产趋势")
|
|
|
|
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
|
|
|
|
public CommonResult<PlanWeekTrendVO> getWeekTrend() {
|
|
|
|
|
PlanWeekTrendVO planWeekTrendVO = new PlanWeekTrendVO();
|
|
|
|
|
LocalDate today = LocalDate.now();
|
|
|
|
|
// 获取本周一
|
|
|
|
|
LocalDate start = today.with(DayOfWeek.MONDAY);
|
|
|
|
|
// 获取本周日
|
|
|
|
|
LocalDate end = today.with(DayOfWeek.SUNDAY);
|
|
|
|
|
|
|
|
|
|
// 转换为 Date
|
|
|
|
|
Date monday = Date.from(start.atStartOfDay(ZoneId.systemDefault()).toInstant());
|
|
|
|
|
Date sunday = Date.from(end.atTime(23, 59, 59).atZone(ZoneId.systemDefault()).toInstant());
|
|
|
|
|
List<Map<String, Object>> result = planMapper.selectMaps(
|
|
|
|
|
new QueryWrapper<PlanDO>()
|
|
|
|
|
.select(
|
|
|
|
|
"DATE(create_time) as date",
|
|
|
|
|
"DAYOFWEEK(create_time) as weekday",
|
|
|
|
|
"SUM(plan_number) as planCount",
|
|
|
|
|
"SUM(wangong_number) as wangongCount"
|
|
|
|
|
)
|
|
|
|
|
.ge("create_time", monday)
|
|
|
|
|
.le("create_time", sunday)
|
|
|
|
|
.groupBy("DATE(create_time), DAYOFWEEK(create_time)")
|
|
|
|
|
.orderByAsc("DATE(create_time)")
|
|
|
|
|
);
|
|
|
|
|
List<String> weekDays = new ArrayList<>(Arrays.asList("周一", "周二", "周三", "周四", "周五", "周六", "周日"));
|
|
|
|
|
List<Integer> weekPlan = new ArrayList<>(Collections.nCopies(7, 0));
|
|
|
|
|
List<Integer> weekReal = new ArrayList<>(Collections.nCopies(7, 0));
|
|
|
|
|
for (Map<String, Object> map : result) {
|
|
|
|
|
Object weekdayObj = map.get("weekday");
|
|
|
|
|
// 确定星期字符串
|
|
|
|
|
String weekdayStr = null;
|
|
|
|
|
if (weekdayObj instanceof Integer) {
|
|
|
|
|
int dayCode = (Integer) weekdayObj;
|
|
|
|
|
weekdayStr = WeekDayEnum.getNameByCode(dayCode); // 使用枚举转换
|
|
|
|
|
} else if (weekdayObj instanceof String) {
|
|
|
|
|
weekdayStr = (String) weekdayObj;
|
|
|
|
|
} else if (weekdayObj != null) {
|
|
|
|
|
weekdayStr = weekdayObj.toString();
|
|
|
|
|
}
|
|
|
|
|
// 匹配并填充数据
|
|
|
|
|
if (weekdayStr != null) {
|
|
|
|
|
int index = weekDays.indexOf(weekdayStr);
|
|
|
|
|
if (index != -1) {
|
|
|
|
|
int plan = Math.max(getIntValue(map.get("planCount")), 0);
|
|
|
|
|
int real = Math.max(getIntValue(map.get("wangongCount")), 0);
|
|
|
|
|
|
|
|
|
|
weekPlan.set(index, plan);
|
|
|
|
|
weekReal.set(index, real);
|
|
|
|
|
weekReal.set(index, real);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
planWeekTrendVO.setWeekDays(weekDays);
|
|
|
|
|
planWeekTrendVO.setWeekPlan(weekPlan);
|
|
|
|
|
planWeekTrendVO.setWeekReal(weekReal);
|
|
|
|
|
return success(planWeekTrendVO);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GetMapping("/getDayCapacity")
|
|
|
|
|
@Operation(summary = "综合大屏-日产能达成情况")
|
|
|
|
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
|
|
|
|
public CommonResult<DayCapacityVO> getDayCapacity() {
|
|
|
|
|
DayCapacityVO dayCapacityVO = new DayCapacityVO();
|
|
|
|
|
List<Integer> statusList = new ArrayList<>(Collections.singletonList(PlanStatusEnum.已排产.getValue()));
|
|
|
|
|
List<PlanDO> planDOList = planService.getPlanByStatus(statusList);
|
|
|
|
|
// 排产单数量
|
|
|
|
|
dayCapacityVO.setOrders(planDOList.size());
|
|
|
|
|
// 排产数量
|
|
|
|
|
int plan = 0;
|
|
|
|
|
for (PlanDO planDO : planDOList) {
|
|
|
|
|
if (planDO.getPlanNumber() != null) {
|
|
|
|
|
plan = plan + planDO.getPlanNumber().intValue();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
dayCapacityVO.setPlan(plan);
|
|
|
|
|
// 已生产数量
|
|
|
|
|
statusList = Arrays.asList(PlanStatusEnum.已入库.getValue(),PlanStatusEnum.待入库.getValue());;
|
|
|
|
|
planDOList = planService.getPlanByStatus(statusList);
|
|
|
|
|
int finish = 0;
|
|
|
|
|
for (PlanDO planDO : planDOList) {
|
|
|
|
|
if (planDO.getWangongNumber() != null) {
|
|
|
|
|
finish = finish + planDO.getWangongNumber().intValue();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
dayCapacityVO.setPending(finish);
|
|
|
|
|
return success(dayCapacityVO);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|