package com.chinaztt.mes.plan.controller; import cn.hutool.core.collection.CollectionUtil; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.chinaztt.mes.common.wrapper.QueryWrapperUtil; import com.chinaztt.mes.plan.dto.CustomerOrderDTO; import com.chinaztt.mes.plan.dto.MasterProductionScheduleDTO; import com.chinaztt.mes.plan.dto.MpsStructureComponentDTO; import com.chinaztt.mes.plan.dto.MpsStructureComponentTreeNode; import com.chinaztt.mes.plan.entity.MasterProductionSchedule; import com.chinaztt.mes.plan.entity.OperationTaskProduce; import com.chinaztt.mes.plan.service.MasterProductionScheduleService; import com.chinaztt.mes.technology.dto.StructureTree; import com.chinaztt.mes.technology.service.StructureService; import com.chinaztt.ztt.common.core.util.R; import com.chinaztt.ztt.common.log.annotation.SysLog; import com.chinaztt.ztt.common.security.annotation.Inner; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.AllArgsConstructor; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; import java.util.ArrayList; import java.util.List; /** * 主生产计划 * * @author cxf * @date 2020-09-23 14:42:39 */ @RestController @AllArgsConstructor @RequestMapping("/masterProductionSchedule") @Api(value = "masterProductionSchedule", tags = "主生产计划") public class MasterProductionScheduleController { private final StructureService structureService; private final MasterProductionScheduleService masterProductionScheduleService; /** * 分页查询 * * @param page 分页对象 * @param masterProductionScheduleDTO 计划 * @return R */ @ApiOperation(value = "分页查询", notes = "分页查询") @GetMapping("/page") @PreAuthorize("@pms.hasPermission('plan_masterproductionschedule_view')") public R getMasterProductionSchedulePage(Page page, MasterProductionScheduleDTO masterProductionScheduleDTO) { return R.ok(masterProductionScheduleService.getMasterProductionSchedulePage(page, QueryWrapperUtil.gen(masterProductionScheduleDTO))); } /** * 通过id查询计划 * * @param id id * @return R */ @ApiOperation(value = "通过id查询", notes = "通过id查询") @GetMapping("/{id}") @PreAuthorize("@pms.hasPermission('plan_masterproductionschedule_view')") public R getById(@PathVariable("id") Long id) { return R.ok(masterProductionScheduleService.getById(id)); } /** * 通过id查询计划 * * @param id id * @return R */ @ApiOperation(value = "通过id查询", notes = "通过id查询") @GetMapping("/getByIdExt/{id}") @PreAuthorize("@pms.hasPermission('plan_masterproductionschedule_view')") public R getByIdExt(@PathVariable("id") Long id) { return R.ok(masterProductionScheduleService.getByIdExt(id)); } /** * 新增计划 * * @param masterProductionSchedule 计划 * @return R */ @ApiOperation(value = "新增计划", notes = "新增计划") @SysLog("新增计划") @PostMapping @PreAuthorize("@pms.hasPermission('plan_masterproductionschedule_add')") public R save(@RequestBody MasterProductionSchedule masterProductionSchedule) { return masterProductionScheduleService.doAdd(masterProductionSchedule); } /** * 修改计划 * * @param masterProductionSchedule 计划 * @return R */ @ApiOperation(value = "修改计划", notes = "修改计划") @SysLog("修改计划") @PutMapping @PreAuthorize("@pms.hasPermission('plan_masterproductionschedule_edit')") public R updateById(@RequestBody MasterProductionSchedule masterProductionSchedule) { return R.ok(masterProductionScheduleService.updateById(masterProductionSchedule)); } /** * 通过id删除计划 * * @param id id * @return R */ @ApiOperation(value = "通过id删除计划", notes = "通过id删除计划") @SysLog("通过id删除计划") @DeleteMapping("/{id}") @PreAuthorize("@pms.hasPermission('plan_masterproductionschedule_del')") public R removeById(@PathVariable Long id) { return R.ok(masterProductionScheduleService.removeById(id)); } /** * 通过id加载主生产计划来源 * * @param id * @return */ @ApiOperation(value = "通过id加载主生产计划来源", notes = "通过id加载主生产计划来源") @GetMapping("/loadMasterPlanSource/{id}") @PreAuthorize("@pms.hasPermission('plan_masterproductionschedule_view')") public R loadMasterPlanSource(@PathVariable Long id) { return R.ok(masterProductionScheduleService.loadMasterPlanSourceById(id)); } /** * 通过id加载主生产计划来源(客户订单) * * @param id * @return */ @ApiOperation(value = "通过id加载主生产计划来源(客户订单)", notes = "通过id加载主生产计划来源(客户订单)") @GetMapping("/loadMasterPlanSourceByCustomer/{id}") public R loadMasterPlanSourceByCustomer(@PathVariable Long id) { return R.ok(masterProductionScheduleService.loadMasterPlanSourceByCustomer(id)); } /** * 通过id加载下发的订单 * * @param id * @return */ @ApiOperation(value = "通过id加载下发的订单", notes = "通过id加载下发的订单") @GetMapping("/loadOrder/{id}") @PreAuthorize("@pms.hasPermission('plan_masterproductionschedule_view')") public R loadOrder(@PathVariable Long id) { return R.ok(masterProductionScheduleService.loadOrder(id)); } /** * 修改来源的计划数量 * * @param customerOrderDTO * @return */ @ApiOperation(value = "修改来源的计划数量", notes = "修改来源的计划数量") @PostMapping("/updateQtyPlaned") public R updateQtyPlaned(@RequestBody CustomerOrderDTO customerOrderDTO) { return R.ok(masterProductionScheduleService.updateQtyPlaned(customerOrderDTO)); } /** * 通过id查询bom结构 * * @param id * @return */ @ApiOperation(value = "通过id查询bom结构", notes = "通过id查询bom结构") @GetMapping("/getMpsStructureComponent/{id}/{partId}") public R getMpsStructureComponentByMpsId(@PathVariable("id") Long id, @PathVariable("partId") Long partId) { List mpsStructureComponentTree = masterProductionScheduleService.getMpsStructureComponentByMpsId(id); if (CollectionUtil.isNotEmpty(mpsStructureComponentTree)) { return R.ok(mpsStructureComponentTree); } else { List structureTreeList = null; StructureTree structureTree = structureService.getMasterTreeByPartId(partId); if (structureTree != null) { structureTreeList = new ArrayList(); structureTreeList.add(structureTree); } return R.ok(structureTreeList); } } /** * 保存bom结构 * * @param list * @param mpsId * @return */ @ApiOperation(value = "保存bom结构", notes = "保存bom结构") @PostMapping("/saveMpsStructureComponent/{mpsId}") public R saveMpsStructureComponent(@RequestBody List list, @PathVariable Long mpsId) { return R.ok(masterProductionScheduleService.saveMpsStructureComponent(list, mpsId)); } /** * 通过id删除bom结构 * * @param id id * @return R */ @ApiOperation(value = "通过id删除bom结构", notes = "通过id删除bom结构") @SysLog("通过id删除bom结构") @DeleteMapping("deleteMpsStructureComponent/{id}") public R deleteMpsStructureComponentById(@PathVariable Long id) { return R.ok(masterProductionScheduleService.deleteMpsStructureComponentById(id)); } /** * 新增bom结构 * * @param mpsStructureComponentDTO * @param mpsId * @return */ @ApiOperation(value = "新增bom结构", notes = "新增bom结构") @PostMapping("/insertMpsStructureComponent/{mpsId}") public R insertMpsStructureComponent(@RequestBody MpsStructureComponentDTO mpsStructureComponentDTO, @PathVariable Long mpsId) { return R.ok(masterProductionScheduleService.insertMpsStructureComponent(mpsStructureComponentDTO, mpsId)); } /** * 修改bom结构 * * @param mpsStructureComponentDTO * @return */ @ApiOperation(value = "修改bom结构", notes = "修改bom结构") @PostMapping("/updateMpsStructureComponent") public R updateMpsStructureComponent(@RequestBody MpsStructureComponentDTO mpsStructureComponentDTO) { return R.ok(masterProductionScheduleService.updateMpsStructureComponent(mpsStructureComponentDTO)); } /** * 状态变更 * * @param ids * @return R */ @ApiOperation(value = "状态变更", notes = "状态变更") @SysLog("状态变更") @PostMapping("/changeState/{event}") public R changeMarkPlanned(@RequestBody List ids, @PathVariable String event) { return R.ok(masterProductionScheduleService.changeState(ids, event)); } /** * Description: 绑定工艺文件 * * @param: mpsRequirementsDTOList * @return: R */ @ApiOperation(value = "绑定工艺文件", notes = "绑定工艺文件") @PostMapping("/handleDocument/{docId}") public R handleDocument(@RequestBody List ids, @PathVariable Long docId) { return masterProductionScheduleService.handleDocument(ids, docId); } /** * Description: 取消关联工艺文件 * * @param: mpsRequirementsDTOList * @return: R */ @ApiOperation(value = "取消绑定工艺文件", notes = "取消绑定工艺文件") @PostMapping("/rejectHandleDocument") public R rejectHandleDocument(@RequestBody List ids) { return masterProductionScheduleService.rejectHandleDocument(ids); } /** * OA对接 * * @param id */ @GetMapping("/oa/{id}") public R oa(@PathVariable("id") Long id) { return masterProductionScheduleService.oa(id); } /** * 手动修改审核状态 * * @param id id * @param status 状态 * @return */ @GetMapping("/changeAudit/{id}/{status}") public R oa(@PathVariable("id") Long id, @PathVariable("status") String status) { return masterProductionScheduleService.changeAudit(id, status); } /** * 根据零件号查询库存可用性计划 * * @param partNo 零件号 * @return */ @GetMapping("/queryInventUseablePlanStd") public R queryInventUseablePlanStd(String partNo) { return masterProductionScheduleService.queryInventUseablePlanStd(partNo); } /** * 根据工艺文件id查看工艺文件是否对接到ifs * * @param id * @return */ @GetMapping("/checkIfsSync/{id}") public R checkIfsSync(@PathVariable("id") Long id) { return masterProductionScheduleService.checkIfsSync(id); } /** * 查询计划半成品数据 * * @param id 主计划的id * @param operationTaskProduceList 选择的段长数据 * @return */ @PostMapping("/getTheoryQuantity/{id}") public R getTheoryQuantity(@PathVariable("id") Long id, @RequestBody List operationTaskProduceList) { return masterProductionScheduleService.getTheoryQuantity(id, operationTaskProduceList); } /** * 通过主计划号查询 * @param mpsNo * @return */ @ApiOperation(value = "通过主计划号查询", notes = "通过主计划号查询") @GetMapping("/getByMpsNo") public R getByCustomerOrderNo (@RequestParam("mpsNo") String mpsNo){ return R.ok(masterProductionScheduleService.getOne(Wrappers.lambdaQuery() .eq(MasterProductionSchedule::getMpsNo, mpsNo))); } @ApiOperation(value = "通过主计划查询ifs库存生产采购计划", notes = "通过主计划查询ifs库存生产采购计划") @PostMapping("/addPlanPurchasing") @Inner(value = false) public R addPlanPurchasing(@RequestParam(required = false) ListmasterProductionSchedules){ return R.ok(masterProductionScheduleService.addPlanPurchasing(masterProductionSchedules)); } }