From d62bb2fc85bc3f3f8964ac9974f3f7303dc2b76d Mon Sep 17 00:00:00 2001 From: shaoyong Date: Mon, 11 Mar 2024 15:55:19 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B4=A8=E9=87=8F=E7=9B=AE=E6=A0=87=E6=A8=A1?= =?UTF-8?q?=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../quality/controller/QcGoalController.java | 126 ++++++++ .../QcGoalDistributeController.java | 118 ++++++++ .../java/com/op/quality/domain/QcGoal.java | 273 ++++++++++++++++++ .../op/quality/domain/QcGoalDistribute.java | 216 ++++++++++++++ .../com/op/quality/domain/vo/TreeSelect.java | 8 + .../mapper/QcGoalDistributeMapper.java | 70 +++++ .../com/op/quality/mapper/QcGoalMapper.java | 75 +++++ .../impl/QcGoalDistributeServiceImpl.java | 153 ++++++++++ .../service/impl/QcGoalServiceImpl.java | 245 ++++++++++++++++ .../mapper/quality/QcGoalDistributeMapper.xml | 218 ++++++++++++++ .../resources/mapper/quality/QcGoalMapper.xml | 261 +++++++++++++++++ 11 files changed, 1763 insertions(+) create mode 100644 op-modules/op-quality/src/main/java/com/op/quality/controller/QcGoalController.java create mode 100644 op-modules/op-quality/src/main/java/com/op/quality/controller/QcGoalDistributeController.java create mode 100644 op-modules/op-quality/src/main/java/com/op/quality/domain/QcGoal.java create mode 100644 op-modules/op-quality/src/main/java/com/op/quality/domain/QcGoalDistribute.java create mode 100644 op-modules/op-quality/src/main/java/com/op/quality/mapper/QcGoalDistributeMapper.java create mode 100644 op-modules/op-quality/src/main/java/com/op/quality/mapper/QcGoalMapper.java create mode 100644 op-modules/op-quality/src/main/java/com/op/quality/service/impl/QcGoalDistributeServiceImpl.java create mode 100644 op-modules/op-quality/src/main/java/com/op/quality/service/impl/QcGoalServiceImpl.java create mode 100644 op-modules/op-quality/src/main/resources/mapper/quality/QcGoalDistributeMapper.xml create mode 100644 op-modules/op-quality/src/main/resources/mapper/quality/QcGoalMapper.xml diff --git a/op-modules/op-quality/src/main/java/com/op/quality/controller/QcGoalController.java b/op-modules/op-quality/src/main/java/com/op/quality/controller/QcGoalController.java new file mode 100644 index 00000000..b6e43d1e --- /dev/null +++ b/op-modules/op-quality/src/main/java/com/op/quality/controller/QcGoalController.java @@ -0,0 +1,126 @@ +package com.op.quality.controller; + +import java.util.List; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import com.op.common.log.annotation.Log; +import com.op.common.log.enums.BusinessType; +import com.op.common.security.annotation.RequiresPermissions; +import com.op.quality.domain.QcGoal; +import com.op.quality.service.IQcGoalService; +import com.op.common.core.web.controller.BaseController; +import com.op.common.core.web.domain.AjaxResult; +import com.op.common.core.utils.poi.ExcelUtil; +import com.op.common.core.web.page.TableDataInfo; + +/** + * 质量目标Controller + * + * @author Open Platform + * @date 2024-03-04 + */ +@RestController +@RequestMapping("/qcGoal") +public class QcGoalController extends BaseController { + @Autowired + private IQcGoalService qcGoalService; + + /** + * 查询质量目标列表 + */ + @RequiresPermissions("quality:qcGoal:list") + @GetMapping("/list") + public TableDataInfo list(QcGoal qcGoal) { + startPage(); + List list = qcGoalService.selectQcGoalList(qcGoal); + return getDataTable(list); + } + + /** + * 查询二级质量目标 + */ + @GetMapping("/getChildrenList/{parentId}") + public List getChildrenList(@PathVariable("parentId") String parentId) { + QcGoal goal = new QcGoal(); + goal.setParentGoal(parentId); + List list = qcGoalService.selectChildrenByParent(goal); + return list; + } + + /** + * 导出质量目标列表 + */ + @RequiresPermissions("quality:qcGoal:export") + @Log(title = "质量目标", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, QcGoal qcGoal) { + List list = qcGoalService.selectQcGoalList(qcGoal); + ExcelUtil util = new ExcelUtil(QcGoal. class); + util.exportExcel(response, list, "质量目标数据"); + } + + /** + * 获取质量目标详细信息 + */ + @RequiresPermissions("quality:qcGoal:query") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") String id) { + return success(qcGoalService.selectQcGoalById(id)); + } + + /** + * 获取质量目标下拉树列表 + */ + @GetMapping("/treeSelect") + public AjaxResult treeSelect(QcGoal qcGoal) { + List qcGoals = qcGoalService.selectQcGoalList(qcGoal); + return success(qcGoalService.buildQcGoalTreeSelect(qcGoals)); + } + + /** + * 新增质量目标 + */ + @RequiresPermissions("quality:qcGoal:add") + @Log(title = "质量目标", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody QcGoal qcGoal) { + return toAjax(qcGoalService.insertQcGoal(qcGoal)); + } + + /** + * 拆解质量目标 + */ + @GetMapping("/generate/{id}") + public TableDataInfo generate(@PathVariable("id") String id) { + List qcGoalList = qcGoalService.generate(id); + return getDataTable(qcGoalList); + } + + + /** + * 修改质量目标 + */ + @RequiresPermissions("quality:qcGoal:edit") + @Log(title = "质量目标", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody QcGoal qcGoal) { + return toAjax(qcGoalService.updateQcGoal(qcGoal)); + } + + /** + * 删除质量目标 + */ + @RequiresPermissions("quality:qcGoal:remove") + @Log(title = "质量目标", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable String[] ids) { + int rows = qcGoalService.deleteQcGoalByIds(ids); + if (rows > 0 ) { + return success("操作成功"); + }else { + return error("操作失败,请检查要删除的项目是否含有子项目"); + } + } +} diff --git a/op-modules/op-quality/src/main/java/com/op/quality/controller/QcGoalDistributeController.java b/op-modules/op-quality/src/main/java/com/op/quality/controller/QcGoalDistributeController.java new file mode 100644 index 00000000..c5148e95 --- /dev/null +++ b/op-modules/op-quality/src/main/java/com/op/quality/controller/QcGoalDistributeController.java @@ -0,0 +1,118 @@ +package com.op.quality.controller; + +import java.util.List; +import javax.servlet.http.HttpServletResponse; + +import com.op.quality.domain.QcGoal; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.op.common.log.annotation.Log; +import com.op.common.log.enums.BusinessType; +import com.op.common.security.annotation.RequiresPermissions; +import com.op.quality.domain.QcGoalDistribute; +import com.op.quality.service.IQcGoalDistributeService; +import com.op.common.core.web.controller.BaseController; +import com.op.common.core.web.domain.AjaxResult; +import com.op.common.core.utils.poi.ExcelUtil; +import com.op.common.core.web.page.TableDataInfo; + +/** + * 质量目标分配Controller + * + * @author Open Platform + * @date 2024-03-07 + */ +@RestController +@RequestMapping("/qcGoalDistribute") +public class QcGoalDistributeController extends BaseController { + @Autowired + private IQcGoalDistributeService qcGoalDistributeService; + +/** + * 查询质量目标分配列表 + */ +@RequiresPermissions("quality:qcGoalDistribute:list") +@GetMapping("/list") + public TableDataInfo list(QcGoalDistribute qcGoalDistribute) { + startPage(); + List list = qcGoalDistributeService.selectQcGoalDistributeList(qcGoalDistribute); + return getDataTable(list); + } + + /** + * 导出质量目标分配列表 + */ + @RequiresPermissions("quality:qcGoalDistribute:export") + @Log(title = "质量目标分配", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, QcGoalDistribute qcGoalDistribute) { + List list = qcGoalDistributeService.selectQcGoalDistributeList(qcGoalDistribute); + ExcelUtil util = new ExcelUtil(QcGoalDistribute. class); + util.exportExcel(response, list, "质量目标分配数据"); + } + + /** + * 获取质量目标分配详细信息 + */ + @RequiresPermissions("quality:qcGoalDistribute:query") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") String id) { + return success(qcGoalDistributeService.selectQcGoalDistributeById(id)); + } + + /** + * 新增质量目标分配 + */ + @Log(title = "质量目标分配", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody QcGoalDistribute qcGoalDistribute) { + return toAjax(qcGoalDistributeService.insertQcGoalDistribute(qcGoalDistribute)); + } + + /** + * 修改质量目标分配 + */ + @RequiresPermissions("quality:qcGoalDistribute:edit") + @Log(title = "质量目标分配", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody QcGoalDistribute qcGoalDistribute) { + return toAjax(qcGoalDistributeService.updateQcGoalDistribute(qcGoalDistribute)); + } + + /** + * 删除质量目标分配 + */ + @RequiresPermissions("quality:qcGoalDistribute:remove") + @Log(title = "质量目标分配", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable String[] ids) { + return toAjax(qcGoalDistributeService.deleteQcGoalDistributeByIds(ids)); + } + /** + * 获取未分配供应商数据 + */ + @GetMapping(value = "/getLeftList") + public TableDataInfo getLeftList(QcGoalDistribute qcGoalDistribute) { + startPage(); + List list = qcGoalDistributeService.getLeftList(qcGoalDistribute); + return getDataTable(list); + } + + /** + * 获取已分配供应商数据 + */ + @GetMapping(value = "/getRightList") + public TableDataInfo getRightList(QcGoalDistribute qcGoalDistribute) { + startPage(); + List list = qcGoalDistributeService.getRightList(qcGoalDistribute); + return getDataTable(list); + } + +} diff --git a/op-modules/op-quality/src/main/java/com/op/quality/domain/QcGoal.java b/op-modules/op-quality/src/main/java/com/op/quality/domain/QcGoal.java new file mode 100644 index 00000000..e46fcbf1 --- /dev/null +++ b/op-modules/op-quality/src/main/java/com/op/quality/domain/QcGoal.java @@ -0,0 +1,273 @@ +package com.op.quality.domain; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.op.common.core.annotation.Excel; +import com.op.common.core.web.domain.BaseEntity; + +/** + * 质量目标对象 qc_goal + * + * @author Open Platform + * @date 2024-03-04 + */ +public class QcGoal extends BaseEntity { + private static final long serialVersionUID = 1L; + + /** + * id + */ + private String id; + + /** + * 目标年份(月份) + */ + @Excel(name = "目标年份", readConverterExp = "月=份") + private String goalYm; + + /** + * 目标类别 + */ + @Excel(name = "目标类别") + private String goalType; + + /** + * 不良率 + */ + @Excel(name = "不良率") + private BigDecimal nookRate; + + /** + * 抽样比例 + */ + @Excel(name = "抽样比例") + private BigDecimal nookQualityRate; + + /** + * 预留字段1 + */ + @Excel(name = "预留字段1") + private String attr1; + + /** + * 预留字段2 + */ + @Excel(name = "预留字段2") + private String attr2; + + /** + * 预留字段3 + */ + @Excel(name = "预留字段3") + private String attr3; + + /** + * 预留字段4 + */ + @Excel(name = "预留字段4") + private String attr4; + + /** + * 工厂编码 + */ + @Excel(name = "工厂编码") + private String factoryCode; + + /** + * 删除标识1删除0正常 + */ + private String delFlag; + + /** + * 检验节点小节点 + */ + @Excel(name = "检验节点小节点") + private String checkType; + + /** + * 检验节点大类 + */ + @Excel(name = "检验节点大类") + private String typeCode; + + /** + * 适配范围 + */ + @Excel(name = "适配范围") + private String scope; + + /** + * 父级目标 + */ + @Excel(name = "父级目标") + private String parentGoal; + + private Boolean hasChildren; + + private List children = new ArrayList<>(); + + public void setId(String id) { + this.id = id; + } + + public String getId() { + return id; + } + + public void setGoalYm(String goalYm) { + this.goalYm = goalYm; + } + + public String getGoalYm() { + return goalYm; + } + + public void setGoalType(String goalType) { + this.goalType = goalType; + } + + public String getGoalType() { + return goalType; + } + + public void setNookRate(BigDecimal nookRate) { + this.nookRate = nookRate; + } + + public BigDecimal getNookRate() { + return nookRate; + } + + public void setNookQualityRate(BigDecimal nookQualityRate) { + this.nookQualityRate = nookQualityRate; + } + + public BigDecimal getNookQualityRate() { + return nookQualityRate; + } + + public void setAttr1(String attr1) { + this.attr1 = attr1; + } + + public String getAttr1() { + return attr1; + } + + public void setAttr2(String attr2) { + this.attr2 = attr2; + } + + public String getAttr2() { + return attr2; + } + + public void setAttr3(String attr3) { + this.attr3 = attr3; + } + + public String getAttr3() { + return attr3; + } + + public void setAttr4(String attr4) { + this.attr4 = attr4; + } + + public String getAttr4() { + return attr4; + } + + public void setFactoryCode(String factoryCode) { + this.factoryCode = factoryCode; + } + + public String getFactoryCode() { + return factoryCode; + } + + public void setDelFlag(String delFlag) { + this.delFlag = delFlag; + } + + public String getDelFlag() { + return delFlag; + } + + public void setCheckType(String checkType) { + this.checkType = checkType; + } + + public String getCheckType() { + return checkType; + } + + public void setTypeCode(String typeCode) { + this.typeCode = typeCode; + } + + public String getTypeCode() { + return typeCode; + } + + public void setScope(String scope) { + this.scope = scope; + } + + public String getScope() { + return scope; + } + + public void setParentGoal(String parentGoal) { + this.parentGoal = parentGoal; + } + + public String getParentGoal() { + return parentGoal; + } + + public Boolean getHasChildren() { + return hasChildren; + } + + public void setHasChildren(Boolean hasChildren) { + this.hasChildren = hasChildren; + } + + public List getChildren() { + return children; + } + + public void setChildren(List children) { + this.children = children; + } + + @Override + public String toString() { + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("goalYm", getGoalYm()) + .append("goalType", getGoalType()) + .append("nookRate", getNookRate()) + .append("nookQualityRate", getNookQualityRate()) + .append("attr1", getAttr1()) + .append("attr2", getAttr2()) + .append("attr3", getAttr3()) + .append("attr4", getAttr4()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("factoryCode", getFactoryCode()) + .append("delFlag", getDelFlag()) + .append("checkType", getCheckType()) + .append("typeCode", getTypeCode()) + .append("scope", getScope()) + .append("parentGoal", getParentGoal()) + .toString(); + } +} diff --git a/op-modules/op-quality/src/main/java/com/op/quality/domain/QcGoalDistribute.java b/op-modules/op-quality/src/main/java/com/op/quality/domain/QcGoalDistribute.java new file mode 100644 index 00000000..316dfd40 --- /dev/null +++ b/op-modules/op-quality/src/main/java/com/op/quality/domain/QcGoalDistribute.java @@ -0,0 +1,216 @@ +package com.op.quality.domain; + +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.op.common.core.annotation.Excel; +import com.op.common.core.web.domain.BaseEntity; + +import java.util.List; + +/** + * 质量目标分配对象 qc_goal_distribute + * + * @author Open Platform + * @date 2024-03-07 + */ +public class QcGoalDistribute extends BaseEntity { + private static final long serialVersionUID = 1L; + + /** + * id + */ + private String id; + + /** + * 所属质量目标id + */ + @Excel(name = "所属质量目标id") + private String belongGoalId; + + /** + * 供应商(产品)编码 + */ + @Excel(name = "供应商(产品)编码") + private String supplierCode; + + /** + * 供应商(产品)名称 + */ + @Excel(name = "供应商(产品)名称") + private String supplierName; + + /** + * 预留字段1 + */ + @Excel(name = "预留字段1") + private String attr1; + + /** + * 预留字段2 + */ + @Excel(name = "预留字段2") + private String attr2; + + /** + * 预留字段3 + */ + @Excel(name = "预留字段3") + private String attr3; + + /** + * 预留字段4 + */ + @Excel(name = "预留字段4") + private String attr4; + + /** + * 工厂编码 + */ + @Excel(name = "工厂编码") + private String factoryCode; + + /** + * 删除标识1删除0正常 + */ + private String delFlag; + + private String label; + + private String key; + + private String[] SupplierCodes; + + private List selectedValues; + + public void setId(String id) { + this.id = id; + } + + public String getId() { + return id; + } + + public void setBelongGoalId(String belongGoalId) { + this.belongGoalId = belongGoalId; + } + + public String getBelongGoalId() { + return belongGoalId; + } + + public void setSupplierCode(String supplierCode) { + this.supplierCode = supplierCode; + } + + public String getSupplierCode() { + return supplierCode; + } + + public void setSupplierName(String supplierName) { + this.supplierName = supplierName; + } + + public String getSupplierName() { + return supplierName; + } + + public void setAttr1(String attr1) { + this.attr1 = attr1; + } + + public String getAttr1() { + return attr1; + } + + public void setAttr2(String attr2) { + this.attr2 = attr2; + } + + public String getAttr2() { + return attr2; + } + + public void setAttr3(String attr3) { + this.attr3 = attr3; + } + + public String getAttr3() { + return attr3; + } + + public void setAttr4(String attr4) { + this.attr4 = attr4; + } + + public String getAttr4() { + return attr4; + } + + public void setFactoryCode(String factoryCode) { + this.factoryCode = factoryCode; + } + + public String getFactoryCode() { + return factoryCode; + } + + public void setDelFlag(String delFlag) { + this.delFlag = delFlag; + } + + public String getDelFlag() { + return delFlag; + } + + public String getLabel() { + return label; + } + + public void setLabel(String label) { + this.label = label; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String[] getSupplierCodes() { + return SupplierCodes; + } + + public void setSupplierCodes(String[] supplierCodes) { + SupplierCodes = supplierCodes; + } + + public List getSelectedValues() { + return selectedValues; + } + + public void setSelectedValues(List selectedValues) { + this.selectedValues = selectedValues; + } + + @Override + public String toString() { + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("belongGoalId", getBelongGoalId()) + .append("supplierCode", getSupplierCode()) + .append("supplierName", getSupplierName()) + .append("attr1", getAttr1()) + .append("attr2", getAttr2()) + .append("attr3", getAttr3()) + .append("attr4", getAttr4()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("factoryCode", getFactoryCode()) + .append("delFlag", getDelFlag()) + .toString(); + } +} diff --git a/op-modules/op-quality/src/main/java/com/op/quality/domain/vo/TreeSelect.java b/op-modules/op-quality/src/main/java/com/op/quality/domain/vo/TreeSelect.java index 03d7e960..42cba682 100644 --- a/op-modules/op-quality/src/main/java/com/op/quality/domain/vo/TreeSelect.java +++ b/op-modules/op-quality/src/main/java/com/op/quality/domain/vo/TreeSelect.java @@ -1,9 +1,11 @@ package com.op.quality.domain.vo; import com.fasterxml.jackson.annotation.JsonInclude; +import com.op.quality.domain.QcGoal; import com.op.quality.domain.QcMaterialGroup; +import javax.xml.bind.annotation.XmlEnum; import java.io.Serializable; import java.util.List; import java.util.stream.Collectors; @@ -42,6 +44,12 @@ public class TreeSelect implements Serializable { this.children = qcMaterialGroup.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList()); } + public TreeSelect(QcGoal qcGoal) { + this.id = qcGoal.getId(); + this.label = qcGoal.getGoalYm(); + this.children = qcGoal.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList()); + } + public String getId() { return id; } diff --git a/op-modules/op-quality/src/main/java/com/op/quality/mapper/QcGoalDistributeMapper.java b/op-modules/op-quality/src/main/java/com/op/quality/mapper/QcGoalDistributeMapper.java new file mode 100644 index 00000000..6a550b19 --- /dev/null +++ b/op-modules/op-quality/src/main/java/com/op/quality/mapper/QcGoalDistributeMapper.java @@ -0,0 +1,70 @@ +package com.op.quality.mapper; + +import java.util.List; + +import com.op.quality.domain.QcGoalDistribute; +import org.apache.ibatis.annotations.Mapper; + +/** + * 质量目标分配Mapper接口 + * + * @author Open Platform + * @date 2024-03-07 + */ +@Mapper +public interface QcGoalDistributeMapper { + /** + * 查询质量目标分配 + * + * @param id 质量目标分配主键 + * @return 质量目标分配 + */ + public QcGoalDistribute selectQcGoalDistributeById(String id); + + /** + * 查询质量目标分配列表 + * + * @param qcGoalDistribute 质量目标分配 + * @return 质量目标分配集合 + */ + public List selectQcGoalDistributeList(QcGoalDistribute qcGoalDistribute); + + /** + * 新增质量目标分配 + * + * @param qcGoalDistribute 质量目标分配 + * @return 结果 + */ + public int insertQcGoalDistribute(QcGoalDistribute qcGoalDistribute); + + /** + * 修改质量目标分配 + * + * @param qcGoalDistribute 质量目标分配 + * @return 结果 + */ + public int updateQcGoalDistribute(QcGoalDistribute qcGoalDistribute); + + /** + * 删除质量目标分配 + * + * @param id 质量目标分配主键 + * @return 结果 + */ + public int deleteQcGoalDistributeById(String id); + + public int deleteQcGoalDistributeByBelongId(String id); + + /** + * 批量删除质量目标分配 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteQcGoalDistributeByIds(String[] ids); + + public List getGoalDistributeUndo(QcGoalDistribute qcGoalDistribute); + public List getGoalDistributeDo(QcGoalDistribute qcGoalDistribute); + + +} diff --git a/op-modules/op-quality/src/main/java/com/op/quality/mapper/QcGoalMapper.java b/op-modules/op-quality/src/main/java/com/op/quality/mapper/QcGoalMapper.java new file mode 100644 index 00000000..9855d49a --- /dev/null +++ b/op-modules/op-quality/src/main/java/com/op/quality/mapper/QcGoalMapper.java @@ -0,0 +1,75 @@ +package com.op.quality.mapper; + +import java.util.List; + +import com.op.quality.domain.QcGoal; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +/** + * 质量目标Mapper接口 + * + * @author Open Platform + * @date 2024-03-04 + */ +@Mapper +public interface QcGoalMapper { + /** + * 查询质量目标 + * + * @param id 质量目标主键 + * @return 质量目标 + */ + public QcGoal selectQcGoalById(String id); + + /** + * 查询质量目标列表 + * + * @param qcGoal 质量目标 + * @return 质量目标集合 + */ + public List selectQcGoalList(QcGoal qcGoal); + + public List selectChildrenByParent(QcGoal qcGoal); + + /** + * 新增质量目标 + * + * @param qcGoal 质量目标 + * @return 结果 + */ + public int insertQcGoal(QcGoal qcGoal); + + /** + * 批量插入 + * @param qcGoalList + * @return + */ + public int insertQcGoalList(@Param("qcGoalList") List qcGoalList); + + /** + * 修改质量目标 + * + * @param qcGoal 质量目标 + * @return 结果 + */ + public int updateQcGoal(QcGoal qcGoal); + + /** + * 删除质量目标 + * + * @param id 质量目标主键 + * @return 结果 + */ + public int deleteQcGoalById(String id); + + /** + * 批量删除质量目标 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteQcGoalByIds(String[] ids); + + public int getTodayMaxNum(QcGoal qcGoal); +} diff --git a/op-modules/op-quality/src/main/java/com/op/quality/service/impl/QcGoalDistributeServiceImpl.java b/op-modules/op-quality/src/main/java/com/op/quality/service/impl/QcGoalDistributeServiceImpl.java new file mode 100644 index 00000000..791311ee --- /dev/null +++ b/op-modules/op-quality/src/main/java/com/op/quality/service/impl/QcGoalDistributeServiceImpl.java @@ -0,0 +1,153 @@ +package com.op.quality.service.impl; + +import java.util.Date; +import java.util.List; + +import com.baomidou.dynamic.datasource.annotation.DS; +import com.op.common.core.utils.DateUtils; +import com.op.common.core.utils.StringUtils; +import com.op.common.core.utils.uuid.IdUtils; +import com.op.common.security.utils.SecurityUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.op.quality.mapper.QcGoalDistributeMapper; +import com.op.quality.domain.QcGoalDistribute; +import com.op.quality.service.IQcGoalDistributeService; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import javax.servlet.http.HttpServletRequest; + +/** + * 质量目标分配Service业务层处理 + * + * @author Open Platform + * @date 2024-03-07 + */ +@Service +public class QcGoalDistributeServiceImpl implements IQcGoalDistributeService { + @Autowired + private QcGoalDistributeMapper qcGoalDistributeMapper; + + /** + * 查询质量目标分配 + * + * @param id 质量目标分配主键 + * @return 质量目标分配 + */ + @Override + @DS("#header.poolName") + public QcGoalDistribute selectQcGoalDistributeById(String id) { + return qcGoalDistributeMapper.selectQcGoalDistributeById(id); + } + + /** + * 查询质量目标分配列表 + * + * @param qcGoalDistribute 质量目标分配 + * @return 质量目标分配 + */ + @Override + @DS("#header.poolName") + public List selectQcGoalDistributeList(QcGoalDistribute qcGoalDistribute) { + return qcGoalDistributeMapper.selectQcGoalDistributeList(qcGoalDistribute); + } + + /** + * 新增质量目标分配 + * + * @param qcGoalDistribute 质量目标分配 + * @return 结果 + */ + @Override + @DS("#header.poolName") + public int insertQcGoalDistribute(QcGoalDistribute qcGoalDistribute) { + + if (StringUtils.isNotEmpty(qcGoalDistribute.getBelongGoalId())) { + qcGoalDistributeMapper.deleteQcGoalDistributeByBelongId(qcGoalDistribute.getBelongGoalId()); + } + int count = 0; + if (qcGoalDistribute.getSelectedValues().size() > 0){ + QcGoalDistribute dto = null; + Date now = DateUtils.getNowDate(); + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + String key = "#header.poolName"; + String factoryCode = request.getHeader(key.substring(8)).replace("ds_", ""); + for (String supplierCode : qcGoalDistribute.getSelectedValues()) { + dto = new QcGoalDistribute(); + dto.setId(IdUtils.fastSimpleUUID()); + dto.setCreateTime(now); + dto.setCreateBy(SecurityUtils.getUsername()); + dto.setBelongGoalId(qcGoalDistribute.getBelongGoalId()); + dto.setSupplierCode(supplierCode); + dto.setFactoryCode(factoryCode); + count += qcGoalDistributeMapper.insertQcGoalDistribute(dto); + } + }else { + count = 1; + } + return count; + } + + /** + * 修改质量目标分配 + * + * @param qcGoalDistribute 质量目标分配 + * @return 结果 + */ + @Override + @DS("#header.poolName") + public int updateQcGoalDistribute(QcGoalDistribute qcGoalDistribute) { + qcGoalDistribute.setUpdateTime(DateUtils.getNowDate()); + return qcGoalDistributeMapper.updateQcGoalDistribute(qcGoalDistribute); + } + + /** + * 批量删除质量目标分配 + * + * @param ids 需要删除的质量目标分配主键 + * @return 结果 + */ + @Override + @DS("#header.poolName") + public int deleteQcGoalDistributeByIds(String[] ids) { + return qcGoalDistributeMapper.deleteQcGoalDistributeByIds(ids); + } + + /** + * 删除质量目标分配信息 + * + * @param id 质量目标分配主键 + * @return 结果 + */ + @Override + @DS("#header.poolName") + public int deleteQcGoalDistributeById(String id) { + return qcGoalDistributeMapper.deleteQcGoalDistributeById(id); + } + + @Override + @DS("#header.poolName") + public List getLeftList(QcGoalDistribute qcGoalDistribute) { + List dto = qcGoalDistributeMapper.getGoalDistributeUndo(qcGoalDistribute); + List selected = qcGoalDistributeMapper.getGoalDistributeDo(qcGoalDistribute); + dto.addAll(selected); + dto.forEach(item -> { + item.setKey(item.getSupplierCode()); + }); + return dto; + } + + @Override + @DS("#header.poolName") + public List getRightList(QcGoalDistribute qcGoalDistribute) { + List selected = qcGoalDistributeMapper.getGoalDistributeDo(qcGoalDistribute); + selected.forEach(item -> { + item.setKey(item.getSupplierCode()); + }); + return selected; + } + + + +} diff --git a/op-modules/op-quality/src/main/java/com/op/quality/service/impl/QcGoalServiceImpl.java b/op-modules/op-quality/src/main/java/com/op/quality/service/impl/QcGoalServiceImpl.java new file mode 100644 index 00000000..f3aa0a00 --- /dev/null +++ b/op-modules/op-quality/src/main/java/com/op/quality/service/impl/QcGoalServiceImpl.java @@ -0,0 +1,245 @@ +package com.op.quality.service.impl; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Date; +import java.util.Iterator; +import java.util.List; +import java.util.stream.Collectors; + +import com.baomidou.dynamic.datasource.annotation.DS; +import com.op.common.core.utils.DateUtils; +import com.op.common.security.utils.SecurityUtils; +import com.op.quality.domain.vo.TreeSelect; +import com.sun.xml.bind.v2.TODO; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.op.quality.mapper.QcGoalMapper; +import com.op.quality.domain.QcGoal; +import com.op.quality.service.IQcGoalService; +import org.springframework.util.ObjectUtils; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import javax.servlet.http.HttpServletRequest; + +/** + * 质量目标Service业务层处理 + * + * @author Open Platform + * @date 2024-03-04 + */ +@Service +public class QcGoalServiceImpl implements IQcGoalService { + @Autowired + private QcGoalMapper qcGoalMapper; + + /** + * 查询质量目标 + * + * @param id 质量目标主键 + * @return 质量目标 + */ + @Override + @DS("#header.poolName") + public QcGoal selectQcGoalById(String id) { + return qcGoalMapper.selectQcGoalById(id); + } + + /** + * 查询质量目标列表 + * + * @param qcGoal 质量目标 + * @return 质量目标 + */ + @Override + @DS("#header.poolName") + public List selectQcGoalList(QcGoal qcGoal) { + List qcGoals = qcGoalMapper.selectQcGoalList(qcGoal); + for (QcGoal item : qcGoals) { + item.setHasChildren(true); + } + return qcGoals; + } + + @Override + @DS("#header.poolName") + public List selectChildrenByParent(QcGoal goal) { + return qcGoalMapper.selectChildrenByParent(goal); + } + + @Override + @DS("#header.poolName") + public List buildQcGoalTreeSelect(List qcGoals) { + List qcGoalTrees = buildGoalTree(qcGoals); + return qcGoalTrees.stream().map(TreeSelect::new).collect(Collectors.toList()); + } + + /** + * 新增质量目标 + * + * @param qcGoal 质量目标 + * @return 结果 + */ + @Override + @DS("#header.poolName") + public int insertQcGoal(QcGoal qcGoal) { + qcGoal.setCreateTime(DateUtils.getNowDate()); + qcGoal.setCreateBy(SecurityUtils.getUsername()); + + qcGoal.setId(getSerialNumber(qcGoal)); + qcGoal.setFactoryCode(getFactoryCode()); + qcGoal.setParentGoal("0"); + + return qcGoalMapper.insertQcGoal(qcGoal); + } + + @Override + @DS("#header.poolName") + public List generate(String id) { + QcGoal goal = qcGoalMapper.selectQcGoalById(id); + List genResult = new ArrayList<>(); + + // 提前分配大小,有助于减少不必要的计算和内存分配,从而提高代码的性能。 + String goalYm = goal.getGoalYm(); + BigDecimal nookQualityRate = goal.getNookQualityRate(); + BigDecimal nookRate = goal.getNookRate(); + String checkType = goal.getCheckType(); + String typeCode = goal.getTypeCode(); + String factoryCode = getFactoryCode(); + String username = SecurityUtils.getUsername(); + Date nowDate = DateUtils.getNowDate(); + String parentGoal = goal.getId(); + + + int liushuiNum = qcGoalMapper.getTodayMaxNum(goal); + String dateNumber = DateUtils.parseDateToStr(DateUtils.YYYYMMDD, DateUtils.getNowDate()); + + int month = 12; + for (int i = 1; i <= month; i++) { + QcGoal monthGoal = new QcGoal(); + + String liushuiStr = String.format("%04d", liushuiNum+i-1); + monthGoal.setId(dateNumber+liushuiStr); + String mon = String.format("%02d",i); + monthGoal.setGoalYm(goalYm+"-"+mon); + monthGoal.setGoalType("mm"); + monthGoal.setNookQualityRate(nookQualityRate); + monthGoal.setNookRate(nookRate); + monthGoal.setCheckType(checkType); + monthGoal.setTypeCode(typeCode); + monthGoal.setScope(goal.getScope()); + monthGoal.setCreateTime(nowDate); + monthGoal.setCreateBy(username); + monthGoal.setFactoryCode(factoryCode); + monthGoal.setParentGoal(parentGoal); + genResult.add(monthGoal); + } + // 批量插入 + int flag = qcGoalMapper.insertQcGoalList(genResult); + if (flag > 0) { + return genResult; + }else { + return goal.getChildren(); + } + + } + + /** + * 修改质量目标 + * + * @param qcGoal 质量目标 + * @return 结果 + */ + @Override + @DS("#header.poolName") + public int updateQcGoal(QcGoal qcGoal) { + qcGoal.setUpdateTime(DateUtils.getNowDate()); + qcGoal.setUpdateBy(SecurityUtils.getUsername()); + return qcGoalMapper.updateQcGoal(qcGoal); + } + + /** + * 批量删除质量目标 + * + * @param ids 需要删除的质量目标主键 + * @return 结果 + */ + @Override + @DS("#header.poolName") + public int deleteQcGoalByIds(String[] ids) { + boolean flag = false; + for (String id : ids) { + QcGoal goal = new QcGoal(); + goal.setParentGoal(id); + List hasChildren = qcGoalMapper.selectChildrenByParent(goal); + if (hasChildren.size() > 0) { + flag = true; + break; + } + } + if (flag) { + return 0; + }else { + return qcGoalMapper.deleteQcGoalByIds(ids); + } + } + + /** + * 删除质量目标信息 + * + * @param id 质量目标主键 + * @return 结果 + */ + @Override + @DS("#header.poolName") + public int deleteQcGoalById(String id) { + return qcGoalMapper.deleteQcGoalById(id); + } + + @Override + public List buildGoalTree(List qcGoals) { + List returnList = new ArrayList<>(); + List tempList = qcGoals.stream().map(QcGoal::getId).collect(Collectors.toList()); + for (Iterator iterator = qcGoals.iterator(); iterator.hasNext(); ) { + QcGoal qcGoal = (QcGoal) iterator.next(); + //如果是顶级节点,遍历父节点的所有子节点 + if (!tempList.contains(qcGoal.getParentGoal())) { + List childList = getChildList(qcGoals,qcGoal); + qcGoal.setChildren(childList); + returnList.add(qcGoal); + } + } + if (returnList.isEmpty()) { + returnList = qcGoals; + } + return returnList; + } + + private List getChildList(List list, QcGoal t) { + List tlist = new ArrayList<>(); + Iterator it = list.iterator(); + while (it.hasNext()) { + QcGoal goal = (QcGoal) it.next(); + if (goal.getParentGoal().equals(t.getId())){ + tlist.add(goal); + } + } + return tlist; + } + + @DS("#header.poolName") + private String getSerialNumber(QcGoal qcGoal) { + int liushuiNum = qcGoalMapper.getTodayMaxNum(qcGoal); + String liushuiStr = String.format("%04d", liushuiNum); + String dateNumber = DateUtils.parseDateToStr(DateUtils.YYYYMMDD, DateUtils.getNowDate()); + return dateNumber + liushuiStr; + } + @DS("#header.poolName") + private String getFactoryCode() { + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + String key = "#header.poolName"; + return request.getHeader(key.substring(8)).replace("ds_", ""); + } + +} diff --git a/op-modules/op-quality/src/main/resources/mapper/quality/QcGoalDistributeMapper.xml b/op-modules/op-quality/src/main/resources/mapper/quality/QcGoalDistributeMapper.xml new file mode 100644 index 00000000..812578b7 --- /dev/null +++ b/op-modules/op-quality/src/main/resources/mapper/quality/QcGoalDistributeMapper.xml @@ -0,0 +1,218 @@ + + + + + + + + + + + + + + + + + + + + + + + select id, belong_goal_id, supplier_code, supplier_name, attr1, attr2, attr3, attr4, create_by, create_time, update_by, update_time, factory_code, del_flag from qc_goal_distribute + + + + + + + + insert into qc_goal_distribute + + id, + + belong_goal_id, + + supplier_code, + + supplier_name, + + attr1, + + attr2, + + attr3, + + attr4, + + create_by, + + create_time, + + update_by, + + update_time, + + factory_code, + + del_flag, + + + + #{id}, + + #{belongGoalId}, + + #{supplierCode}, + + #{supplierName}, + + #{attr1}, + + #{attr2}, + + #{attr3}, + + #{attr4}, + + #{createBy}, + + #{createTime}, + + #{updateBy}, + + #{updateTime}, + + #{factoryCode}, + + #{delFlag}, + + + + + + update qc_goal_distribute + + belong_goal_id = + #{belongGoalId}, + + supplier_code = + #{supplierCode}, + + supplier_name = + #{supplierName}, + + attr1 = + #{attr1}, + + attr2 = + #{attr2}, + + attr3 = + #{attr3}, + + attr4 = + #{attr4}, + + create_by = + #{createBy}, + + create_time = + #{createTime}, + + update_by = + #{updateBy}, + + update_time = + #{updateTime}, + + factory_code = + #{factoryCode}, + + del_flag = + #{delFlag}, + + + where id = #{id} + + + + delete from qc_goal_distribute where id = #{id} + + + + delete from qc_goal_distribute where id in + + #{id} + + + + + delete from qc_goal_distribute where belong_goal_id = #{belongGoalId} + + + + + + + + diff --git a/op-modules/op-quality/src/main/resources/mapper/quality/QcGoalMapper.xml b/op-modules/op-quality/src/main/resources/mapper/quality/QcGoalMapper.xml new file mode 100644 index 00000000..ea848188 --- /dev/null +++ b/op-modules/op-quality/src/main/resources/mapper/quality/QcGoalMapper.xml @@ -0,0 +1,261 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + select id, goal_ym, goal_type, noOk_rate, noOk_quality_rate, attr1, attr2, attr3, attr4, create_by, create_time, update_by, update_time, factory_code, del_flag, check_type, type_code, scope, parent_goal from qc_goal + + + + + + + + + + insert into qc_goal + + id, + + goal_ym, + + goal_type, + + noOk_rate, + + noOk_quality_rate, + + create_by, + + create_time, + + update_by, + + update_time, + + factory_code, + + del_flag, + + check_type, + + type_code, + + scope, + + parent_goal, + + + + #{id}, + + #{goalYm}, + + #{goalType}, + + #{nookRate}, + + #{nookQualityRate}, + + #{createBy}, + + #{createTime}, + + #{updateBy}, + + #{updateTime}, + + #{factoryCode}, + + #{delFlag}, + + #{checkType}, + + #{typeCode}, + + #{scope}, + + #{parentGoal}, + + + + + + insert into qc_goal(id,goal_ym,goal_type,noOk_rate,noOk_quality_rate,create_by,create_time, + update_by,update_time,factory_code,check_type,type_code,scope,parent_goal)values + + (#{item.id}, + #{item.goalYm}, + #{item.goalType}, + #{item.nookRate}, + #{item.nookQualityRate}, + #{item.createBy}, + #{item.createTime}, + #{item.updateBy}, + #{item.updateTime}, + #{item.factoryCode}, + #{item.checkType}, + #{item.typeCode}, + #{item.scope}, + #{item.parentGoal}) + + + + + + update qc_goal + + goal_ym = + #{goalYm}, + + goal_type = + #{goalType}, + + noOk_rate = + #{nookRate}, + + noOk_quality_rate = + #{nookQualityRate}, + + create_by = + #{createBy}, + + create_time = + #{createTime}, + + update_by = + #{updateBy}, + + update_time = + #{updateTime}, + + factory_code = + #{factoryCode}, + + del_flag = + #{delFlag}, + + check_type = + #{checkType}, + + type_code = + #{typeCode}, + + scope = + #{scope}, + + parent_goal = + #{parentGoal}, + + + where id = #{id} + + + + + delete from qc_goal where id = #{id} + + + + delete from qc_goal where id in + + #{id} + + +