diff --git a/ktg-mes/src/main/java/com/ktg/mes/qc/controller/mobile/QCIpqcLineMobController.java b/ktg-mes/src/main/java/com/ktg/mes/qc/controller/mobile/QCIpqcLineMobController.java new file mode 100644 index 0000000..4b7d21a --- /dev/null +++ b/ktg-mes/src/main/java/com/ktg/mes/qc/controller/mobile/QCIpqcLineMobController.java @@ -0,0 +1,83 @@ +package com.ktg.mes.qc.controller.mobile; + +import com.ktg.common.annotation.Log; +import com.ktg.common.core.controller.BaseController; +import com.ktg.common.core.domain.AjaxResult; +import com.ktg.common.core.page.TableDataInfo; +import com.ktg.common.enums.BusinessType; +import com.ktg.mes.qc.domain.QcIpqcLine; +import com.ktg.mes.qc.service.IQcIpqcLineService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 移动端过程检验、质量巡检、完工检验行接口 + */ +@RestController +@RequestMapping("/mobile/qc/ipqcline") +public class QCIpqcLineMobController extends BaseController { + + @Autowired + private IQcIpqcLineService qcIpqcLineService; + + /** + * 查询过程检验单行列表 + */ + @PreAuthorize("@ss.hasPermi('mes:qc:ipqc:list')") + @GetMapping("/list") + public TableDataInfo list(QcIpqcLine qcIpqcLine) + { + startPage(); + List list = qcIpqcLineService.selectQcIpqcLineList(qcIpqcLine); + return getDataTable(list); + } + + /** + * 获取过程检验单行详细信息 + */ + @PreAuthorize("@ss.hasPermi('mes:qc:ipqc:query')") + @GetMapping(value = "/{lineId}") + public AjaxResult getInfo(@PathVariable("lineId") Long lineId) + { + return AjaxResult.success(qcIpqcLineService.selectQcIpqcLineByLineId(lineId)); + } + + /** + * 新增过程检验单行 + */ + @PreAuthorize("@ss.hasPermi('mes:qc:ipqc:add')") + @Log(title = "过程检验单行", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody QcIpqcLine qcIpqcLine) + { + qcIpqcLine.setCreateBy(getUsername()); + qcIpqcLineService.insertQcIpqcLine(qcIpqcLine); + return AjaxResult.success(qcIpqcLine); + } + + /** + * 修改过程检验单行 + */ + @PreAuthorize("@ss.hasPermi('mes:qc:ipqc:edit')") + @Log(title = "过程检验单行", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody QcIpqcLine qcIpqcLine) + { + return toAjax(qcIpqcLineService.updateQcIpqcLine(qcIpqcLine)); + } + + /** + * 删除过程检验单行 + */ + @PreAuthorize("@ss.hasPermi('mes:qc:ipqc:remove')") + @Log(title = "过程检验单行", businessType = BusinessType.DELETE) + @DeleteMapping("/{lineIds}") + public AjaxResult remove(@PathVariable Long[] lineIds) + { + return toAjax(qcIpqcLineService.deleteQcIpqcLineByLineIds(lineIds)); + } + +} diff --git a/ktg-mes/src/main/java/com/ktg/mes/qc/controller/mobile/QCIpqcMobController.java b/ktg-mes/src/main/java/com/ktg/mes/qc/controller/mobile/QCIpqcMobController.java new file mode 100644 index 0000000..9e15bb7 --- /dev/null +++ b/ktg-mes/src/main/java/com/ktg/mes/qc/controller/mobile/QCIpqcMobController.java @@ -0,0 +1,253 @@ +package com.ktg.mes.qc.controller.mobile; + +import cn.hutool.core.collection.CollUtil; +import com.ktg.common.annotation.Log; +import com.ktg.common.constant.UserConstants; +import com.ktg.common.core.controller.BaseController; +import com.ktg.common.core.domain.AjaxResult; +import com.ktg.common.core.page.TableDataInfo; +import com.ktg.common.enums.BusinessType; +import com.ktg.common.utils.StringUtils; +import com.ktg.mes.md.domain.MdWorkstation; +import com.ktg.mes.md.service.IMdWorkstationService; +import com.ktg.mes.pro.domain.ProFeedback; +import com.ktg.mes.pro.domain.ProWorkorder; +import com.ktg.mes.pro.service.IProFeedbackService; +import com.ktg.mes.pro.service.IProWorkorderService; +import com.ktg.mes.qc.domain.*; +import com.ktg.mes.qc.service.*; +import com.ktg.system.strategy.AutoCodeUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; +import org.springframework.web.bind.annotation.*; + +import java.math.BigDecimal; +import java.util.List; + +/** + * 过程检验、质量巡检、完工检验接口 + */ +@RestController +@RequestMapping("/mobile/qc/ipqc") +public class QCIpqcMobController extends BaseController { + + @Autowired + private IQcIpqcService qcIpqcService; + + @Autowired + private AutoCodeUtil autoCodeUtil; + + @Autowired + private IProWorkorderService proWorkorderService; + + @Autowired + private IMdWorkstationService mdWorkstationService; + + @Autowired + private IQcTemplateIndexService qcTemplateIndexService; + + @Autowired + private IQcTemplateService qcTemplateService; + + @Autowired + private IQcIpqcLineService qcIpqcLineService; + + @Autowired + private IQcDefectRecordService qcDefectRecordService; + + @Autowired + private IProFeedbackService proFeedbackService; + + /** + * 查询过程检验单列表 + */ + @GetMapping("/list") + public TableDataInfo list(QcIpqc qcIpqc) + { + startPage(); + List list = qcIpqcService.selectQcIpqcList(qcIpqc); + return getDataTable(list); + } + + /** + * 获取过程检验单详细信息 + */ + @GetMapping(value = "/{ipqcId}") + public AjaxResult getInfo(@PathVariable("ipqcId") Long ipqcId) + { + return AjaxResult.success(qcIpqcService.selectQcIpqcByIpqcId(ipqcId)); + } + + /** + * 新增过程检验单 + */ + @Log(title = "过程检验单", businessType = BusinessType.INSERT) + @Transactional + @PostMapping + public AjaxResult add(@RequestBody QcIpqc qcIpqc) + { + + //质量的质检记录编码自动生成 + String resultCode = autoCodeUtil.genSerialCode(UserConstants.QC_IPQC_CODE,null); + qcIpqc.setIpqcCode(resultCode); + + //过程检验、完工检验按物资搜索 + //根据工单获取产品信息 + ProWorkorder workorder = proWorkorderService.selectProWorkorderByWorkorderId(qcIpqc.getWorkorderId()); + qcIpqc.setWorkorderId(workorder.getWorkorderId()); + qcIpqc.setWorkorderCode(workorder.getWorkorderCode()); + qcIpqc.setWorkorderName(workorder.getWorkorderName()); + qcIpqc.setItemId(workorder.getProductId()); + qcIpqc.setItemCode(workorder.getProductCode()); + qcIpqc.setItemName(workorder.getProductName()); + qcIpqc.setSpecification(workorder.getProductSpc()); + qcIpqc.setUnitOfMeasure(workorder.getUnitOfMeasure()); + + //查询工序相关信息 + List infos = qcIpqcService.getProcessInfo(qcIpqc); + if(!CollectionUtils.isEmpty(infos)&&infos.size() ==1){ + qcIpqc.setProcessId(infos.get(0).getProcessId()); + qcIpqc.setProcessCode(infos.get(0).getProcessCode()); + qcIpqc.setProcessName(infos.get(0).getProcessName()); + } + + //根据产品和检测类型获取检测模板 + QcTemplate param = new QcTemplate(); + param.setQcTypes(qcIpqc.getIpqcType()); + param.setItemId(workorder.getProductId()); + QcTemplate template = qcTemplateService.selectQcTemplateByProductAndQcType(param); + if(StringUtils.isNotNull(template)){ + qcIpqc.setTemplateId(template.getTemplateId()); + }else{ + return AjaxResult.error("当前工单生产的产品未配置此类型的检验模板!"); + } + + qcIpqc.setCreateBy(getUsername()); + //先保存 + qcIpqcService.insertQcIpqc(qcIpqc); + + //生成行信息 + generateLine(qcIpqc); + + return AjaxResult.success(qcIpqc); + } + + /** + * 修改过程检验单 + */ + @Log(title = "过程检验单", businessType = BusinessType.UPDATE) + @Transactional + @PutMapping + public AjaxResult edit(@RequestBody QcIpqc qcIpqc) + { + if(UserConstants.NOT_UNIQUE.equals(qcIpqcService.checkIpqcCodeUnique(qcIpqc))){ + return AjaxResult.error("检测单编码已存在!"); + } + + + //根据工单获取产品信息 + ProWorkorder workorder = proWorkorderService.selectProWorkorderByWorkorderId(qcIpqc.getWorkorderId()); + qcIpqc.setWorkorderId(workorder.getWorkorderId()); + qcIpqc.setWorkorderCode(workorder.getWorkorderCode()); + qcIpqc.setWorkorderName(workorder.getWorkorderName()); + qcIpqc.setItemId(workorder.getProductId()); + qcIpqc.setItemCode(workorder.getProductCode()); + qcIpqc.setItemName(workorder.getProductName()); + qcIpqc.setSpecification(workorder.getProductSpc()); + qcIpqc.setUnitOfMeasure(workorder.getUnitOfMeasure()); + + //查询工序相关信息 + List infos = qcIpqcService.getProcessInfo(qcIpqc); + if(!CollectionUtils.isEmpty(infos)&&infos.size() ==1){ + qcIpqc.setProcessId(infos.get(0).getProcessId()); + qcIpqc.setProcessCode(infos.get(0).getProcessCode()); + qcIpqc.setProcessName(infos.get(0).getProcessName()); + } + + //根据产品和检测类型获取检测模板 + QcTemplate param = new QcTemplate(); + param.setQcTypes(qcIpqc.getIpqcType()); + param.setItemId(workorder.getProductId()); + QcTemplate template = qcTemplateService.selectQcTemplateByProductAndQcType(param); + if(StringUtils.isNotNull(template)){ + qcIpqc.setTemplateId(template.getTemplateId()); + }else{ + return AjaxResult.error("当前工单生产的产品未配置此类型的检验模板!"); + } + + //如果是完成单据则根据单据上的来源单据,更新对应的关联单据信息 + if(UserConstants.ORDER_STATUS_FINISHED.equals(qcIpqc.getStatus())){ + //如果来源是生产报工单 + ProFeedback feedback = proFeedbackService.selectProFeedbackByRecordId(qcIpqc.getSourceDocId()); + if(StringUtils.isNotNull(feedback)){ + feedback.setQuantityQualified(qcIpqc.getQuantityQualified()); + feedback.setQuantityUnquanlified(qcIpqc.getQuantityUnqualified()); + feedback.setQuantityUncheck(BigDecimal.ZERO); + proFeedbackService.updateProFeedback(feedback); + } + } + + return toAjax(qcIpqcService.updateQcIpqc(qcIpqc)); + } + + /** + * 删除过程检验单 + */ + @Log(title = "过程检验单", businessType = BusinessType.DELETE) + @Transactional + @DeleteMapping("/{ipqcIds}") + public AjaxResult remove(@PathVariable Long[] ipqcIds) + { + for (Long ipqcId: ipqcIds + ) { + QcIpqc ipqc = qcIpqcService.selectQcIpqcByIpqcId(ipqcId); + if(!UserConstants.ORDER_STATUS_PREPARE.equals(ipqc.getStatus())){ + return AjaxResult.error("只能删除草稿状态的单据!"); + } + + qcIpqcLineService.deleteByIpqcId(ipqcId); //删除对应的行信息 + QcDefectRecord p2 = new QcDefectRecord(); + p2.setQcId(ipqcId); + qcDefectRecordService.deleteByQcIdAndType(p2);//删除对应的缺陷记录 + + //TODO: 删除对应的质检值记录 + } + + return toAjax(qcIpqcService.deleteQcIpqcByIpqcIds(ipqcIds)); + } + + + /** + * 根据头信息生成行信息 + * @param iqc + */ + private void generateLine(QcIpqc iqc){ + QcTemplateIndex param = new QcTemplateIndex(); + param.setTemplateId(iqc.getTemplateId()); + List indexs = qcTemplateIndexService.selectQcTemplateIndexList(param); + if(CollUtil.isNotEmpty(indexs)){ + for (QcTemplateIndex index:indexs + ) { + QcIpqcLine line = new QcIpqcLine(); + line.setIpqcId(iqc.getIpqcId()); + line.setIndexId(index.getIndexId()); + line.setIndexCode(index.getIndexCode()); + line.setIndexName(index.getIndexName()); + line.setIndexType(index.getIndexType()); + line.setQcTool(index.getQcTool()); + line.setCheckMethod(index.getCheckMethod()); + line.setStanderVal(index.getStanderVal()); + line.setUnitOfMeasure(index.getUnitOfMeasure()); + line.setThresholdMax(index.getThresholdMax()); + line.setThresholdMin(index.getThresholdMin()); + line.setCrQuantity(new BigDecimal(0L)); + line.setMajQuantity(new BigDecimal(0L)); + line.setMajQuantity(new BigDecimal(0L)); + qcIpqcLineService.insertQcIpqcLine(line); + } + } + } + + +} diff --git a/ktg-mes/src/main/java/com/ktg/mes/qc/controller/mobile/QCIqcLineMobController.java b/ktg-mes/src/main/java/com/ktg/mes/qc/controller/mobile/QCIqcLineMobController.java new file mode 100644 index 0000000..34783da --- /dev/null +++ b/ktg-mes/src/main/java/com/ktg/mes/qc/controller/mobile/QCIqcLineMobController.java @@ -0,0 +1,84 @@ +package com.ktg.mes.qc.controller.mobile; + +import com.ktg.common.annotation.Log; +import com.ktg.common.core.controller.BaseController; +import com.ktg.common.core.domain.AjaxResult; +import com.ktg.common.core.page.TableDataInfo; +import com.ktg.common.enums.BusinessType; +import com.ktg.mes.qc.domain.QcIqcLine; +import com.ktg.mes.qc.domain.QcOqcLine; +import com.ktg.mes.qc.service.IQcIqcLineService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 移动端来料检验单行接口 + */ +@RestController +@RequestMapping("/mobile/qc/iqcline") +public class QCIqcLineMobController extends BaseController { + + @Autowired + private IQcIqcLineService qcIqcLineService; + + /** + * 查询来料检验单行列表 + */ + @PreAuthorize("@ss.hasPermi('mes:qc:iqc:list')") + @GetMapping("/list") + public TableDataInfo list(QcIqcLine qcIqcLine) + { + startPage(); + List list = qcIqcLineService.selectQcIqcLineList(qcIqcLine); + return getDataTable(list); + } + + /** + * 获取来料检验单行详细信息 + */ + @PreAuthorize("@ss.hasPermi('mes:qc:iqc:query')") + @GetMapping(value = "/{lineId}") + public AjaxResult getInfo(@PathVariable("lineId") Long lineId) + { + return AjaxResult.success(qcIqcLineService.selectQcIqcLineByLineId(lineId)); + } + + /** + * 新增来料检验单行 + */ + @PreAuthorize("@ss.hasPermi('mes:qc:iqc:add')") + @Log(title = "来料检验单行", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody QcIqcLine qcIqcLine) + { + qcIqcLine.setCreateBy(getUsername()); + qcIqcLineService.insertQcIqcLine(qcIqcLine); + return AjaxResult.success(qcIqcLine); + } + + /** + * 修改来料检验单行 + */ + @PreAuthorize("@ss.hasPermi('mes:qc:iqc:edit')") + @Log(title = "来料检验单行", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody QcIqcLine qcIqcLine) + { + return toAjax(qcIqcLineService.updateQcIqcLine(qcIqcLine)); + } + + /** + * 删除来料检验单行 + */ + @PreAuthorize("@ss.hasPermi('mes:qc:iqc:remove')") + @Log(title = "来料检验单行", businessType = BusinessType.DELETE) + @DeleteMapping("/{lineIds}") + public AjaxResult remove(@PathVariable Long[] lineIds) + { + return toAjax(qcIqcLineService.deleteQcIqcLineByLineIds(lineIds)); + } + +} diff --git a/ktg-mes/src/main/java/com/ktg/mes/qc/controller/mobile/QCIqcMobController.java b/ktg-mes/src/main/java/com/ktg/mes/qc/controller/mobile/QCIqcMobController.java new file mode 100644 index 0000000..8a93dce --- /dev/null +++ b/ktg-mes/src/main/java/com/ktg/mes/qc/controller/mobile/QCIqcMobController.java @@ -0,0 +1,198 @@ +package com.ktg.mes.qc.controller.mobile; + +import cn.hutool.core.collection.CollUtil; +import com.ktg.common.annotation.Log; +import com.ktg.common.constant.UserConstants; +import com.ktg.common.core.controller.BaseController; +import com.ktg.common.core.domain.AjaxResult; +import com.ktg.common.core.page.TableDataInfo; +import com.ktg.common.enums.BusinessType; +import com.ktg.common.utils.StringUtils; +import com.ktg.mes.qc.domain.*; +import com.ktg.mes.qc.service.*; +import com.ktg.mes.wm.domain.WmItemRecptLine; +import com.ktg.mes.wm.service.IWmItemRecptLineService; +import com.ktg.system.strategy.AutoCodeUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.bind.annotation.*; + +import java.math.BigDecimal; +import java.util.List; + +/** + * 移动端来料检验单接口 + */ +@RestController +@RequestMapping("/mobile/qc/iqc") +public class QCIqcMobController extends BaseController { + + @Autowired + private IQcIqcService qcIqcService; + + @Autowired + private AutoCodeUtil autoCodeUtil; + + @Autowired + private IQcTemplateProductService qcTemplateProductService; + + @Autowired + private IQcTemplateIndexService qcTemplateIndexService; + + @Autowired + private IQcIqcLineService qcIqcLineService; + + @Autowired + private IQcDefectRecordService qcDefectRecordService; + + @Autowired + private IWmItemRecptLineService wmItemRecptLineService; + + + /** + * 查询来料检验单列表 + */ + @GetMapping("/list") + public TableDataInfo list(QcIqc qcIqc) + { + startPage(); + List list = qcIqcService.selectQcIqcList(qcIqc); + return getDataTable(list); + } + + + /** + * 获取来料检验单详细信息 + */ + @PreAuthorize("@ss.hasPermi('mes:qc:iqc:query')") + @GetMapping(value = "/{iqcId}") + public AjaxResult getInfo(@PathVariable("iqcId") Long iqcId) + { + return AjaxResult.success(qcIqcService.selectQcIqcByIqcId(iqcId)); + } + + + /** + * 新增来料检验单 + */ + @PreAuthorize("@ss.hasPermi('mes:qc:iqc:add')") + @Log(title = "来料检验单", businessType = BusinessType.INSERT) + @Transactional + @PostMapping + public AjaxResult add(@RequestBody QcIqc qcIqc) + { + //质量的质检记录编码自动生成 + String resultCode = autoCodeUtil.genSerialCode(UserConstants.QC_IQC_CODE,null); + qcIqc.setIqcCode(resultCode); + + QcTemplateProduct param = new QcTemplateProduct(); + param.setItemId(qcIqc.getItemId()); + List templates = qcTemplateProductService.selectQcTemplateProductList(param); + if(CollUtil.isNotEmpty(templates)){ + qcIqc.setTemplateId(templates.get(0).getTemplateId()); + }else{ + return AjaxResult.error("当前产品未配置检测模板!"); + } + qcIqc.setInspector(getUsername()); + qcIqc.setCreateBy(getUsername()); + qcIqcService.insertQcIqc(qcIqc); + generateLine(qcIqc); + return AjaxResult.success(qcIqc); + } + + /** + * 修改来料检验单 + */ + @PreAuthorize("@ss.hasPermi('mes:qc:iqc:edit')") + @Log(title = "来料检验单", businessType = BusinessType.UPDATE) + @Transactional + @PutMapping + public AjaxResult edit(@RequestBody QcIqc qcIqc) + { + if(UserConstants.NOT_UNIQUE.equals(qcIqcService.checkIqcCodeUnique(qcIqc))){ + return AjaxResult.error("单据编号已存在!"); + } + + QcTemplateProduct param = new QcTemplateProduct(); + param.setItemId(qcIqc.getItemId()); + List templates = qcTemplateProductService.selectQcTemplateProductList(param); + if(CollUtil.isNotEmpty(templates)){ + qcIqc.setTemplateId(templates.get(0).getTemplateId()); + }else{ + return AjaxResult.error("当前产品未配置检测模板!"); + } + qcIqc.setInspector(getUsername()); + + //如果是完成状态,则根据来源单据更新其对应的检测单 + if(UserConstants.ORDER_STATUS_FINISHED.equals(qcIqc.getStatus())){ + if(StringUtils.isNotNull(qcIqc.getSourceDocCode())){ + //这里默认是采购入库单,后续有其他单据则根据单据类型(sourceDocType)进行区分 + WmItemRecptLine line = wmItemRecptLineService.selectWmItemRecptLineByLineId(qcIqc.getSourceLineId()); + if(StringUtils.isNotNull(line)){ + line.setIqcCode(qcIqc.getIqcCode()); + line.setIqcId(qcIqc.getIqcId()); + wmItemRecptLineService.updateWmItemRecptLine(line); + } + } + } + + return toAjax(qcIqcService.updateQcIqc(qcIqc)); + } + + /** + * 删除来料检验单 + */ + @PreAuthorize("@ss.hasPermi('mes:qc:iqc:remove')") + @Log(title = "来料检验单", businessType = BusinessType.DELETE) + @Transactional + @DeleteMapping("/{iqcIds}") + public AjaxResult remove(@PathVariable Long[] iqcIds) + { + for (Long iqcId:iqcIds + ) { + QcIqc iqc = qcIqcService.selectQcIqcByIqcId(iqcId); + if(!UserConstants.ORDER_STATUS_PREPARE.equals(iqc.getStatus())){ + return AjaxResult.error("只能删除草稿状态单据!"); + } + qcIqcLineService.deleteByIqcId(iqcId); + QcDefectRecord p2 = new QcDefectRecord(); + p2.setQcId(iqcId); + p2.setQcType(UserConstants.QC_TYPE_IQC); + qcDefectRecordService.deleteByQcIdAndType(p2);//删除对应的缺陷记录 + } + return toAjax(qcIqcService.deleteQcIqcByIqcIds(iqcIds)); + } + + /** + * 根据头信息生成行信息 + * @param iqc + */ + private void generateLine(QcIqc iqc){ + QcTemplateIndex param = new QcTemplateIndex(); + param.setTemplateId(iqc.getTemplateId()); + List indexs = qcTemplateIndexService.selectQcTemplateIndexList(param); + if(CollUtil.isNotEmpty(indexs)){ + for (QcTemplateIndex index:indexs + ) { + QcIqcLine line = new QcIqcLine(); + line.setIqcId(iqc.getIqcId()); + line.setIndexId(index.getIndexId()); + line.setIndexCode(index.getIndexCode()); + line.setIndexName(index.getIndexName()); + line.setIndexType(index.getIndexType()); + line.setQcTool(index.getQcTool()); + line.setCheckMethod(index.getCheckMethod()); + line.setStanderVal(index.getStanderVal()); + line.setUnitOfMeasure(index.getUnitOfMeasure()); + line.setThresholdMax(index.getThresholdMax()); + line.setThresholdMin(index.getThresholdMin()); + line.setCrQuantity(BigDecimal.ZERO); + line.setMajQuantity(BigDecimal.ZERO); + line.setMajQuantity(BigDecimal.ZERO); + qcIqcLineService.insertQcIqcLine(line); + } + } + } + +} diff --git a/ktg-mes/src/main/java/com/ktg/mes/qc/controller/mobile/QCOqcLineMobController.java b/ktg-mes/src/main/java/com/ktg/mes/qc/controller/mobile/QCOqcLineMobController.java new file mode 100644 index 0000000..d72f97f --- /dev/null +++ b/ktg-mes/src/main/java/com/ktg/mes/qc/controller/mobile/QCOqcLineMobController.java @@ -0,0 +1,83 @@ +package com.ktg.mes.qc.controller.mobile; + +import com.ktg.common.annotation.Log; +import com.ktg.common.core.controller.BaseController; +import com.ktg.common.core.domain.AjaxResult; +import com.ktg.common.core.page.TableDataInfo; +import com.ktg.common.enums.BusinessType; +import com.ktg.mes.qc.domain.QcOqcLine; +import com.ktg.mes.qc.service.IQcOqcLineService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 移动端出厂检验单行接口 + */ +@RestController +@RequestMapping("/mobile/qc/oqcline") +public class QCOqcLineMobController extends BaseController { + + @Autowired + private IQcOqcLineService qcOqcLineService; + + /** + * 查询出货检验单行列表 + */ + @PreAuthorize("@ss.hasPermi('mes:qc:oqc:list')") + @GetMapping("/list") + public TableDataInfo list(QcOqcLine qcOqcLine) + { + startPage(); + List list = qcOqcLineService.selectQcOqcLineList(qcOqcLine); + return getDataTable(list); + } + + /** + * 获取出货检验单行详细信息 + */ + @PreAuthorize("@ss.hasPermi('mes:qc:oqc:query')") + @GetMapping(value = "/{lineId}") + public AjaxResult getInfo(@PathVariable("lineId") Long lineId) + { + return AjaxResult.success(qcOqcLineService.selectQcOqcLineByLineId(lineId)); + } + + /** + * 新增出货检验单行 + */ + @PreAuthorize("@ss.hasPermi('mes:qc:oqc:add')") + @Log(title = "出货检验单行", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody QcOqcLine qcOqcLine) + { + qcOqcLine.setCreateBy(getUsername()); + qcOqcLineService.insertQcOqcLine(qcOqcLine); + return AjaxResult.success(qcOqcLine); + } + + /** + * 修改出货检验单行 + */ + @PreAuthorize("@ss.hasPermi('mes:qc:oqc:edit')") + @Log(title = "出货检验单行", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody QcOqcLine qcOqcLine) + { + return toAjax(qcOqcLineService.updateQcOqcLine(qcOqcLine)); + } + + /** + * 删除出货检验单行 + */ + @PreAuthorize("@ss.hasPermi('mes:qc:oqc:remove')") + @Log(title = "出货检验单行", businessType = BusinessType.DELETE) + @DeleteMapping("/{lineIds}") + public AjaxResult remove(@PathVariable Long[] lineIds) + { + return toAjax(qcOqcLineService.deleteQcOqcLineByLineIds(lineIds)); + } + +} diff --git a/ktg-mes/src/main/java/com/ktg/mes/qc/controller/mobile/QCOqcMobController.java b/ktg-mes/src/main/java/com/ktg/mes/qc/controller/mobile/QCOqcMobController.java new file mode 100644 index 0000000..5639513 --- /dev/null +++ b/ktg-mes/src/main/java/com/ktg/mes/qc/controller/mobile/QCOqcMobController.java @@ -0,0 +1,198 @@ +package com.ktg.mes.qc.controller.mobile; + +import cn.hutool.core.collection.CollUtil; +import com.ktg.common.annotation.Log; +import com.ktg.common.constant.UserConstants; +import com.ktg.common.core.controller.BaseController; +import com.ktg.common.core.domain.AjaxResult; +import com.ktg.common.core.page.TableDataInfo; +import com.ktg.common.enums.BusinessType; +import com.ktg.common.utils.StringUtils; +import com.ktg.mes.qc.domain.QcOqc; +import com.ktg.mes.qc.domain.QcOqcLine; +import com.ktg.mes.qc.domain.QcTemplateIndex; +import com.ktg.mes.qc.domain.QcTemplateProduct; +import com.ktg.mes.qc.service.IQcOqcLineService; +import com.ktg.mes.qc.service.IQcOqcService; +import com.ktg.mes.qc.service.IQcTemplateIndexService; +import com.ktg.mes.qc.service.IQcTemplateProductService; +import com.ktg.mes.wm.domain.WmProductSalseLine; +import com.ktg.mes.wm.service.IWmProductSalseLineService; +import com.ktg.system.strategy.AutoCodeUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.bind.annotation.*; + +import java.math.BigDecimal; +import java.util.List; + +/** + * 移动端出厂检验接口 + */ +@RestController +@RequestMapping("/mobile/qc/oqc") +public class QCOqcMobController extends BaseController { + + @Autowired + private IQcOqcService qcOqcService; + + @Autowired + private AutoCodeUtil autoCodeUtil; + + @Autowired + private IQcOqcLineService qcOqcLineService; + + @Autowired + private IQcTemplateProductService qcTemplateProductService; + + @Autowired + private IQcTemplateIndexService qcTemplateIndexService; + + @Autowired + private IWmProductSalseLineService wmProductSalseLineService; + + /** + * 查询出货检验单列表 + */ + @GetMapping("/list") + public TableDataInfo list(QcOqc qcOqc) + { + startPage(); + List list = qcOqcService.selectQcOqcList(qcOqc); + return getDataTable(list); + } + + /** + * 获取出货检验单详细信息 + */ + @PreAuthorize("@ss.hasPermi('mes:qc:oqc:query')") + @GetMapping(value = "/{oqcId}") + public AjaxResult getInfo(@PathVariable("oqcId") Long oqcId) + { + return AjaxResult.success(qcOqcService.selectQcOqcByOqcId(oqcId)); + } + + /** + * 新增出货检验单 + */ + @PreAuthorize("@ss.hasPermi('mes:qc:oqc:add')") + @Log(title = "出货检验单", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody QcOqc qcOqc) + { + //质量的质检记录编码自动生成 + String resultCode = autoCodeUtil.genSerialCode(UserConstants.QC_OQC_CODE,null); + qcOqc.setOqcCode(resultCode); + + //自动获取对应的检测模板 + QcTemplateProduct param = new QcTemplateProduct(); + param.setItemId(qcOqc.getItemId()); + List templates = qcTemplateProductService.selectQcTemplateProductList(param); + if(CollUtil.isNotEmpty(templates)){ + qcOqc.setTemplateId(templates.get(0).getTemplateId()); + }else{ + return AjaxResult.error("当前产品未配置检测模板!"); + } + //设置检测人 + qcOqc.setInspector(getUsername()); + + qcOqc.setCreateBy(getUsername()); + //先保存单据 + qcOqcService.insertQcOqc(qcOqc); + //生成行信息 + generateLine(qcOqc); + + return AjaxResult.success(qcOqc); + } + + /** + * 修改出货检验单 + */ + @PreAuthorize("@ss.hasPermi('mes:qc:oqc:edit')") + @Log(title = "出货检验单", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody QcOqc qcOqc) + { + if(UserConstants.NOT_UNIQUE.equals(qcOqcService.checkOqcCodeUnique(qcOqc))){ + return AjaxResult.error("出货单编号已存在!"); + } + + //自动获取对应的检测模板 + QcTemplateProduct param = new QcTemplateProduct(); + param.setItemId(qcOqc.getItemId()); + List templates = qcTemplateProductService.selectQcTemplateProductList(param); + if(CollUtil.isNotEmpty(templates)){ + qcOqc.setTemplateId(templates.get(0).getTemplateId()); + }else{ + return AjaxResult.error("当前产品未配置检测模板!"); + } + //设置检测人 + qcOqc.setInspector(getUsername()); + + if(UserConstants.ORDER_STATUS_FINISHED.equals(qcOqc.getStatus())){ + if(StringUtils.isNotNull(qcOqc.getSourceDocCode())){ + WmProductSalseLine line = wmProductSalseLineService.selectWmProductSalseLineByLineId(qcOqc.getSourceLineId()); + if(StringUtils.isNotNull(line)){ + line.setOqcId(qcOqc.getOqcId()); + line.setOqcCode(qcOqc.getOqcCode()); + wmProductSalseLineService.updateWmProductSalseLine(line); + } + } + } + return toAjax(qcOqcService.updateQcOqc(qcOqc)); + } + + /** + * 删除出货检验单 + */ + @PreAuthorize("@ss.hasPermi('mes:qc:oqc:remove')") + @Log(title = "出货检验单", businessType = BusinessType.DELETE) + @Transactional + @DeleteMapping("/{oqcIds}") + public AjaxResult remove(@PathVariable Long[] oqcIds) + { + for (Long oqcId: oqcIds + ) { + QcOqc oqc = qcOqcService.selectQcOqcByOqcId(oqcId); + if(!UserConstants.ORDER_STATUS_PREPARE.equals(oqc.getStatus())){ + return AjaxResult.error("只能删除状态为草稿的单据!"); + } + qcOqcLineService.deleteByOqcId(oqcId); + } + + return toAjax(qcOqcService.deleteQcOqcByOqcIds(oqcIds)); + } + + /** + * 根据头信息生成行信息 + * @param oqc + */ + private void generateLine(QcOqc oqc){ + QcTemplateIndex param = new QcTemplateIndex(); + param.setTemplateId(oqc.getTemplateId()); + List indexs = qcTemplateIndexService.selectQcTemplateIndexList(param); + if(CollUtil.isNotEmpty(indexs)){ + for (QcTemplateIndex index:indexs + ) { + QcOqcLine line = new QcOqcLine(); + line.setOqcId(oqc.getOqcId()); + line.setIndexId(index.getIndexId()); + line.setIndexCode(index.getIndexCode()); + line.setIndexName(index.getIndexName()); + line.setIndexType(index.getIndexType()); + line.setQcTool(index.getQcTool()); + line.setCheckMethod(index.getCheckMethod()); + line.setStanderVal(index.getStanderVal()); + line.setUnitOfMeasure(index.getUnitOfMeasure()); + line.setThresholdMax(index.getThresholdMax()); + line.setThresholdMin(index.getThresholdMin()); + line.setCrQuantity(new BigDecimal(0L)); + line.setMajQuantity(new BigDecimal(0L)); + line.setMajQuantity(new BigDecimal(0L)); + qcOqcLineService.insertQcOqcLine(line); + } + } + } + +} diff --git a/ktg-mes/src/main/java/com/ktg/mes/qc/controller/mobile/QCResultDetailMobController.java b/ktg-mes/src/main/java/com/ktg/mes/qc/controller/mobile/QCResultDetailMobController.java new file mode 100644 index 0000000..45442a1 --- /dev/null +++ b/ktg-mes/src/main/java/com/ktg/mes/qc/controller/mobile/QCResultDetailMobController.java @@ -0,0 +1,90 @@ +package com.ktg.mes.qc.controller.mobile; + +import com.ktg.common.annotation.Log; +import com.ktg.common.constant.UserConstants; +import com.ktg.common.core.controller.BaseController; +import com.ktg.common.core.domain.AjaxResult; +import com.ktg.common.core.page.TableDataInfo; +import com.ktg.common.enums.BusinessType; +import com.ktg.common.utils.StringUtils; +import com.ktg.mes.qc.domain.QcResultDetail; +import com.ktg.mes.qc.domain.ValidList; +import com.ktg.mes.qc.service.IQcResultDetailService; +import org.apache.commons.collections.CollectionUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * @author yinjinlu + * @description + * @date 2024/12/9 + */ +@RestController +@RequestMapping("/mobile/qc/qcresultdetail") +public class QCResultDetailMobController extends BaseController { + + @Autowired + private IQcResultDetailService qcResultDetailService; + + /** + * 查询检测结果明细记录列表 + */ + @GetMapping("/list") + public TableDataInfo list(QcResultDetail qcResultDetail) + { + startPage(); + List list = qcResultDetailService.selectQcResultDetailList(qcResultDetail); + return getDataTable(list); + } + + /** + * 修改检验单结果 + */ + @Log(title = "更新质检记录列表", businessType = BusinessType.UPDATE) + @Transactional + @PutMapping + public AjaxResult updateList(@Validated @RequestBody ValidList defects){ + if(CollectionUtils.isNotEmpty(defects)){ + for(QcResultDetail index: defects){ + switch (index.getQcResultType()){ + case UserConstants.QC_RESULT_TYPE_FLOAT: + if(StringUtils.isNull(index.getQcValFloat())){ + return AjaxResult.error("请填写检测值!【"+index.getIndexName()+"】"); + } + break; + case UserConstants.QC_RESULT_TYPE_INTEGER: + if(StringUtils.isNull(index.getQcValInteger())){ + return AjaxResult.error("请填写检测值!【"+index.getIndexName()+"】"); + } + break; + case UserConstants.QC_RESULT_TYPE_TEXT: + if(StringUtils.isNull(index.getQcValText())){ + return AjaxResult.error("请填写检测值!【"+index.getIndexName()+"】"); + } + break; + case UserConstants.QC_RESULT_TYPE_DICT: + if(StringUtils.isNull(index.getQcValDict())){ + return AjaxResult.error("请填写检测值!【"+index.getIndexName()+"】"); + } + break; + case UserConstants.QC_RESULT_TYPE_FILE: + if(StringUtils.isNull(index.getQcValFile())){ + return AjaxResult.error("请填写检测值!【"+index.getIndexName()+"】"); + } + break; + default: + break; + } + qcResultDetailService.updateQcResultDetail(index); + } + } + return AjaxResult.success(); + } + + +} diff --git a/ktg-mes/src/main/java/com/ktg/mes/qc/controller/mobile/QCResultMobController.java b/ktg-mes/src/main/java/com/ktg/mes/qc/controller/mobile/QCResultMobController.java new file mode 100644 index 0000000..2df2dbb --- /dev/null +++ b/ktg-mes/src/main/java/com/ktg/mes/qc/controller/mobile/QCResultMobController.java @@ -0,0 +1,245 @@ +package com.ktg.mes.qc.controller.mobile; + +import com.ktg.common.annotation.Log; +import com.ktg.common.constant.UserConstants; +import com.ktg.common.core.controller.BaseController; +import com.ktg.common.core.domain.AjaxResult; +import com.ktg.common.core.page.TableDataInfo; +import com.ktg.common.enums.BusinessType; +import com.ktg.common.utils.StringUtils; +import com.ktg.common.utils.bean.BeanUtils; +import com.ktg.common.utils.poi.ExcelUtil; +import com.ktg.mes.qc.domain.*; +import com.ktg.mes.qc.service.*; +import com.ktg.system.strategy.AutoCodeUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; + +/** + * 质检记录Controller + * + * @author yinjinlu + * @date 2023-11-19 + */ +@RestController +@RequestMapping("/mobile/qc/qcresult") +public class QCResultMobController extends BaseController +{ + @Autowired + private IQcResultService qcResultService; + + @Autowired + private IQcResultDetailService qcResultDetailService; + + @Autowired + private AutoCodeUtil autoCodeUtil; + + @Autowired + private IQcIqcService qcIqcService; + + @Autowired + private IQcIqcLineService qcIqcLineService; + + @Autowired + private IQcIpqcService qcIpqcService; + + @Autowired + private IQcIpqcLineService qcIpqcLineService; + + @Autowired + private IQcOqcService qcOqcService; + + @Autowired + private IQcOqcLineService qcOqcLineService; + + + /** + * 查询质检记录列表 + */ + @GetMapping("/list") + public TableDataInfo list(QcResult qcResult) + { + startPage(); + List list = qcResultService.selectQcResultList(qcResult); + return getDataTable(list); + } + + /** + * 导出质检记录列表 + */ + @Log(title = "质检记录", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, QcResult qcResult) + { + List list = qcResultService.selectQcResultList(qcResult); + ExcelUtil util = new ExcelUtil(QcResult.class); + util.exportExcel(response, list, "质检记录数据"); + } + + /** + * 获取质检记录详细信息 + */ + @GetMapping(value = "/{resultId}") + public AjaxResult getInfo(@PathVariable("resultId") Long resultId) + { + return AjaxResult.success(qcResultService.selectQcResultByResultId(resultId)); + } + + /** + * 新增质检记录 + */ + @Log(title = "质检记录", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody QcResult qcResult) + { + //质量的质检记录编码自动生成 + String resultCode = autoCodeUtil.genSerialCode(UserConstants.QC_RESULT_CODE,null); + qcResult.setResultCode(resultCode); + + //根据传入的sourceDocId和sourceDocType初始化其他信息 + if(StringUtils.isNull(qcResult.getSourceDocId()) || StringUtils.isNull(qcResult.getSourceDocType())){ + return AjaxResult.error("来源单据类型和ID不能为空!"); + } + + String sourceDocType = qcResult.getSourceDocType(); + Long sourceDocId = qcResult.getSourceDocId(); + Long resultId = -1L; + switch (sourceDocType){ + case UserConstants.QC_TYPE_IQC: + //根据iqcId查询对应的单据编号和名称 + QcIqc iqc = qcIqcService.selectQcIqcByIqcId(sourceDocId); + if(StringUtils.isNotNull(iqc)){ + qcResult.setSourceDocCode(iqc.getIqcCode()); + qcResult.setSourceDocName(iqc.getIqcName()); + qcResult.setItemId(iqc.getItemId()); + qcResult.setItemName(iqc.getItemName()); + qcResult.setItemCode(iqc.getItemCode()); + qcResult.setSpecification(iqc.getSpecification()); + qcResult.setUnitOfMeasure(iqc.getUnitOfMeasure()); + } + + qcResultService.insertQcResult(qcResult); + resultId = qcResult.getResultId(); + generateIQCRecordIndex(resultId,sourceDocId); + break; + case UserConstants.QC_TYPE_IPQC: + QcIpqc ipqc = qcIpqcService.selectQcIpqcByIpqcId(sourceDocId); + if(StringUtils.isNotNull(ipqc)){ + qcResult.setSourceDocCode(ipqc.getIpqcCode()); + qcResult.setSourceDocName(ipqc.getIpqcName()); + qcResult.setItemId(ipqc.getItemId()); + qcResult.setItemName(ipqc.getItemName()); + qcResult.setItemCode(ipqc.getItemCode()); + qcResult.setSpecification(ipqc.getSpecification()); + qcResult.setUnitOfMeasure(ipqc.getUnitOfMeasure()); + } + + qcResultService.insertQcResult(qcResult); + resultId = qcResult.getResultId(); + generateIPQCRecordIndex(resultId,sourceDocId); + break; + case UserConstants.QC_TYPE_OQC: + QcOqc oqc = qcOqcService.selectQcOqcByOqcId(sourceDocId); + if(StringUtils.isNotNull(oqc)){ + qcResult.setSourceDocCode(oqc.getOqcCode()); + qcResult.setSourceDocName(oqc.getOqcName()); + qcResult.setItemId(oqc.getItemId()); + qcResult.setItemName(oqc.getItemName()); + qcResult.setItemCode(oqc.getItemCode()); + qcResult.setSpecification(oqc.getSpecification()); + qcResult.setUnitOfMeasure(oqc.getUnitOfMeasure()); + } + + qcResultService.insertQcResult(qcResult); + resultId = qcResult.getResultId(); + generateOQCRecordIndex(resultId,sourceDocId); + break; + default: + return AjaxResult.error("错误的检测单类型!"); + } + return AjaxResult.success(qcResult); + } + + /** + * 修改质检记录 + */ + @Log(title = "质检记录", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody QcResult qcResult) + { + return toAjax(qcResultService.updateQcResult(qcResult)); + } + + /** + * 删除质检记录 + */ + @Log(title = "质检记录", businessType = BusinessType.DELETE) + @Transactional + @DeleteMapping("/{resultIds}") + public AjaxResult remove(@PathVariable Long[] resultIds) + { + return toAjax(qcResultService.deleteQcResultByResultIds(resultIds)); + } + + /** + * 根据来料检验单ID,自动生成对应的检测记录-检测项 + * @param resultId + */ + private void generateIQCRecordIndex(Long resultId,Long iqcId){ + QcResultDetail qcResultDetail = new QcResultDetail(); + qcResultDetail.setResultId(resultId); + qcResultDetail.setQcId(iqcId); + List details = qcResultDetailService.selectQcResultDetailByResultIdAndIQCId(qcResultDetail); + + if(!CollectionUtils.isEmpty(details)){ + for (QcResultDetail line: details + ) { + line.setResultId(resultId); + qcResultDetailService.insertQcResultDetail(line); + } + } + } + + /** + * 根据过程检验单ID自动生成对应的检测记录-检测项 + * @param resultId + */ + private void generateIPQCRecordIndex(Long resultId,Long ipqcId){ + QcResultDetail qcResultDetail = new QcResultDetail(); + qcResultDetail.setResultId(resultId); + qcResultDetail.setQcId(ipqcId); + List details = qcResultDetailService.selectQcResultDetailByResultIdAndIPQCId(qcResultDetail); + + if(!CollectionUtils.isEmpty(details)){ + for (QcResultDetail line: details + ) { + line.setResultId(resultId); + qcResultDetailService.insertQcResultDetail(line); + } + } + } + + /** + * 根据出厂检验单ID,自动生成对应的检测记录-检测项 + * @param resultId + */ + private void generateOQCRecordIndex(Long resultId,Long oqcId){ + QcResultDetail qcResultDetail = new QcResultDetail(); + qcResultDetail.setResultId(resultId); + qcResultDetail.setQcId(oqcId); + List details = qcResultDetailService.selectQcResultDetailByResultIdAndOQCId(qcResultDetail); + + if(!CollectionUtils.isEmpty(details)){ + for (QcResultDetail line: details + ) { + line.setResultId(resultId); + qcResultDetailService.insertQcResultDetail(line); + } + } + } +}