Selaa lähdekoodia

新增质量问题反馈流程申请

wangliang 1 vuosi sitten
vanhempi
commit
5dc44a176b

+ 104 - 52
sop-business/src/main/java/com/qmth/sop/business/entity/TBQualityProblemApply.java

@@ -3,13 +3,19 @@ package com.qmth.sop.business.entity;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import com.qmth.sop.common.base.BaseEntity;
+import com.qmth.sop.common.contant.SystemConstant;
+import com.qmth.sop.common.enums.FlowApprovePassEnum;
 import com.qmth.sop.common.enums.InfluenceDegreeEnum;
 import com.qmth.sop.common.enums.QualityProblemReasonEnum;
 import com.qmth.sop.common.enums.QualityProblemTypeEnum;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
 import java.io.Serializable;
+import java.util.List;
 
 /**
  * <p>
@@ -19,19 +25,17 @@ import java.io.Serializable;
  * @author wangliang
  * @since 2023-08-01
  */
-@ApiModel(value="TBQualityProblemApply对象", description="质量问题反馈表")
-public class TBQualityProblemApply implements Serializable {
+@ApiModel(value = "TBQualityProblemApply对象", description = "质量问题反馈表")
+public class TBQualityProblemApply extends BaseEntity implements Serializable {
 
     private static final long serialVersionUID = 1L;
 
-    @ApiModelProperty(value = "主键")
-    @JsonSerialize(using = ToStringSerializer.class)
-    private Long id;
-
     @ApiModelProperty(value = "sop单号")
+    @NotBlank(message = "sop单号不能为空")
     private String sopNo;
 
     @ApiModelProperty(value = "crm单号")
+    @NotBlank(message = "crm单号不能为空")
     private String crmNo;
 
     @ApiModelProperty(value = "问题单号")
@@ -39,14 +43,20 @@ public class TBQualityProblemApply implements Serializable {
 
     @ApiModelProperty(value = "服务单元id")
     @JsonSerialize(using = ToStringSerializer.class)
+    @NotNull(message = "服务单元id不能为空")
     private Long serviceId;
 
     @ApiModelProperty(value = "问题简要")
+    @NotBlank(message = "问题简要不能为空")
     private String summary;
 
+    @ApiModelProperty(value = "问题情况说明")
+    @NotBlank(message = "问题情况说明不能为空")
+    private String remark;
+
     @ApiModelProperty(value = "责任人id")
     @JsonSerialize(using = ToStringSerializer.class)
-    private Long userId;
+    private String userIds;
 
     @ApiModelProperty(value = "问题类型,UPDATE:修正类,OPTIMIZE:优化类,NO_PROBLEM:不是问题")
     private QualityProblemTypeEnum type;
@@ -56,33 +66,107 @@ public class TBQualityProblemApply implements Serializable {
 
     @ApiModelProperty(value = "附件id")
     @JsonSerialize(using = ToStringSerializer.class)
-    private Long attachmentId;
+    private String attachmentIds;
 
     @ApiModelProperty(value = "影响度:A,B,C,D")
     @TableField("Influence_degree")
     private InfluenceDegreeEnum influenceDegree;
 
-    @ApiModelProperty(value = "创建人id")
-    @JsonSerialize(using = ToStringSerializer.class)
-    private Long createId;
+    @TableField(exist = false)
+    @ApiModelProperty(value = "流程部署id")
+    @NotNull(message = "流程部署id不能为空")
+    private String flowDeploymentId;
 
-    @ApiModelProperty(value = "创建时间")
-    private Long createTime;
+    @TableField(exist = false)
+    @ApiModelProperty(value = "流程操作")
+    @NotNull(message = "流程操作不能为空")
+    private FlowApprovePassEnum approve;
+
+    @TableField(exist = false)
+    @ApiModelProperty(value = "流程表单")
+    private String formProperties;
+
+    @TableField(exist = false)
+    @ApiModelProperty(value = "流程审批人")
+    private List<String> approveUserIds;
+
+    public TBQualityProblemApply() {
 
-    public String getProblemNo() {
-        return problemNo;
     }
 
-    public void setProblemNo(String problemNo) {
+    public TBQualityProblemApply(String sopNo, String crmNo, String problemNo, Long serviceId, String summary, String remark, String attachmentIds) {
+        setId(SystemConstant.getDbUuid());
+        this.sopNo = sopNo;
+        this.crmNo = crmNo;
         this.problemNo = problemNo;
+        this.serviceId = serviceId;
+        this.summary = summary;
+        this.remark = remark;
+        this.attachmentIds = attachmentIds;
+    }
+
+    public List<String> getApproveUserIds() {
+        return approveUserIds;
+    }
+
+    public void setApproveUserIds(List<String> approveUserIds) {
+        this.approveUserIds = approveUserIds;
+    }
+
+    public FlowApprovePassEnum getApprove() {
+        return approve;
+    }
+
+    public void setApprove(FlowApprovePassEnum approve) {
+        this.approve = approve;
+    }
+
+    public String getFormProperties() {
+        return formProperties;
+    }
+
+    public void setFormProperties(String formProperties) {
+        this.formProperties = formProperties;
+    }
+
+    public String getFlowDeploymentId() {
+        return flowDeploymentId;
+    }
+
+    public void setFlowDeploymentId(String flowDeploymentId) {
+        this.flowDeploymentId = flowDeploymentId;
+    }
+
+    public String getRemark() {
+        return remark;
+    }
+
+    public void setRemark(String remark) {
+        this.remark = remark;
+    }
+
+    public String getUserIds() {
+        return userIds;
+    }
+
+    public void setUserIds(String userIds) {
+        this.userIds = userIds;
+    }
+
+    public String getAttachmentIds() {
+        return attachmentIds;
+    }
+
+    public void setAttachmentIds(String attachmentIds) {
+        this.attachmentIds = attachmentIds;
     }
 
-    public Long getId() {
-        return id;
+    public String getProblemNo() {
+        return problemNo;
     }
 
-    public void setId(Long id) {
-        this.id = id;
+    public void setProblemNo(String problemNo) {
+        this.problemNo = problemNo;
     }
 
     public String getSopNo() {
@@ -117,14 +201,6 @@ public class TBQualityProblemApply implements Serializable {
         this.summary = summary;
     }
 
-    public Long getUserId() {
-        return userId;
-    }
-
-    public void setUserId(Long userId) {
-        this.userId = userId;
-    }
-
     public QualityProblemTypeEnum getType() {
         return type;
     }
@@ -141,14 +217,6 @@ public class TBQualityProblemApply implements Serializable {
         this.reason = reason;
     }
 
-    public Long getAttachmentId() {
-        return attachmentId;
-    }
-
-    public void setAttachmentId(Long attachmentId) {
-        this.attachmentId = attachmentId;
-    }
-
     public InfluenceDegreeEnum getInfluenceDegree() {
         return influenceDegree;
     }
@@ -156,20 +224,4 @@ public class TBQualityProblemApply implements Serializable {
     public void setInfluenceDegree(InfluenceDegreeEnum influenceDegree) {
         this.influenceDegree = influenceDegree;
     }
-
-    public Long getCreateId() {
-        return createId;
-    }
-
-    public void setCreateId(Long createId) {
-        this.createId = createId;
-    }
-
-    public Long getCreateTime() {
-        return createTime;
-    }
-
-    public void setCreateTime(Long createTime) {
-        this.createTime = createTime;
-    }
 }

+ 8 - 0
sop-business/src/main/java/com/qmth/sop/business/service/SequenceService.java

@@ -29,4 +29,12 @@ public interface SequenceService extends IService<Sequence> {
      * @return
      */
     String createFlowCode(TFCustomTypeEnum tfCustomTypeEnum) throws InterruptedException;
+
+    /**
+     * 创建CRM编号
+     *
+     * @param crm
+     * @return
+     */
+    String createCrmCode(String crm) throws InterruptedException;
 }

+ 9 - 1
sop-business/src/main/java/com/qmth/sop/business/service/TBQualityProblemApplyService.java

@@ -1,7 +1,7 @@
 package com.qmth.sop.business.service;
 
-import com.qmth.sop.business.entity.TBQualityProblemApply;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.qmth.sop.business.entity.TBQualityProblemApply;
 
 /**
  * <p>
@@ -13,4 +13,12 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface TBQualityProblemApplyService extends IService<TBQualityProblemApply> {
 
+    /**
+     * \
+     * 质量问题反馈信息保存/修改
+     *
+     * @param tbQualityProblemApply
+     * @return
+     */
+    Boolean saveOrUpdateInfo(TBQualityProblemApply tbQualityProblemApply) throws InterruptedException;
 }

+ 14 - 0
sop-business/src/main/java/com/qmth/sop/business/service/impl/SequenceServiceImpl.java

@@ -78,4 +78,18 @@ public class SequenceServiceImpl extends ServiceImpl<SequenceMapper, Sequence> i
         String sequence = String.format("%0" + sysConfig.getConfigValue() + "d", this.selectNextVal(tfCustomTypeEnum.getCode()));
         return tfCustomTypeEnum.getMark() + sequence;
     }
+
+    /**
+     * 创建CRM编号
+     *
+     * @param crm
+     * @return
+     * @throws InterruptedException
+     */
+    @Override
+    public String createCrmCode(String crm) throws InterruptedException {
+        SysConfig sysConfig = commonCacheService.addSysConfigCache(SystemConstant.FLOW_CODE_LENGTH);
+        Optional.ofNullable(sysConfig).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程编码长度未设置"));
+        return String.format("%0" + sysConfig.getConfigValue() + "d", this.selectNextVal(crm));
+    }
 }

+ 47 - 1
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBQualityProblemApplyServiceImpl.java

@@ -1,10 +1,22 @@
 package com.qmth.sop.business.service.impl;
 
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.qmth.sop.business.activiti.service.ActivitiService;
 import com.qmth.sop.business.entity.TBQualityProblemApply;
 import com.qmth.sop.business.mapper.TBQualityProblemApplyMapper;
+import com.qmth.sop.business.service.SequenceService;
 import com.qmth.sop.business.service.TBQualityProblemApplyService;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.qmth.sop.business.service.TFCustomFlowEntityService;
+import com.qmth.sop.common.enums.TFCustomTypeEnum;
+import com.qmth.sop.common.util.ServletUtil;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
 
 /**
  * <p>
@@ -17,4 +29,38 @@ import org.springframework.stereotype.Service;
 @Service
 public class TBQualityProblemApplyServiceImpl extends ServiceImpl<TBQualityProblemApplyMapper, TBQualityProblemApply> implements TBQualityProblemApplyService {
 
+    @Resource
+    TFCustomFlowEntityService tfCustomFlowEntityService;
+
+    @Resource
+    ActivitiService activitiService;
+
+    @Resource
+    SequenceService sequenceService;
+
+    /**
+     * 质量问题反馈信息保存/修改
+     *
+     * @param tbQualityProblemApply
+     * @return
+     */
+    @Override
+    @Transactional
+    public Boolean saveOrUpdateInfo(TBQualityProblemApply tbQualityProblemApply) throws InterruptedException {
+        HttpServletRequest request = ServletUtil.getRequest();
+        Map<String, Object> map = new HashMap<>();
+        Map<String, String> formDataMap = new HashMap<>();
+        Map<String, String[]> parameterMap = request.getParameterMap();
+        Set<Map.Entry<String, String[]>> entrySet = parameterMap.entrySet();
+        for (Map.Entry<String, String[]> entry : entrySet) {
+            String key = entry.getKey();
+            String[] value = entry.getValue();
+            formDataMap.put(key, value[0]);
+        }
+        map.putAll(formDataMap);
+        Map<String, Object> resultMap = activitiService.taskApprove(tbQualityProblemApply.getFlowDeploymentId(), tbQualityProblemApply.getApprove(), null, null, tbQualityProblemApply.getFormProperties(), tbQualityProblemApply.getApproveUserIds(), null, map);
+        String problemNo = sequenceService.createFlowCode(TFCustomTypeEnum.QUALITY_PROBLEM_FLOW);
+        tbQualityProblemApply.setProblemNo(problemNo);
+        return this.saveOrUpdate(tbQualityProblemApply);
+    }
 }

+ 56 - 0
sop-business/src/main/resources/db/log/wangliang_update_log.sql

@@ -415,3 +415,59 @@ VALUES(19, NULL, 'flow.code.length', '流程编码长度', '10', NULL, 1, 1, 1,
 
 ALTER TABLE t_f_custom_flow_entity MODIFY COLUMN code varchar(20) CHARACTER SET utf8mb4 NOT NULL COMMENT '编号';
 ALTER TABLE t_f_custom_flow_entity ADD CONSTRAINT t_f_custom_flow_entity_UN_code UNIQUE KEY (code,flow_id);
+
+DELETE FROM sys_privilege
+WHERE id=22;
+
+UPDATE sys_privilege
+SET name='质量监控分析', url='qualityProblemControl', `type`='MENU', parent_id=20, `sequence`=2, property=NULL, related=NULL, enable=1, default_auth=0, front_display=1
+WHERE id=23;
+
+ALTER TABLE t_b_quality_problem_apply CHANGE COLUMN sop_no sop_no VARCHAR(100)
+    COMMENT 'sop单号' NOT NULL;
+
+ALTER TABLE t_b_quality_problem_apply CHANGE COLUMN crm_no crm_no VARCHAR(100)
+    COMMENT 'crm单号' NOT NULL;
+
+ALTER TABLE t_b_quality_problem_apply CHANGE COLUMN service_id service_id BIGINT
+    COMMENT '服务单元id' NOT NULL;
+
+ALTER TABLE t_b_quality_problem_apply CHANGE COLUMN type type VARCHAR(20)
+    COMMENT '问题类型,UPDATE:修正类,OPTIMIZE:优化类,NO_PROBLEM:不是问题' NULL;
+
+ALTER TABLE t_b_quality_problem_apply CHANGE COLUMN reason reason VARCHAR(20)
+    COMMENT '问题原因类型,EXEC:执行类,MANAGER:管理协调类,FLOW:流程制度类,PRODUCT_PROBLEM:产品缺陷类,PRODUCT_MANAGER:产品运维类,OTHER:其它' NULL;
+
+ALTER TABLE t_b_quality_problem_apply CHANGE COLUMN user_id user_ids VARCHAR(500)
+    COMMENT '责任人id数组' NULL;
+
+ALTER TABLE t_b_quality_problem_apply CHANGE COLUMN attachment_id attachment_ids VARCHAR(500)
+    COMMENT '附件id数组' NULL;
+
+ALTER TABLE t_b_quality_problem_apply ADD remark VARCHAR(500)
+    COMMENT '问题情况说明' NOT NULL after summary;
+
+ALTER TABLE t_b_quality_problem_apply ADD update_id BIGINT
+    COMMENT '更新人id' NULL after create_time;
+
+ALTER TABLE t_b_quality_problem_apply ADD update_time BIGINT
+    COMMENT '更新时间' NULL after update_id;
+
+UPDATE sys_privilege
+SET name='作废', url='Cancel', `type`='BUTTON', parent_id=21, `sequence`=1, property='AUTH', related='3019', enable=1, default_auth=0, front_display=1
+WHERE id=128;
+UPDATE sys_privilege
+SET name='查询', url='Select', `type`='BUTTON', parent_id=21, `sequence`=2, property='AUTH', related='3018', enable=1, default_auth=0, front_display=1
+WHERE id=130;
+UPDATE sys_privilege
+SET name='上报质量问题', url='ProblemSubmit', `type`='LINK', parent_id=41, `sequence`=5, property='AUTH', related='3017', enable=1, default_auth=0, front_display=1
+WHERE id=179;
+INSERT INTO sys_privilege
+(id, name, url, `type`, parent_id, `sequence`, property, related, enable, default_auth, front_display)
+VALUES(3017, '质量问题反馈申请接口', '/api/admin/quality/problem/apply', 'URL', 41, 1, 'AUTH', NULL, 1, 1, 0);
+INSERT INTO sys_privilege
+(id, name, url, `type`, parent_id, `sequence`, property, related, enable, default_auth, front_display)
+VALUES(3018, '质量问题反馈查询接口', '/api/admin/quality/problem/list', 'URL', 21, 1, 'AUTH', NULL, 1, 1, 0);
+INSERT INTO sys_privilege
+(id, name, url, `type`, parent_id, `sequence`, property, related, enable, default_auth, front_display)
+VALUES(3019, '质量问题反馈作废接口', '/api/admin/quality/problem/cancel', 'URL', 21, 2, 'AUTH', NULL, 1, 1, 0);

+ 1 - 0
sop-common/src/main/java/com/qmth/sop/common/contant/SystemConstant.java

@@ -146,6 +146,7 @@ public class SystemConstant {
     public static final String PREFIX_URL_VIOLATION = "/admin/tb/violation";
     public static final String PREFIX_URL_VIOLATION_DETAIL = "/admin/tb/violation/detail";
     public static final String PREFIX_URL_DING = "/admin/tb/ding";
+    public static final String PREFIX_URL_QUALITY_PROBLEM = "/admin/quality/problem";
 
     /**
      * 缓存配置

+ 45 - 4
sop-server/src/main/java/com/qmth/sop/server/api/TBQualityProblemApplyController.java

@@ -1,9 +1,21 @@
 package com.qmth.sop.server.api;
 
+import com.qmth.boot.api.constant.ApiConstant;
+import com.qmth.sop.business.entity.TBQualityProblemApply;
+import com.qmth.sop.business.service.TBQualityProblemApplyService;
+import com.qmth.sop.common.contant.SystemConstant;
+import com.qmth.sop.common.util.Result;
+import com.qmth.sop.common.util.ResultUtil;
+import io.swagger.annotations.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.validation.BindingResult;
+import org.springframework.web.bind.annotation.*;
 
-import org.springframework.web.bind.annotation.RequestMapping;
-
-import org.springframework.web.bind.annotation.RestController;
+import javax.annotation.Resource;
+import javax.validation.Valid;
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
 
 /**
  * <p>
@@ -13,8 +25,37 @@ import org.springframework.web.bind.annotation.RestController;
  * @author wangliang
  * @since 2023-08-01
  */
+@Api(tags = "质量问题反馈Controller")
 @RestController
-@RequestMapping("/t-bquality-problem-apply")
+@RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + SystemConstant.PREFIX_URL_QUALITY_PROBLEM)
 public class TBQualityProblemApplyController {
+    private final static Logger log = LoggerFactory.getLogger(TBQualityProblemApplyController.class);
+
+    @Resource
+    TBQualityProblemApplyService tbQualityProblemApplyService;
+
+    @ApiOperation(value = "质量问题反馈申请")
+    @RequestMapping(value = "/apply", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
+    public Result apply(@Valid @RequestBody TBQualityProblemApply tbQualityProblemApply, BindingResult bindingResult) throws InterruptedException {
+        if (bindingResult.hasErrors()) {
+            return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
+        }
+        return ResultUtil.ok(tbQualityProblemApplyService.saveOrUpdateInfo(tbQualityProblemApply));
+    }
+
+    @ApiOperation(value = "质量问题反馈查询")
+    @RequestMapping(value = "/list", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
+    public Result list(@ApiParam(value = "页码", required = true) @RequestParam @Min(SystemConstant.PAGE_NUMBER_MIN) Integer pageNumber,
+                       @ApiParam(value = "页数", required = true) @RequestParam @Min(SystemConstant.PAGE_SIZE_MIN) @Max(SystemConstant.PAGE_SIZE_MAX) Integer pageSize) {
+        return ResultUtil.ok();
+    }
 
+    @ApiOperation(value = "质量问题反馈作废")
+    @RequestMapping(value = "/cancel", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
+    public Result cancel() {
+        return ResultUtil.ok();
+    }
 }