Commit 703fa953 authored by 李驰骋's avatar 李驰骋

Merge remote-tracking branch 'origin/dev' into dev

# Conflicts:
#	mes/src/main/java/com/ximai/mes/pro/mapper/task/ProTaskWorkunitMapper.java
parents 478fb472 3cc641d9
......@@ -230,3 +230,4 @@ delete.data.error.occupied = \u8be5\u6570\u636e\u5df2\u7ecf\u88ab\u5173\u8054\u4
#权限复制,复制用户和被复制用户重叠
user.copyuser.repeat = \u590d\u5236\u7528\u6237\u4e2d\u5b58\u5728\u60a8\u52fe\u9009\u7684\u88ab\u590d\u5236\u7528\u6237\uff0c\u7528\u6237\u540d :{0}
user.lack.of.permissions = \u5c97\u4f4d\u8d44\u6e90\u6216\u89d2\u8272\u4e3a\u7a7a\uff0c\u60a8\u786e\u5b9a\u9700\u8981\u590d\u5236\u5417\uff1f
rollback.schedule.status.err = \u4efb\u52a1\u7ec4\u5408\u5df2\u7ecf\u6709\u5904\u4e8e\u5f00\u5de5\u6216\u8005\u62a5\u5de5\u8bb0\u5f55:{0}
\ No newline at end of file
......@@ -220,3 +220,4 @@ delete.data.error.occupied = The data that needs to be deleted has been used
user.copyuser.repeat = The employee with copied permission exists among the employees with copied permission :{0}
user.lack.of.permissions = Job resources or roles are empty, are you sure you need to copy them?
rollback.schedule.status.err = The order task has started :{0};
\ No newline at end of file
......@@ -229,3 +229,4 @@ md.workUnit.error.workunitCode.unique = \u0E2B\u0E21\u0E32\u0E22\u0E40\u0E25\u0E
delete.data.error.occupied = \u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e17\u0e35\u0e48\u0e15\u0e49\u0e2d\u0e07\u0e01\u0e32\u0e23\u0e25\u0e1a\u0e44\u0e14\u0e49\u0e16\u0e39\u0e01\u0e43\u0e0a\u0e49\u0e44\u0e1b\u0e41\u0e25\u0e49\u0e27
user.copyuser.repeat = \u0e1e\u0e19\u0e31\u0e01\u0e07\u0e32\u0e19\u0e17\u0e35\u0e48\u0e16\u0e39\u0e01\u0e04\u0e31\u0e14\u0e25\u0e2d\u0e01\u0e2a\u0e34\u0e17\u0e18\u0e34\u0e4c\u0e21\u0e35\u0e2d\u0e22\u0e39\u0e48\u0e43\u0e19\u0e1e\u0e19\u0e31\u0e01\u0e07\u0e32\u0e19\u0e17\u0e35\u0e48\u0e16\u0e39\u0e01\u0e04\u0e31\u0e14\u0e25\u0e2d\u0e01\u0e2a\u0e34\u0e17\u0e18\u0e34\u0e4c :{0}
user.lack.of.permissions = \u0e17\u0e23\u0e31\u0e1e\u0e22\u0e32\u0e01\u0e23\u0e42\u0e1e\u0e2a\u0e15\u0e4c\u0e2b\u0e23\u0e37\u0e2d\u0e1a\u0e17\u0e1a\u0e32\u0e17\u0e27\u0e48\u0e32\u0e07\u0e40\u0e1b\u0e25\u0e48\u0e32\u0e04\u0e38\u0e13\u0e41\u0e19\u0e48\u0e43\u0e08\u0e2b\u0e23\u0e37\u0e2d\u0e44\u0e21\u0e48\u0e27\u0e48\u0e32\u0e04\u0e38\u0e13\u0e08\u0e33\u0e40\u0e1b\u0e47\u0e19\u0e15\u0e49\u0e2d\u0e07\u0e04\u0e31\u0e14\u0e25\u0e2d\u0e01\u003f
rollback.schedule.status.err = \u0e20\u0e32\u0e23\u0e01\u0e34\u0e08\u0e01\u0e32\u0e23\u0e2a\u0e31\u0e48\u0e07\u0e0b\u0e37\u0e49\u0e2d\u0e44\u0e14\u0e49\u0e40\u0e23\u0e34\u0e48\u0e21\u0e02\u0e36\u0e49\u0e19\u0e41\u0e25\u0e49\u0e27:{0}
\ No newline at end of file
......@@ -223,3 +223,4 @@ delete.data.error.occupied = \u8be5\u6570\u636e\u5df2\u7ecf\u88ab\u5173\u8054\u4
user.copyuser.repeat = \u590d\u5236\u7528\u6237\u4e2d\u5b58\u5728\u60a8\u52fe\u9009\u7684\u88ab\u590d\u5236\u7528\u6237\uff0c\u7528\u6237\u540d :{0}
user.lack.of.permissions = \u5c97\u4f4d\u8d44\u6e90\u6216\u89d2\u8272\u4e3a\u7a7a\uff0c\u60a8\u786e\u5b9a\u9700\u8981\u590d\u5236\u5417\uff1f
rollback.schedule.status.err = \u4efb\u52a1\u7ec4\u5408\u5df2\u7ecf\u6709\u5904\u4e8e\u5f00\u5de5\u6216\u8005\u62a5\u5de5\u8bb0\u5f55:{0}
\ No newline at end of file
package com.ximai.mes.pro.controller.proWorkOrder; import cn.hutool.core.bean.BeanUtil;import cn.hutool.core.collection.CollUtil;import cn.hutool.core.collection.CollectionUtil;import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;import com.ximai.common.annotation.Log;import com.ximai.common.constant.UserConstants;import com.ximai.common.core.controller.BaseController;import com.ximai.common.core.domain.AjaxResult;import com.ximai.common.core.page.TableDataInfo;import com.ximai.common.enums.BusinessType;import com.ximai.common.exception.ServiceException;import com.ximai.common.utils.MessageUtils;import com.ximai.common.utils.data.ExceptionUtil;import com.ximai.common.utils.data.StringUtils;import com.ximai.common.utils.excel.ExcelWriter;import com.ximai.mes.constant.WorkorderStatusEnum;import com.ximai.mes.md.domain.MdProductBom;import com.ximai.mes.md.service.IMdBaseInfoService;import com.ximai.mes.md.service.IMdProductBomService;import com.ximai.mes.pro.domain.ProWorkorderBomm;import com.ximai.mes.pro.domain.proWorkOrder.ProWorkOrderSoDirective;import com.ximai.mes.pro.domain.proWorkOrder.ProWorkOrderSoSizeItem;import com.ximai.mes.pro.domain.proWorkOrder.ProWorkorder;import com.ximai.mes.pro.domain.task.ProPackagePrintRecord;import com.ximai.mes.pro.domain.task.ProTask;import com.ximai.mes.pro.domain.vo.ProPackagePrintResult;import com.ximai.mes.pro.domain.vo.ProWorkOrderProcessVo;import com.ximai.mes.pro.domain.vo.ProWorkorderQuery;import com.ximai.mes.pro.domain.vo.ProWorkorderVo;import com.ximai.mes.pro.domain.vo.proWorkOrder.BuildPackageParams2;import com.ximai.mes.pro.domain.vo.proWorkOrder.ProWorkorderPrintTab;import com.ximai.mes.pro.domain.vo.proWorkOrder.WorkorderProofMakeProduction;import com.ximai.mes.pro.dto.ProWorkorderExcelExport;import com.ximai.mes.pro.mapper.proWorkOrder.ProWorkOrderProcessMapper;import com.ximai.mes.pro.service.IProWorkorderBomService;import com.ximai.mes.pro.service.proWorkOrder.IProWorkOrderSoDirectiveService;import com.ximai.mes.pro.service.proWorkOrder.IProWorkOrderSoSizeItemService;import com.ximai.mes.pro.service.proWorkOrder.IProWorkorderService;import com.ximai.mes.pro.service.task.IProTaskService;import com.ximai.system.strategy.AutoCodeUtil;import io.swagger.annotations.ApiOperation;import org.aspectj.bridge.Message;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.security.access.prepost.PreAuthorize;import org.springframework.transaction.annotation.Transactional;import org.springframework.util.CollectionUtils;import org.springframework.web.bind.annotation.*;import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource;import javax.servlet.http.HttpServletResponse;import java.io.IOException;import java.math.BigDecimal;import java.util.*; /** * 生产工单Controller * * @date 2022-05-09 */@RestController@RequestMapping("/mes/pro/workorder")public class ProWorkorderController extends BaseController { @Autowired private IProWorkorderService proWorkorderService; @Resource private ProWorkOrderProcessMapper proWorkOrderProcessMapper; @Autowired private IProWorkorderBomService proWorkorderBomService; @Autowired private IMdProductBomService mdProductBomService; @Autowired private IProTaskService proTaskService; @Autowired private IProWorkOrderSoSizeItemService proWorkOrderSoSizeItemService; @Autowired private IProWorkOrderSoDirectiveService proWorkOrderSoDirectiveService; @Autowired private IMdBaseInfoService mdBaseInfoService; @Autowired AutoCodeUtil autoCodeUtil; /** * 查询生产工单列表 */ @ApiOperation("工单查询") @GetMapping("/list") public TableDataInfo<ProWorkorder> list(ProWorkorderQuery proWorkorder) { startPage(); List<ProWorkorder> list = proWorkorderService.selectProWorkorderList(proWorkorder); return getDataTable(list); } /** * 查询待排产生产工单列表 */ @ApiOperation("查询待排产生产工单列表") @GetMapping("/scheduleList") public TableDataInfo<ProWorkorder> scheduleList(ProWorkorderQuery proWorkorder) { startPage(); QueryWrapper<ProWorkorder> query = new QueryWrapper<>(); query.like(StringUtils.isNotEmpty(proWorkorder.getOrderCode()), "t1.order_code", proWorkorder.getOrderCode()); query.like(StringUtils.isNotEmpty(proWorkorder.getOrderSerial()), "t1.order_serial", proWorkorder.getOrderSerial()); query.like(StringUtils.isNotEmpty(proWorkorder.getCustomerProjectNo()), "t1.customer_project_no", proWorkorder.getCustomerProjectNo()); query.like(StringUtils.isNotEmpty(proWorkorder.getWorkorderCode()), "t1.workorder_code", proWorkorder.getWorkorderCode()); query.like(StringUtils.isNotEmpty(proWorkorder.getProductCode()), "t1.product_code", proWorkorder.getProductCode()); query.like(StringUtils.isNotEmpty(proWorkorder.getProductName()), "t1.product_name", proWorkorder.getProductName()); query.in(StringUtils.isNotEmpty(proWorkorder.getStatusArr()), "t1.status", proWorkorder.getStatusArr()); query.in("t1.status", new String[]{WorkorderStatusEnum.PREPARE.getValue(), WorkorderStatusEnum.PUBLISHED.getValue(), WorkorderStatusEnum.ISSUED.getValue()}); query.gt("t1.quantity-t1.quantity_scheduled", 0); query.orderByAsc("request_date","t1.order_code"); List<ProWorkorder> list = proWorkorderService.selectListByQw(query); return getDataTable(list); } /** * 查询生产工单列表 */ @ApiOperation("查询工单打印数据") @GetMapping("/printInfo") public AjaxResult printInfo(ProWorkorderQuery proWorkorder) { List<ProWorkorderPrintTab> list = proWorkorderService.selectWorkorderPrintTab(proWorkorder); return AjaxResult.success(list); } @ApiOperation("查询生产工单列表,并联查指令与SIZE数据") @GetMapping("/listWithSizeAndDirective") public TableDataInfo<ProWorkorderVo> listWithSizeAndDirective(ProWorkorderQuery proWorkorder) { List<ProWorkorderVo> list = proWorkorderService.getFeedBackRecord(proWorkorder); return getDataTable(list); } @ApiOperation("工单关联属性查询") @GetMapping("/linkInfo") public AjaxResult<ProWorkorderVo> linkInfo(Long workorderId) { ProWorkorderVo rst = new ProWorkorderVo(); ProWorkorder proWorkorder = proWorkorderService.selectWorkorderById(workorderId); BeanUtil.copyProperties(proWorkorder, rst); ProWorkOrderSoDirective directiveQuery = new ProWorkOrderSoDirective(); directiveQuery.setWorkorderId(proWorkorder.getWorkorderId()); List<ProWorkOrderSoDirective> directiveList = proWorkOrderSoDirectiveService.selectProWorkOrderSoDirectiveList(directiveQuery); ProWorkOrderSoSizeItem sizeQuery = new ProWorkOrderSoSizeItem(); sizeQuery.setWorkorderId(proWorkorder.getWorkorderId()); List<ProWorkOrderSoSizeItem> sizeList = proWorkOrderSoSizeItemService.selectProWorkOrderSoSizeItemList(sizeQuery); rst.setSaleDirectiveList(directiveList); rst.setSizeList(sizeList); if (directiveList.size() == 1) { if (directiveList.get(0).getPackNum() != null && rst.getUsagePackNum() == null) { rst.setUsagePackNum(directiveList.get(0).getPackNum().intValue()); } } if (proWorkorder.getUsageEncasementNum() != null) { rst.setUsageEncasementNum(proWorkorder.getUsageEncasementNum()); } if (proWorkorder.getUsagePackNum() != null) { rst.setUsagePackNum(proWorkorder.getUsagePackNum()); } return AjaxResult.success(rst); } @Log(title = "用户管理", businessType = BusinessType.IMPORT) @PreAuthorize("@ss.hasPermi('system:user:import')") @PostMapping("/importData") public AjaxResult importData(MultipartFile file) throws Exception { String message = proWorkorderService.importWorkOrder(file); return AjaxResult.success(message); } @GetMapping(value = "/getChildWorkorderCode/{workOrderCode}") public AjaxResult getChildOrderCode(@PathVariable("workOrderCode") String workorderCode) { if (workorderCode == null || "".equals(workorderCode)) { throw new RuntimeException("工单编码传递为空"); } Integer i = proWorkorderService.countByParentCode(workorderCode); // 补料单生成编号 Map<String, String> map = new HashMap<>(); map.put("code", workorderCode + "-" + ((i == null ? 0 : i) + 1)); return AjaxResult.success(map); } @PostMapping("/importTemplate") public void importTemplate(HttpServletResponse response) throws IOException { proWorkorderService.importTemplate(response); } /** * 获取生产工单详细信息 */ @GetMapping(value = "/{workorderId}") public AjaxResult getInfo(@PathVariable("workorderId") Long workorderId) { return AjaxResult.success(proWorkorderService.selectProWorkorderByWorkorderId(workorderId)); } /** * 获取生产工单详细信息 */ @PostMapping(value = "/getQcCondition") public AjaxResult getQcCondition(@RequestBody ProWorkorder proWorkorder) { QueryWrapper<ProWorkorder> queryWrapper = new QueryWrapper<>(); queryWrapper.eq(StringUtils.isNotEmpty(proWorkorder.getWorkorderCode()), "workorder_code", proWorkorder.getWorkorderCode()); queryWrapper.eq(StringUtils.isNotEmpty(proWorkorder.getArrangeCode()), "arrange_code", proWorkorder.getArrangeCode()); List<ProWorkorder> proWorkorders = proWorkorderService.selectListByQw(queryWrapper); ExceptionUtil.checkTrueThrowException(CollectionUtil.isEmpty(proWorkorders), MessageUtils.message("pro.workOrder.error.not.exist")); ProWorkorder proWorkorder1 = proWorkorders.get(0); List<ProWorkOrderProcessVo> proWorkOrderProcessList = proWorkOrderProcessMapper.selectProWorkOrderProcessByWorkOrderId(proWorkorder1.getWorkorderId()); ProWorkorderVo proWorkorderVo = proWorkorder1.deepCopyObj(ProWorkorderVo.class); proWorkorderVo.setProcessList(proWorkOrderProcessList); return AjaxResult.success(proWorkorderVo); } /** * 新增生产工单 */ @ApiOperation("生产工单新增") @PreAuthorize("@ss.hasPermi('mes:pro:workorder:add')") @Log(title = "生产工单", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@RequestBody ProWorkorderVo proWorkorderVo) { ProWorkorder proWorkorder = proWorkorderVo.deepCopyObj(ProWorkorder.class); ExceptionUtil.checkTrueThrowException(!proWorkorderService.checkWorkorderIsExsit(proWorkorder), MessageUtils.message("pro.workOrder.error.workOrderNo.exist")); ProWorkorder proWorkorderNew = proWorkorderService.insertObj(proWorkorder, proWorkorderVo); return AjaxResult.success(proWorkorderNew.getWorkorderId()); } /** * 修改生产工单 */ @PreAuthorize("@ss.hasPermi('mes:pro:workorder:edit')") @Log(title = "生产工单", businessType = BusinessType.UPDATE) @PutMapping("/close") public AjaxResult close(@RequestBody List<ProWorkorderVo> proWorkorderVos) { for (ProWorkorderVo proWorkorderVo : proWorkorderVos) { proWorkorderService.updateObject(proWorkorderVo); } return AjaxResult.success(); } @PreAuthorize("@ss.hasPermi('mes:pro:workorder:add')") @Log(title = "生产补单工单", businessType = BusinessType.INSERT) @PostMapping("/addComplements") public AjaxResult addComplements(@RequestBody ProWorkorderVo proWorkorderVo) { proWorkorderService.addComplements(proWorkorderVo); return AjaxResult.success(); } /** * 修改生产工单 */ @ApiOperation("生产工单修改") @PreAuthorize("@ss.hasPermi('mes:pro:workorder:edit')") @Log(title = "生产工单", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@RequestBody ProWorkorderVo proWorkorderVo) { int ret = proWorkorderService.updateObject(proWorkorderVo); return toAjax(ret); } /** * 修改生产工单 */ @ApiOperation("生产工单修改生产版本以及工艺路线") @PreAuthorize("@ss.hasPermi('mes:pro:workorder:edit')") @Log(title = "生产工单", businessType = BusinessType.UPDATE) @PutMapping("/updateWorkProcess") public AjaxResult updateWorkProcess(@RequestBody ProWorkorderVo proWorkorderVo) { int ret = proWorkorderService.updateWorkProcess(proWorkorderVo); return toAjax(ret); } /** * 删除生产工单 */ @PreAuthorize("@ss.hasPermi('mes:pro:workorder:remove')") @Log(title = "生产工单", businessType = BusinessType.DELETE) @DeleteMapping("/{workorderIds}") public AjaxResult remove(@PathVariable Long[] workorderIds) { for (Long id : workorderIds) { ProWorkorderVo workorder = proWorkorderService.selectProWorkorderByWorkorderId(id); if (!UserConstants.ORDER_STATUS_PREPARE.equals(workorder.getStatus())) { return AjaxResult.error(MessageUtils.message("pro.workOrder.error.limit.delete")); } proWorkorderBomService.deleteProWorkorderBomByWorkorderId(id); } return toAjax(proWorkorderService.deleteProWorkorderByWorkorderIds(workorderIds)); } /** * 获取当前工单的物料需求清单 */ @PreAuthorize("@ss.hasPermi('mes:pro:workorder:list')") @GetMapping("/listItems") public TableDataInfo listItemss(ProWorkorder proWorkorder) { List<MdProductBom> result = new ArrayList<MdProductBom>(); ProWorkorderBomm param = new ProWorkorderBomm(); param.setWorkorderId(proWorkorder.getWorkorderId()); List<ProWorkorderBomm> boms = proWorkorderBomService.selectProWorkorderBomList(param); if (!CollectionUtils.isEmpty(boms)) { for (ProWorkorderBomm bom : boms ) { MdProductBom theBom = new MdProductBom(); theBom.setBomItemId(bom.getItemId()); result.addAll(getBoms(theBom, bom.getQuantity(), 0)); } } return getDataTable(result); } private List<MdProductBom> getBoms(MdProductBom item, BigDecimal quantity, int count) { MdProductBom param = new MdProductBom(); List<MdProductBom> results = new ArrayList<MdProductBom>(); if (count > 20) { return results; } param.setItemId(item.getBomItemId()); List<MdProductBom> boms = mdProductBomService.selectMdProductBomList(param); if (CollUtil.isNotEmpty(boms)) { //最多20层依赖 count++; for (MdProductBom bomItem : boms) { bomItem.setQuantity(quantity.multiply(bomItem.getQuantity())); results.addAll(getBoms(bomItem, bomItem.getQuantity(), count)); } } else { results.add(item); } return results; } /** * 完成工单 * * @param workorderId * @return */ @PreAuthorize("@ss.hasPermi('mes:pro:workorder:edit')") @Log(title = "生产工单", businessType = BusinessType.UPDATE) @Transactional @PutMapping("/{workorderId}") public AjaxResult dofinish(@PathVariable Long workorderId) { ProWorkorderVo proWorkorderVo = proWorkorderService.selectProWorkorderByWorkorderId(workorderId); ProWorkorder workorder = proWorkorderVo.deepCopyObj(ProWorkorder.class); //将此工单下所有的生产任务状态设置为已完成 ProTask param = new ProTask(); param.setArrangeCode(workorder.getArrangeCode()); List<ProTask> tasks = proTaskService.selectProTaskList(param); if (!CollectionUtils.isEmpty(tasks)) { for (ProTask task : tasks) { task.setStatus(UserConstants.ORDER_STATUS_FINISHED); proTaskService.updateProTask(task); } } workorder.setStatus(UserConstants.ORDER_STATUS_FINISHED); //更新工单的状态 proWorkorderService.updateProWorkorder(workorder); return AjaxResult.success(); } /** * 生产工单工装量具齐套检查 */ @PostMapping(value = "/checkToolNum") public void checkToolNum(@RequestBody ProWorkorderVo proWorkorderVo) { proWorkorderService.checkToolNum(proWorkorderVo.getWorkorderIds()); } /** * 生产工单将草稿状态改为已确认 */ @GetMapping(value = "/setStatus/{workorderId}") public void setStaus(@PathVariable("workorderId") Long workorderId) { ProWorkorder workorder = proWorkorderService.selectWorkorderById(workorderId); proWorkorderService.updateWorkorderState(workorder, WorkorderStatusEnum.PUBLISHED); } @PostMapping(value = "/proofMakeProduction") public AjaxResult proofMakeProduction(@RequestBody WorkorderProofMakeProduction production) { proWorkorderService.proofMakeProduction(production); return AjaxResult.success(); } /** * 导出生产工单列表 */ @PreAuthorize("@ss.hasPermi('mes:pro:workorder:export')") @Log(title = "生产工单", businessType = BusinessType.EXPORT) @PostMapping("/export") public void export(HttpServletResponse response, ProWorkorderQuery proWorkorder) throws IOException { List<ProWorkorder> list = proWorkorderService.selectProWorkorderList(proWorkorder); List<ProWorkorderExcelExport> exportList = BeanUtil.copyToList(list, ProWorkorderExcelExport.class); ExcelWriter.write(response,ProWorkorderExcelExport.class,exportList); } /** * 同步ERP数据 */ @PreAuthorize("@ss.hasPermi('mes:pro:workorder:sync')") @Log(title = "工单同步", businessType = BusinessType.SYNC_DATA) @PostMapping("/syncData") public AjaxResult syncData() { proWorkorderService.syncErpData(); return AjaxResult.success(); } }
\ No newline at end of file
package com.ximai.mes.pro.controller.proWorkOrder; import cn.hutool.core.bean.BeanUtil;import cn.hutool.core.collection.CollUtil;import cn.hutool.core.collection.CollectionUtil;import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;import com.ximai.common.annotation.Log;import com.ximai.common.constant.UserConstants;import com.ximai.common.core.controller.BaseController;import com.ximai.common.core.domain.AjaxResult;import com.ximai.common.core.page.TableDataInfo;import com.ximai.common.enums.BusinessType;import com.ximai.common.exception.ServiceException;import com.ximai.common.utils.MessageUtils;import com.ximai.common.utils.data.ExceptionUtil;import com.ximai.common.utils.data.StringUtils;import com.ximai.common.utils.excel.ExcelWriter;import com.ximai.mes.constant.WorkorderStatusEnum;import com.ximai.mes.md.domain.MdProductBom;import com.ximai.mes.md.service.IMdBaseInfoService;import com.ximai.mes.md.service.IMdProductBomService;import com.ximai.mes.pro.domain.ProWorkorderBomm;import com.ximai.mes.pro.domain.proWorkOrder.ProWorkOrderSoDirective;import com.ximai.mes.pro.domain.proWorkOrder.ProWorkOrderSoSizeItem;import com.ximai.mes.pro.domain.proWorkOrder.ProWorkorder;import com.ximai.mes.pro.domain.task.ProPackagePrintRecord;import com.ximai.mes.pro.domain.task.ProTask;import com.ximai.mes.pro.domain.vo.ProPackagePrintResult;import com.ximai.mes.pro.domain.vo.ProWorkOrderProcessVo;import com.ximai.mes.pro.domain.vo.ProWorkorderQuery;import com.ximai.mes.pro.domain.vo.ProWorkorderVo;import com.ximai.mes.pro.domain.vo.proWorkOrder.BuildPackageParams2;import com.ximai.mes.pro.domain.vo.proWorkOrder.ProWorkorderPrintTab;import com.ximai.mes.pro.domain.vo.proWorkOrder.WorkorderProofMakeProduction;import com.ximai.mes.pro.dto.ProWorkorderExcelExport;import com.ximai.mes.pro.mapper.proWorkOrder.ProWorkOrderProcessMapper;import com.ximai.mes.pro.service.IProWorkorderBomService;import com.ximai.mes.pro.service.proWorkOrder.IProWorkOrderSoDirectiveService;import com.ximai.mes.pro.service.proWorkOrder.IProWorkOrderSoSizeItemService;import com.ximai.mes.pro.service.proWorkOrder.IProWorkorderService;import com.ximai.mes.pro.service.task.IProTaskService;import com.ximai.system.strategy.AutoCodeUtil;import io.swagger.annotations.ApiOperation;import org.aspectj.bridge.Message;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.security.access.prepost.PreAuthorize;import org.springframework.transaction.annotation.Transactional;import org.springframework.util.CollectionUtils;import org.springframework.web.bind.annotation.*;import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource;import javax.servlet.http.HttpServletResponse;import java.io.IOException;import java.math.BigDecimal;import java.util.*; /** * 生产工单Controller * * @date 2022-05-09 */@RestController@RequestMapping("/mes/pro/workorder")public class ProWorkorderController extends BaseController { @Autowired private IProWorkorderService proWorkorderService; @Resource private ProWorkOrderProcessMapper proWorkOrderProcessMapper; @Autowired private IProWorkorderBomService proWorkorderBomService; @Autowired private IMdProductBomService mdProductBomService; @Autowired private IProTaskService proTaskService; @Autowired private IProWorkOrderSoSizeItemService proWorkOrderSoSizeItemService; @Autowired private IProWorkOrderSoDirectiveService proWorkOrderSoDirectiveService; @Autowired private IMdBaseInfoService mdBaseInfoService; @Autowired AutoCodeUtil autoCodeUtil; /** * 查询生产工单列表 */ @ApiOperation("工单查询") @GetMapping("/list") public TableDataInfo<ProWorkorder> list(ProWorkorderQuery proWorkorder) { startPage(); List<ProWorkorder> list = proWorkorderService.selectProWorkorderList(proWorkorder); return getDataTable(list); } /** * 查询待排产生产工单列表 */ @ApiOperation("查询待排产生产工单列表") @GetMapping("/scheduleList") public TableDataInfo<ProWorkorder> scheduleList(ProWorkorderQuery proWorkorder) { startPage(); QueryWrapper<ProWorkorder> query = new QueryWrapper<>(); query.like(StringUtils.isNotEmpty(proWorkorder.getOrderCode()), "t1.order_code", proWorkorder.getOrderCode()); query.like(StringUtils.isNotEmpty(proWorkorder.getOrderSerial()), "t1.order_serial", proWorkorder.getOrderSerial()); query.like(StringUtils.isNotEmpty(proWorkorder.getCustomerProjectNo()), "t1.customer_project_no", proWorkorder.getCustomerProjectNo()); query.like(StringUtils.isNotEmpty(proWorkorder.getWorkorderCode()), "t1.workorder_code", proWorkorder.getWorkorderCode()); query.like(StringUtils.isNotEmpty(proWorkorder.getProductCode()), "t1.product_code", proWorkorder.getProductCode()); query.like(StringUtils.isNotEmpty(proWorkorder.getProductName()), "t1.product_name", proWorkorder.getProductName()); query.in(StringUtils.isNotEmpty(proWorkorder.getStatusArr()), "t1.status", proWorkorder.getStatusArr()); query.in("t1.status", new String[]{WorkorderStatusEnum.PREPARE.getValue(), WorkorderStatusEnum.PUBLISHED.getValue(), WorkorderStatusEnum.ISSUED.getValue(),WorkorderStatusEnum.PRODUCING.getValue()}); query.gt("t1.quantity-t1.quantity_scheduled", 0); query.orderByAsc("request_date","t1.order_code"); List<ProWorkorder> list = proWorkorderService.selectListByQw(query); return getDataTable(list); } /** * 查询生产工单列表 */ @ApiOperation("查询工单打印数据") @GetMapping("/printInfo") public AjaxResult printInfo(ProWorkorderQuery proWorkorder) { List<ProWorkorderPrintTab> list = proWorkorderService.selectWorkorderPrintTab(proWorkorder); return AjaxResult.success(list); } @ApiOperation("查询生产工单列表,并联查指令与SIZE数据") @GetMapping("/listWithSizeAndDirective") public TableDataInfo<ProWorkorderVo> listWithSizeAndDirective(ProWorkorderQuery proWorkorder) { List<ProWorkorderVo> list = proWorkorderService.getFeedBackRecord(proWorkorder); return getDataTable(list); } @ApiOperation("工单关联属性查询") @GetMapping("/linkInfo") public AjaxResult<ProWorkorderVo> linkInfo(Long workorderId) { ProWorkorderVo rst = new ProWorkorderVo(); ProWorkorder proWorkorder = proWorkorderService.selectWorkorderById(workorderId); BeanUtil.copyProperties(proWorkorder, rst); ProWorkOrderSoDirective directiveQuery = new ProWorkOrderSoDirective(); directiveQuery.setWorkorderId(proWorkorder.getWorkorderId()); List<ProWorkOrderSoDirective> directiveList = proWorkOrderSoDirectiveService.selectProWorkOrderSoDirectiveList(directiveQuery); ProWorkOrderSoSizeItem sizeQuery = new ProWorkOrderSoSizeItem(); sizeQuery.setWorkorderId(proWorkorder.getWorkorderId()); List<ProWorkOrderSoSizeItem> sizeList = proWorkOrderSoSizeItemService.selectProWorkOrderSoSizeItemList(sizeQuery); rst.setSaleDirectiveList(directiveList); rst.setSizeList(sizeList); if (directiveList.size() == 1) { if (directiveList.get(0).getPackNum() != null && rst.getUsagePackNum() == null) { rst.setUsagePackNum(directiveList.get(0).getPackNum().intValue()); } } if (proWorkorder.getUsageEncasementNum() != null) { rst.setUsageEncasementNum(proWorkorder.getUsageEncasementNum()); } if (proWorkorder.getUsagePackNum() != null) { rst.setUsagePackNum(proWorkorder.getUsagePackNum()); } return AjaxResult.success(rst); } @Log(title = "用户管理", businessType = BusinessType.IMPORT) @PreAuthorize("@ss.hasPermi('system:user:import')") @PostMapping("/importData") public AjaxResult importData(MultipartFile file) throws Exception { String message = proWorkorderService.importWorkOrder(file); return AjaxResult.success(message); } @GetMapping(value = "/getChildWorkorderCode/{workOrderCode}") public AjaxResult getChildOrderCode(@PathVariable("workOrderCode") String workorderCode) { if (workorderCode == null || "".equals(workorderCode)) { throw new RuntimeException("工单编码传递为空"); } Integer i = proWorkorderService.countByParentCode(workorderCode); // 补料单生成编号 Map<String, String> map = new HashMap<>(); map.put("code", workorderCode + "-" + ((i == null ? 0 : i) + 1)); return AjaxResult.success(map); } @PostMapping("/importTemplate") public void importTemplate(HttpServletResponse response) throws IOException { proWorkorderService.importTemplate(response); } /** * 获取生产工单详细信息 */ @GetMapping(value = "/{workorderId}") public AjaxResult getInfo(@PathVariable("workorderId") Long workorderId) { return AjaxResult.success(proWorkorderService.selectProWorkorderByWorkorderId(workorderId)); } /** * 获取生产工单详细信息 */ @PostMapping(value = "/getQcCondition") public AjaxResult getQcCondition(@RequestBody ProWorkorder proWorkorder) { QueryWrapper<ProWorkorder> queryWrapper = new QueryWrapper<>(); queryWrapper.eq(StringUtils.isNotEmpty(proWorkorder.getWorkorderCode()), "workorder_code", proWorkorder.getWorkorderCode()); queryWrapper.eq(StringUtils.isNotEmpty(proWorkorder.getArrangeCode()), "arrange_code", proWorkorder.getArrangeCode()); List<ProWorkorder> proWorkorders = proWorkorderService.selectListByQw(queryWrapper); ExceptionUtil.checkTrueThrowException(CollectionUtil.isEmpty(proWorkorders), MessageUtils.message("pro.workOrder.error.not.exist")); ProWorkorder proWorkorder1 = proWorkorders.get(0); List<ProWorkOrderProcessVo> proWorkOrderProcessList = proWorkOrderProcessMapper.selectProWorkOrderProcessByWorkOrderId(proWorkorder1.getWorkorderId()); ProWorkorderVo proWorkorderVo = proWorkorder1.deepCopyObj(ProWorkorderVo.class); proWorkorderVo.setProcessList(proWorkOrderProcessList); return AjaxResult.success(proWorkorderVo); } /** * 新增生产工单 */ @ApiOperation("生产工单新增") @PreAuthorize("@ss.hasPermi('mes:pro:workorder:add')") @Log(title = "生产工单", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@RequestBody ProWorkorderVo proWorkorderVo) { ProWorkorder proWorkorder = proWorkorderVo.deepCopyObj(ProWorkorder.class); ExceptionUtil.checkTrueThrowException(!proWorkorderService.checkWorkorderIsExsit(proWorkorder), MessageUtils.message("pro.workOrder.error.workOrderNo.exist")); ProWorkorder proWorkorderNew = proWorkorderService.insertObj(proWorkorder, proWorkorderVo); return AjaxResult.success(proWorkorderNew.getWorkorderId()); } /** * 修改生产工单 */ @PreAuthorize("@ss.hasPermi('mes:pro:workorder:edit')") @Log(title = "生产工单", businessType = BusinessType.UPDATE) @PutMapping("/close") public AjaxResult close(@RequestBody List<ProWorkorderVo> proWorkorderVos) { for (ProWorkorderVo proWorkorderVo : proWorkorderVos) { proWorkorderService.updateObject(proWorkorderVo); } return AjaxResult.success(); } @PreAuthorize("@ss.hasPermi('mes:pro:workorder:add')") @Log(title = "生产补单工单", businessType = BusinessType.INSERT) @PostMapping("/addComplements") public AjaxResult addComplements(@RequestBody ProWorkorderVo proWorkorderVo) { proWorkorderService.addComplements(proWorkorderVo); return AjaxResult.success(); } /** * 修改生产工单 */ @ApiOperation("生产工单修改") @PreAuthorize("@ss.hasPermi('mes:pro:workorder:edit')") @Log(title = "生产工单", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@RequestBody ProWorkorderVo proWorkorderVo) { int ret = proWorkorderService.updateObject(proWorkorderVo); return toAjax(ret); } /** * 修改生产工单 */ @ApiOperation("生产工单修改生产版本以及工艺路线") @PreAuthorize("@ss.hasPermi('mes:pro:workorder:edit')") @Log(title = "生产工单", businessType = BusinessType.UPDATE) @PutMapping("/updateWorkProcess") public AjaxResult updateWorkProcess(@RequestBody ProWorkorderVo proWorkorderVo) { int ret = proWorkorderService.updateWorkProcess(proWorkorderVo); return toAjax(ret); } /** * 删除生产工单 */ @PreAuthorize("@ss.hasPermi('mes:pro:workorder:remove')") @Log(title = "生产工单", businessType = BusinessType.DELETE) @DeleteMapping("/{workorderIds}") public AjaxResult remove(@PathVariable Long[] workorderIds) { for (Long id : workorderIds) { ProWorkorderVo workorder = proWorkorderService.selectProWorkorderByWorkorderId(id); if (!UserConstants.ORDER_STATUS_PREPARE.equals(workorder.getStatus())) { return AjaxResult.error(MessageUtils.message("pro.workOrder.error.limit.delete")); } proWorkorderBomService.deleteProWorkorderBomByWorkorderId(id); } return toAjax(proWorkorderService.deleteProWorkorderByWorkorderIds(workorderIds)); } /** * 获取当前工单的物料需求清单 */ @PreAuthorize("@ss.hasPermi('mes:pro:workorder:list')") @GetMapping("/listItems") public TableDataInfo listItemss(ProWorkorder proWorkorder) { List<MdProductBom> result = new ArrayList<MdProductBom>(); ProWorkorderBomm param = new ProWorkorderBomm(); param.setWorkorderId(proWorkorder.getWorkorderId()); List<ProWorkorderBomm> boms = proWorkorderBomService.selectProWorkorderBomList(param); if (!CollectionUtils.isEmpty(boms)) { for (ProWorkorderBomm bom : boms ) { MdProductBom theBom = new MdProductBom(); theBom.setBomItemId(bom.getItemId()); result.addAll(getBoms(theBom, bom.getQuantity(), 0)); } } return getDataTable(result); } private List<MdProductBom> getBoms(MdProductBom item, BigDecimal quantity, int count) { MdProductBom param = new MdProductBom(); List<MdProductBom> results = new ArrayList<MdProductBom>(); if (count > 20) { return results; } param.setItemId(item.getBomItemId()); List<MdProductBom> boms = mdProductBomService.selectMdProductBomList(param); if (CollUtil.isNotEmpty(boms)) { //最多20层依赖 count++; for (MdProductBom bomItem : boms) { bomItem.setQuantity(quantity.multiply(bomItem.getQuantity())); results.addAll(getBoms(bomItem, bomItem.getQuantity(), count)); } } else { results.add(item); } return results; } /** * 完成工单 * * @param workorderId * @return */ @PreAuthorize("@ss.hasPermi('mes:pro:workorder:edit')") @Log(title = "生产工单", businessType = BusinessType.UPDATE) @Transactional @PutMapping("/{workorderId}") public AjaxResult dofinish(@PathVariable Long workorderId) { ProWorkorderVo proWorkorderVo = proWorkorderService.selectProWorkorderByWorkorderId(workorderId); ProWorkorder workorder = proWorkorderVo.deepCopyObj(ProWorkorder.class); //将此工单下所有的生产任务状态设置为已完成 ProTask param = new ProTask(); param.setArrangeCode(workorder.getArrangeCode()); List<ProTask> tasks = proTaskService.selectProTaskList(param); if (!CollectionUtils.isEmpty(tasks)) { for (ProTask task : tasks) { task.setStatus(UserConstants.ORDER_STATUS_FINISHED); proTaskService.updateProTask(task); } } workorder.setStatus(UserConstants.ORDER_STATUS_FINISHED); //更新工单的状态 proWorkorderService.updateProWorkorder(workorder); return AjaxResult.success(); } /** * 生产工单工装量具齐套检查 */ @PostMapping(value = "/checkToolNum") public void checkToolNum(@RequestBody ProWorkorderVo proWorkorderVo) { proWorkorderService.checkToolNum(proWorkorderVo.getWorkorderIds()); } /** * 生产工单将草稿状态改为已确认 */ @GetMapping(value = "/setStatus/{workorderId}") public void setStaus(@PathVariable("workorderId") Long workorderId) { ProWorkorder workorder = proWorkorderService.selectWorkorderById(workorderId); proWorkorderService.updateWorkorderState(workorder, WorkorderStatusEnum.PUBLISHED); } @PostMapping(value = "/proofMakeProduction") public AjaxResult proofMakeProduction(@RequestBody WorkorderProofMakeProduction production) { proWorkorderService.proofMakeProduction(production); return AjaxResult.success(); } /** * 导出生产工单列表 */ @PreAuthorize("@ss.hasPermi('mes:pro:workorder:export')") @Log(title = "生产工单", businessType = BusinessType.EXPORT) @PostMapping("/export") public void export(HttpServletResponse response, ProWorkorderQuery proWorkorder) throws IOException { List<ProWorkorder> list = proWorkorderService.selectProWorkorderList(proWorkorder); List<ProWorkorderExcelExport> exportList = BeanUtil.copyToList(list, ProWorkorderExcelExport.class); ExcelWriter.write(response,ProWorkorderExcelExport.class,exportList); } /** * 同步ERP数据 */ @PreAuthorize("@ss.hasPermi('mes:pro:workorder:sync')") @Log(title = "工单同步", businessType = BusinessType.SYNC_DATA) @PostMapping("/syncData") public AjaxResult syncData() { proWorkorderService.syncErpData(); return AjaxResult.success(); } }
\ No newline at end of file
......
......@@ -17,6 +17,7 @@ import com.ximai.mes.pro.domain.proWorkOrder.ProWorkorder;
import com.ximai.mes.pro.domain.task.ProTask;
import com.ximai.mes.pro.domain.task.ProTaskWorkunit;
import com.ximai.mes.pro.domain.task.WorkorderScheduleParams;
import com.ximai.mes.pro.domain.task.WorkorderScheduleParamsRollBACK;
import com.ximai.mes.pro.domain.vo.ProTaskVo;
import com.ximai.mes.pro.mapper.task.ProTaskMapper;
import com.ximai.mes.pro.service.proWorkOrder.IProWorkorderService;
......@@ -321,6 +322,13 @@ public class ProTaskController extends BaseController {
return AjaxResult.success();
}
@ApiOperation("生产任务排产")
@PreAuthorize("@ss.hasPermi('mes:pro:protask:schedule')")
@Log(title = "回滚删除生产任务排产", businessType = BusinessType.OTHER)
@PostMapping("/rollBACKschedule")
public AjaxResult rollBACKschedule(@ApiParam(value = "任务", required = true) @RequestBody WorkorderScheduleParamsRollBACK params) {
proTaskService.rollBACKschedule(params);
return AjaxResult.success();
}
}
......@@ -75,5 +75,5 @@ public class ProProductQrcodeRecord extends BaseEntity {
* 模板类型
*/
private String templateType;
private String taskBatch;
}
......@@ -261,6 +261,7 @@ public class ProTask extends BaseEntity {
* 任务批次号
*/
private String taskBatch;
@TableField(exist = false)
private String taskBatchStr;
@ApiModelProperty("是否最后工序")
......
package com.ximai.mes.pro.domain.task;
import lombok.Data;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
@Data
public class WorkorderScheduleParamsRollBACK {
private List<String> taskBatchList;
}
......@@ -70,6 +70,7 @@ public class ProProductQrcodeRecordCreate {
*/
private String templateCode;
private String taskBatch;
/**
* 模板类型
*/
......
......@@ -103,4 +103,6 @@ public class ProProductQrcodeRecordDto {
private String specification;
private String qrcodeSub;
private String taskBatch;
}
......@@ -78,5 +78,5 @@ public class ProProductQrcodeRuleCreate {
private String templateType;
private String taskBatch;
}
......@@ -137,4 +137,6 @@ public interface ProFeedbackMapper {
List<FeedbackResponse> getListByProcess(FeedbackRequest feedbackRequest);
List<FeedbackResponse> getListByUser(FeedbackRequest feedbackRequest);
int selectCount(@Param("taskIds")List<Long> taskIds);
}
......@@ -8,6 +8,7 @@ import com.ximai.mes.pro.dto.ProProductQrcodeRecordDto;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.security.core.parameters.P;
/**
* 产品序列号打印记录Mapper接口
......@@ -75,4 +76,9 @@ public interface ProProductQrcodeRecordMapper extends BaseMapper<ProProductQrcod
public int deleteProProductQrcodeRecordByRecordIds(Long[] recordIds);
int addPrintTime(@Param("ids") List<Long> collect,@Param("userName") String userName);
public int deleteProProductQrcodeRecordByTaskBatch(@Param("taskBatch")String taskBatch);
}
......@@ -3,10 +3,12 @@ package com.ximai.mes.pro.mapper.proWorkOrder;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ximai.mes.pro.domain.proWorkOrder.ProWorkorder;
import com.ximai.mes.pro.domain.task.ProTask;
import com.ximai.mes.pro.domain.vo.*;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
......@@ -146,4 +148,6 @@ public interface ProWorkorderMapper extends BaseMapper<ProWorkorder> {
Date maxErpUpdateTime();
int updateProductionSolution(@Param("productionSolutionId") Long productionSolutionId, @Param("productionSolutionCode")String productionSolutionCode, @Param("productionSolutionName")String productionSolutionName,@Param("workorderId")Long workorderId);
void rollBACKschedule(@Param("workorderCode")String workorderCode, @Param("quantity")BigDecimal quantity, @Param("username")String username);
}
......@@ -195,4 +195,6 @@ public interface ProTaskMapper extends BaseMapper<ProTask> {
List<ProTask> selectByTaskIds(@Param("taskIds")List<Long> taskIds);
List<ProTask> selectByTaskBatch(@Param("taskBatch")String taskBatch);
void deleteByTaskBatch(@Param("taskBatch")String taskBatch);
}
......@@ -97,4 +97,6 @@ public interface ProTaskWorkorderMapper
@Select(value = "select * from pro_task_workorder where task_id=#{taskId} ")
List<ProTaskWorkorder> selectProTaskWorkorderTaskId(@Param("taskId") Long taskId);
void deleteByTaskIds(@Param("taskIds")List<Long> taskIds);
}
......@@ -13,7 +13,6 @@ import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;
/**
......@@ -216,6 +215,7 @@ public interface ProTaskWorkunitMapper extends BaseMapper<ProTaskWorkunit> {
"${ew.customSqlSegment} ")
List<ProTaskWorkunitDto> selectTaskWorkUnitWithKanban(@Param("ew") QueryWrapper<ProTaskWorkunit> query);
void deleteByTaskIds(@Param("taskIds")List<Long> taskIds);
/**
* 物料综合看板专用
* @param startDate 开始时间
......
......@@ -29,36 +29,14 @@ public class ProductQrcodeBuild implements ScheduleBusiProcess{
private IProProductQrcodeRuleService proProductQrcodeRuleService;
@Override
public void execute(List<JobResult> jobResults) {
jobResults.forEach(job->{
String taskBatch = job.taskResultList != null && job.taskResultList.size() > 0 ? job.taskResultList.get(0).getProTask().getTaskBatch() : null;
job.getWorkorderList().forEach(workorder->{
ProProductQrcodeRule rule = productQrcodeRuleService.selectProProductQrcodeRuleNewest(workorder.getProductId(), workorder.getClientCode());
if(rule ==null){
return;
}
// //wzc修改 有客户优先按照产品+客户匹配序列号规则绑定的最新打印模板,如果没有匹配到 按照产品匹配序列号规则绑定的最新打印模板(客户字段为空的)
// ProProductQrcodeRuleDto proProductQrcodeRuleDto= null;
// List<ProProductQrcodeRuleDto> list = null;
// if(StringUtils.isNotEmpty(workorder.getClientCode())){
// QueryWrapper<ProProductQrcodeRule> query = new QueryWrapper<>();
// query.eq("m.item_id", workorder.getProductId());
// query.eq( "m.client_code", workorder.getClientCode());
// query.orderByDesc("m.rule_id");
// list = proProductQrcodeRuleService.selectProProductQrcodeRuleDtoList(query);
// }else{
// QueryWrapper<ProProductQrcodeRule> query = new QueryWrapper<>();
// query.eq("m.item_id", workorder.getProductId());
// query.isNull( "m.client_code");
// query.orderByDesc("m.rule_id");
// list = proProductQrcodeRuleService.selectProProductQrcodeRuleDtoList(query);
// }
// if(list != null && list.size() > 0){
// proProductQrcodeRuleDto = list.get(0);
// }
// if (proProductQrcodeRuleDto == null || StringUtils.isEmpty(proProductQrcodeRuleDto.getTemplateName())){
// //后续再看是否需要报错
//// ExceptionUtil.checkTrueThrowException(true,
//// "未能匹配到打印模板,请先到产品二维码规则维护");
// }
List<String> qrcodes = productQrcodeRuleService.buildQrcode(rule, job.getQuantity().intValue());
for(String qrcode : qrcodes){
ProProductQrcodeRecordCreate create = new ProProductQrcodeRecordCreate();
......@@ -70,6 +48,7 @@ public class ProductQrcodeBuild implements ScheduleBusiProcess{
create.setTemplateCode(rule != null ? rule.getTemplateCode() : null);
create.setTemplateName(rule != null ? rule.getTemplateName() : null);
create.setTemplateType(rule != null ? rule.getTemplateType() : null);
create.setTaskBatch(taskBatch);
productQrcodeRecordService.insertProProductQrcodeRecord(create);
}
});
......
......@@ -31,10 +31,7 @@ import com.ximai.mes.pro.domain.vo.*;
import com.ximai.mes.pro.domain.vo.task.FeedbackValidateSerialNoParams;
import com.ximai.mes.pro.dto.ProProductQrcodeRecordDto;
import com.ximai.mes.pro.dto.task.ProTaskLinkFile;
import com.ximai.mes.pro.mapper.ProProcessMapper;
import com.ximai.mes.pro.mapper.ProProductQrcodeRecordMapper;
import com.ximai.mes.pro.mapper.ProProductionLogMapper;
import com.ximai.mes.pro.mapper.ProRouteMapper;
import com.ximai.mes.pro.mapper.*;
import com.ximai.mes.pro.mapper.proWorkOrder.ProWorkOrderProcessMapper;
import com.ximai.mes.pro.mapper.proWorkOrder.ProWorkOrderProcessToolMapper;
import com.ximai.mes.pro.mapper.proWorkOrder.ProWorkorderMapper;
......@@ -143,6 +140,8 @@ public class ProTaskServiceImpl implements IProTaskService {
private ProWorkOrderProcessToolMapper proWorkOrderProcessToolMapper;
@Autowired
private IProFeedbackService proFeedbackService;
@Autowired
private ProFeedbackMapper proFeedbackMapper;
@Resource
private SysUserMapper sysUserMapper;
@Autowired
......@@ -1456,4 +1455,30 @@ public class ProTaskServiceImpl implements IProTaskService {
return null;
}
@Override
@Transactional
public void rollBACKschedule(WorkorderScheduleParamsRollBACK params) {
if(params.getTaskBatchList() == null || params.getTaskBatchList().size() < 1)
return;
params.setTaskBatchList(params.getTaskBatchList().stream().distinct().collect(Collectors.toList()));
//1.pro_task 2.pro_task_workorder ,3.pro_task_workunit 4.pro_product_qrcode_record 5.pro_workorder
//获取该批次下所有数据
for (String taskBatch : params.getTaskBatchList()){
ProTask proTaskCheck = new ProTask();
proTaskCheck.setTaskBatch(taskBatch);
List<ProTask> proTasks = proTaskMapper.selectProTaskList(proTaskCheck);
if(proTasks.size() < 1)
continue;
ExceptionUtil.checkTrueThrowException(proTasks.stream().filter(proTask -> !proTask.getStatus().equals("NORMARL")).count() > 0, MessageUtils.message("rollback.schedule.status.err",taskBatch));
ExceptionUtil.checkTrueThrowException(proFeedbackMapper.selectCount(proTasks.stream().map(proTask -> proTask.getTaskId()).collect(Collectors.toList())) > 0, MessageUtils.message("rollback.schedule.status.err",taskBatch));
proTaskMapper.deleteByTaskBatch(taskBatch);
proTaskWorkunitMapper.deleteByTaskIds(proTasks.stream().map(proTask -> proTask.getTaskId()).collect(Collectors.toList()));
proTaskWorkorderMapper.deleteByTaskIds(proTasks.stream().map(proTask -> proTask.getTaskId()).collect(Collectors.toList()));
proProductQrcodeRecordMapper.deleteProProductQrcodeRecordByTaskBatch(taskBatch);
proWorkorderMapper.rollBACKschedule(proTasks.get(0).getArrangeCode(),proTasks.get(0).getQuantity(),SecurityUtils.getUsername());
}
}
}
......@@ -6,6 +6,7 @@ import com.ximai.mes.pro.domain.ProFeedback;
import com.ximai.mes.pro.domain.task.ProTask;
import com.ximai.mes.pro.domain.task.ProTaskWorkunit;
import com.ximai.mes.pro.domain.task.WorkorderScheduleParams;
import com.ximai.mes.pro.domain.task.WorkorderScheduleParamsRollBACK;
import com.ximai.mes.pro.domain.vo.ProPackagePrintResult;
import com.ximai.mes.pro.domain.vo.ProTaskQuery;
import com.ximai.mes.pro.domain.vo.ProTaskVo;
......@@ -192,4 +193,5 @@ public interface IProTaskService {
List<ProTaskLinkFile> getTaskLinkFile(ProTaskQuery proTask);
void rollBACKschedule(WorkorderScheduleParamsRollBACK params);
}
......@@ -430,6 +430,13 @@
f.user_name,
f.nick_name
</select>
<select id="selectCount" resultType="java.lang.Integer">
select count(1) from pro_feedback
where task_Id in
<foreach collection="taskIds" open="(" item="taskId" close=")" separator=",">
#{taskId}
</foreach>
</select>
<insert id="insertProFeedback" parameterType="ProFeedback" useGeneratedKeys="true" keyProperty="recordId">
insert into pro_feedback
......
......@@ -42,7 +42,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select record_id, item_id, item_code, work_order_id, work_order_no,
print_time, qrcode, client_code, client_name, item_desc, create_by,
create_time, update_by, update_time ,template_id,template_type,
template_code,template_name
template_code,template_name,task_batch
from pro_product_qrcode_record
</sql>
......@@ -94,6 +94,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="templateType != null">
template_type,
</if>
<if test="taskBatch != null">
task_batch,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="itemId != null">#{itemId},</if>
......@@ -121,6 +124,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="templateType != null">
#{templateType,jdbcType=VARCHAR},
</if>
<if test="taskBatch != null">
#{taskBatch,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<update id="addPrintTime">
......@@ -161,4 +167,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{recordId}
</foreach>
</delete>
<delete id="deleteProProductQrcodeRecordByTaskBatch" parameterType="String">
delete from pro_product_qrcode_record where task_batch =#{taskBatch}
</delete>
</mapper>
\ No newline at end of file
......@@ -440,6 +440,9 @@
update pro_workorder set production_solution_id = #{productionSolutionId},production_solution_code = #{productionSolutionCode} ,production_solution_name = #{productionSolutionName}
where workorder_id = #{workorderId}
</update>
<update id="rollBACKschedule">
update pro_workorder set quantity_scheduled = quantity_scheduled - #{quantity} , update_By = #{quantity}, update_time = now() where workorder_code = #{workorderCode}
</update>
<delete id="deleteProWorkorderByWorkorderId" parameterType="Long">
delete
......
......@@ -296,7 +296,9 @@
<if test="taskBatchStr != null and taskBatchStr != ''">and t.task_batch like concat('%', #{taskBatchStr},
'%')
</if>
<if test="taskBatch != null and taskBatch != ''">
and t.task_batch= #{taskBatch}
</if>
<if test="itemId != null ">and t.item_id = #{itemId}</if>
<if test="itemCode != null and itemCode != ''">and i.item_code = #{itemCode}</if>
<if test="itemName != null and itemName != ''">and i.item_name like concat('%', #{itemName}, '%')</if>
......@@ -506,4 +508,7 @@
#{taskId}
</foreach>
</delete>
<delete id="deleteByTaskBatch">
delete from pro_task where task_batch = #{taskBatch}
</delete>
</mapper>
......@@ -63,4 +63,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{taskWorkorderId}
</foreach>
</delete>
<delete id="deleteByTaskIds">
delete from pro_task_workorder where task_id in
<foreach item="taskId" collection="taskIds" open="(" separator="," close=")">
#{taskId}
</foreach>
</delete>
</mapper>
......@@ -199,4 +199,10 @@
#{taskWorkunitId}
</foreach>
</delete>
<delete id="deleteByTaskIds">
delete from pro_task_workunit where task_id in
<foreach item="taskId" collection="taskIds" open="(" separator="," close=")">
#{taskId}
</foreach>
</delete>
</mapper>
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