|
|
|
|
@ -1,19 +1,25 @@
|
|
|
|
|
package cn.iocoder.yudao.module.mes.controller.admin.plan;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
|
|
|
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
|
|
import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
|
|
|
|
|
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.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.dal.dataobject.itemrequisition.ItemRequisitionDO;
|
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.dataobject.organization.OrganizationDO;
|
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.dataobject.plan.PlanDO;
|
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.mysql.plan.PlanMapper;
|
|
|
|
|
import cn.iocoder.yudao.module.mes.service.itemrequisition.ItemAnalysisService;
|
|
|
|
|
import cn.iocoder.yudao.module.mes.service.itemrequisition.entity.ItemRequisitionAndStock;
|
|
|
|
|
import cn.iocoder.yudao.module.mes.service.organization.OrganizationService;
|
|
|
|
|
import cn.iocoder.yudao.module.mes.service.plan.PlanService;
|
|
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
|
|
|
@ -26,11 +32,14 @@ import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import javax.validation.Valid;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Collections;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
@Tag(name = "管理后台 - 生产计划")
|
|
|
|
|
@RestController
|
|
|
|
|
@ -42,6 +51,8 @@ public class PlanController {
|
|
|
|
|
private PlanService planService;
|
|
|
|
|
@Resource
|
|
|
|
|
private PlanMapper planMapper;
|
|
|
|
|
@Resource
|
|
|
|
|
private OrganizationService organizationService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@PostMapping("/create")
|
|
|
|
|
@ -82,7 +93,17 @@ public class PlanController {
|
|
|
|
|
//@PreAuthorize("@ss.hasPermission('mes:plan:query')")
|
|
|
|
|
public CommonResult<PageResult<PlanRespVO>> getPlanPage(@Valid PlanPageReqVO pageReqVO) {
|
|
|
|
|
PageResult<PlanRespVO> pageResult = planService.getPlanPage(pageReqVO);
|
|
|
|
|
return success(pageResult);
|
|
|
|
|
return success(new PageResult<>(buildVOList(pageResult.getList()), pageResult.getTotal()));
|
|
|
|
|
}
|
|
|
|
|
private List<PlanRespVO> buildVOList(List<PlanRespVO> list) {
|
|
|
|
|
if (CollUtil.isEmpty(list)) {
|
|
|
|
|
return Collections.emptyList();
|
|
|
|
|
}
|
|
|
|
|
Map<Long, OrganizationDO> organizationMap = organizationService.getOrganizationVOMap(
|
|
|
|
|
convertSet(list, PlanRespVO::getFeedingPipeline));
|
|
|
|
|
return BeanUtils.toBean(list, PlanRespVO.class, item -> {
|
|
|
|
|
MapUtils.findAndThen(organizationMap, item.getFeedingPipeline(), organization -> item.setFeedingPipelineName(organization.getName()));
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GetMapping("/export-excel")
|
|
|
|
|
@ -134,9 +155,13 @@ public class PlanController {
|
|
|
|
|
//@PreAuthorize("@ss.hasPermission('mes:plan:update')")
|
|
|
|
|
public CommonResult<Boolean> updatePlanStatus(@Valid @RequestBody PlanStatusUpdateVO statusUpdateVO) {
|
|
|
|
|
PlanDO planDO = planMapper.selectById(statusUpdateVO.getId());
|
|
|
|
|
// 试产
|
|
|
|
|
if ("pre".equals(statusUpdateVO.getCode())) {
|
|
|
|
|
planDO.setStatus(PlanStatusEnum.试产.getValue());
|
|
|
|
|
}
|
|
|
|
|
//开工
|
|
|
|
|
if ("start".equals(statusUpdateVO.getCode())) {
|
|
|
|
|
planDO.setStatus(PlanStatusEnum.开工.getValue());
|
|
|
|
|
planDO.setStatus(PlanStatusEnum.量产.getValue());
|
|
|
|
|
}
|
|
|
|
|
//暂停
|
|
|
|
|
else if ("pause".equals(statusUpdateVO.getCode())) {
|
|
|
|
|
@ -146,6 +171,20 @@ public class PlanController {
|
|
|
|
|
else if ("end".equals(statusUpdateVO.getCode())) {
|
|
|
|
|
planDO.setStatus(PlanStatusEnum.完工.getValue());
|
|
|
|
|
}
|
|
|
|
|
// 入库
|
|
|
|
|
else if ("store".equals(statusUpdateVO.getCode())) {
|
|
|
|
|
planDO.setStatus(PlanStatusEnum.已入库.getValue());
|
|
|
|
|
}
|
|
|
|
|
planMapper.updateById(planDO);
|
|
|
|
|
return success(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PutMapping("/updatePlanZjStatus")
|
|
|
|
|
@Operation(summary = "更新生产计划质检状态")
|
|
|
|
|
//@PreAuthorize("@ss.hasPermission('mes:plan:update')")
|
|
|
|
|
public CommonResult<Boolean> updatePlanZjStatus(@Valid @RequestBody PlanStatusUpdateVO statusUpdateVO) {
|
|
|
|
|
PlanDO planDO = planMapper.selectById(statusUpdateVO.getId());
|
|
|
|
|
planDO.setIsZj(true);
|
|
|
|
|
planMapper.updateById(planDO);
|
|
|
|
|
return success(true);
|
|
|
|
|
}
|
|
|
|
|
@ -156,7 +195,7 @@ public class PlanController {
|
|
|
|
|
//@PreAuthorize("@ss.hasPermission('mes:plan:query')")
|
|
|
|
|
public CommonResult<List<ErpProductRespVO>> getPlan() {
|
|
|
|
|
List<Integer> status = new ArrayList<>();
|
|
|
|
|
status.add(PlanStatusEnum.开工.getValue());
|
|
|
|
|
status.add(PlanStatusEnum.量产.getValue());
|
|
|
|
|
//status.add(PlanStatusEnum.完工.getValue());
|
|
|
|
|
List<ErpProductRespVO> proList = planService.getProductByPlanStatus(status);
|
|
|
|
|
return success(proList);
|
|
|
|
|
|