Commit d1f06a20 by jx-art

Merge branch 'feature-changeFlow-221110' of…

Merge branch 'feature-changeFlow-221110' of https://yxwbgit.mail.netease.com/yx-qc-change-flow/yanxuan-qc-change-system into feature-changeFlow-221110
parents 8d0cee48 d9758754
...@@ -41,7 +41,7 @@ CREATE TABLE `TB_YX_CHANGE_TYPE` ...@@ -41,7 +41,7 @@ CREATE TABLE `TB_YX_CHANGE_TYPE`
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='变更类型表'; ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='变更类型表';
CREATE TABLE `TB_YX_CHANGE_RECORD` CREATE TABLE `tb_yx_change_record`
( (
`id` bigint(20) NOT NULL AUTO_INCREMENT, `id` bigint(20) NOT NULL AUTO_INCREMENT,
`flow_id` bigint(20) NOT NULL COMMENT '工单id', `flow_id` bigint(20) NOT NULL COMMENT '工单id',
...@@ -49,6 +49,7 @@ CREATE TABLE `TB_YX_CHANGE_RECORD` ...@@ -49,6 +49,7 @@ CREATE TABLE `TB_YX_CHANGE_RECORD`
`change_subject` int(11) NOT NULL COMMENT '变更主体', `change_subject` int(11) NOT NULL COMMENT '变更主体',
`parent_change_class_id` int(11) NOT NULL COMMENT '一级变更类型id', `parent_change_class_id` int(11) NOT NULL COMMENT '一级变更类型id',
`son_change_class_id` int(11) NOT NULL COMMENT '二级变更类型id', `son_change_class_id` int(11) NOT NULL COMMENT '二级变更类型id',
`change_level` int(11) NOT NULL COMMENT '变更等级',
`change_commander` varchar(20) NOT NULL COMMENT '变更负责人', `change_commander` varchar(20) NOT NULL COMMENT '变更负责人',
`change_item` varchar(20) NOT NULL COMMENT '变更商品(变更主体为商品时有效)', `change_item` varchar(20) NOT NULL COMMENT '变更商品(变更主体为商品时有效)',
`change_supplier` varchar(20) NOT NULL COMMENT '变更供应商(变更主体为供应商时有效)', `change_supplier` varchar(20) NOT NULL COMMENT '变更供应商(变更主体为供应商时有效)',
...@@ -56,7 +57,7 @@ CREATE TABLE `TB_YX_CHANGE_RECORD` ...@@ -56,7 +57,7 @@ CREATE TABLE `TB_YX_CHANGE_RECORD`
`change_content` varchar(500) NOT NULL COMMENT '变更内容', `change_content` varchar(500) NOT NULL COMMENT '变更内容',
`change_risk_desc` varchar(255) NOT NULL COMMENT '变更潜在风险描述', `change_risk_desc` varchar(255) NOT NULL COMMENT '变更潜在风险描述',
`change_checking` varchar(255) NOT NULL COMMENT '变更验证措施', `change_checking` varchar(255) NOT NULL COMMENT '变更验证措施',
`change_profit` varchar(255) NOT NULL COMMENT '变更收益', `change_profit` int(10) NOT NULL COMMENT '变更收益',
`change_profit_desc` varchar(255) NOT NULL COMMENT '变更收益说明', `change_profit_desc` varchar(255) NOT NULL COMMENT '变更收益说明',
`change_confirm_result_time` bigint(20) NOT NULL COMMENT '变更结果确认时间', `change_confirm_result_time` bigint(20) NOT NULL COMMENT '变更结果确认时间',
`state` int(2) NOT NULL COMMENT '工单状态', `state` int(2) NOT NULL COMMENT '工单状态',
...@@ -70,7 +71,7 @@ CREATE TABLE `TB_YX_CHANGE_RECORD` ...@@ -70,7 +71,7 @@ CREATE TABLE `TB_YX_CHANGE_RECORD`
`create_time` bigint(20) NOT NULL COMMENT '创建时间', `create_time` bigint(20) NOT NULL COMMENT '创建时间',
`update_time` bigint(20) NOT NULL COMMENT '更新时间', `update_time` bigint(20) NOT NULL COMMENT '更新时间',
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='变更工单记录表'; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='变更工单记录表';
CREATE TABLE `TB_YX_CHANGE_FILE` CREATE TABLE `TB_YX_CHANGE_FILE`
( (
......
/**
* @(#)ChangeFlowBiz.java, 2022/11/15.
* <p/>
* Copyright 2022 Netease, Inc. All rights reserved.
* NETEASE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
package com.netease.mail.yanxuan.change.biz.biz;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import com.netease.mail.yanxuan.change.biz.config.AppConfig;
import com.netease.mail.yanxuan.change.biz.service.ChangeFlowService;
import com.netease.mail.yanxuan.change.biz.service.change.ChangeConfigService;
import com.netease.mail.yanxuan.change.common.enums.ChangeStatusEnum;
import com.netease.mail.yanxuan.change.common.enums.ChangeSubjectEnum;
import com.netease.mail.yanxuan.change.common.enums.NeedFileEnum;
import com.netease.mail.yanxuan.change.common.util.DateUtils;
import com.netease.mail.yanxuan.change.dal.entity.ChangeConfig;
import com.netease.mail.yanxuan.change.dal.entity.ChangeRecord;
import com.netease.mail.yanxuan.change.dal.meta.model.req.ChangeFlowCreateReq;
/**
* @Author zcwang
* @Date 2022/11/15
*/
@Component
public class ChangeFlowBiz {
@Autowired
private ChangeConfigService changeConfigService;
@Autowired
private ChangeFlowService changeFlowService;
@Autowired
private AppConfig appConfig;
public Boolean createAndSubmit(ChangeFlowCreateReq changeFlowCreateReq) {
// 校验变更主体
Boolean containsChangeSubject = ChangeSubjectEnum.getByType(changeFlowCreateReq.getChangeSubject());
Assert.isTrue(containsChangeSubject, "变更主体不存在");
// 检验是否需要资料
ChangeConfig changeConfig = changeConfigService.queryChangeConfig(changeFlowCreateReq.getSonChangeClassId());
Assert.notNull(changeConfig, "二级变更类型不存在");
Integer needFile = changeConfig.getNeedFile();
if (NeedFileEnum.NEED.getStatus().equals(needFile)) {
Assert.notEmpty(changeFlowCreateReq.getFiles(), "必须上传资料");
}
// 变更行动项不可为空,最多20项
Assert.isTrue(changeFlowCreateReq.getChangeExecProject().size() <= appConfig.getChangeExecLimit(),
"变更行动方案配置数超限");
// 结束时间不可晚于第二天定时任务执行时间
Long tomorrowSpecificTime = DateUtils.getTomorrowSpecificTime("09:00:00");
Assert.isTrue(changeFlowCreateReq.getChangeConfirmResultTime() >= tomorrowSpecificTime, "时间不可晚于下次执行时间");
// 创建并提交工作流
// 保存工单数据
ChangeRecord changeRecord = buildRecord(changeFlowCreateReq);
changeFlowService.saveRecord(changeRecord);
return null;
}
private ChangeRecord buildRecord(ChangeFlowCreateReq changeFlowCreateReq) {
ChangeRecord changeRecord = new ChangeRecord();
// todo
changeRecord.setFlowId(1L);
// todo
changeRecord.setFlowNode("1");
changeRecord.setChangeSubject(changeFlowCreateReq.getChangeSubject());
changeRecord.setParentChangeClassId(changeFlowCreateReq.getParentChangeClassId());
changeRecord.setSonChangeClassId(changeFlowCreateReq.getSonChangeClassId());
changeRecord.setChangeLevel(changeFlowCreateReq.getChangeLevel());
changeRecord.setChangeCommander(changeFlowCreateReq.getChangeCommander());
changeRecord.setChangeItem(changeFlowCreateReq.getChangeItems());
changeRecord.setChangeSupplier(changeFlowCreateReq.getChangeSupplier());
changeRecord.setChangeReason(changeFlowCreateReq.getChangeReason());
changeRecord.setChangeContent(changeFlowCreateReq.getChangeContent());
changeRecord.setChangeRiskDesc(changeFlowCreateReq.getChangeRiskDesc());
changeRecord.setChangeProfit(changeFlowCreateReq.getChangeProfit());
changeRecord.setChangeProfitDesc(changeFlowCreateReq.getChangeProfitDesc());
changeRecord.setChangeConfirmResultTime(changeFlowCreateReq.getChangeConfirmResultTime());
changeRecord.setState(ChangeStatusEnum.IN.getStatus());
changeRecord.setIsCancel(0);
// 变更结论
changeRecord.setChangeResult(1);
changeRecord.setCreateSource(changeFlowCreateReq.getCreateSource());
changeRecord.setCreateSupplier(changeFlowCreateReq.getChangeSupplier());
changeRecord.setChangeResultDesc("");
changeRecord.setRemark("");
changeRecord.setCreator("");
changeRecord.setCreateTime(DateUtils.getCurrentTime());
changeRecord.setUpdateTime(DateUtils.getCurrentTime());
return changeRecord;
}
}
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
*/ */
package com.netease.mail.yanxuan.change.biz.config; package com.netease.mail.yanxuan.change.biz.config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import com.ctrip.framework.apollo.spring.annotation.EnableAutoUpdateApolloConfig; import com.ctrip.framework.apollo.spring.annotation.EnableAutoUpdateApolloConfig;
...@@ -24,4 +25,7 @@ public class AppConfig { ...@@ -24,4 +25,7 @@ public class AppConfig {
@ValueMapping("${titleConfig:null}") @ValueMapping("${titleConfig:null}")
private TitleConfig titleConfig; private TitleConfig titleConfig;
@Value("${changeExecLimit:20}")
private Integer changeExecLimit;
} }
\ No newline at end of file
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
package com.netease.mail.yanxuan.change.biz.service; package com.netease.mail.yanxuan.change.biz.service;
import com.netease.mail.yanxuan.change.biz.config.TitleConfig; import com.netease.mail.yanxuan.change.biz.config.TitleConfig;
import com.netease.mail.yanxuan.change.dal.entity.ChangeRecord;
import com.netease.mail.yanxuan.change.dal.meta.model.vo.ChangeFlowVO;
/** /**
* @Author zcwang * @Author zcwang
...@@ -19,4 +21,6 @@ public interface ChangeFlowService { ...@@ -19,4 +21,6 @@ public interface ChangeFlowService {
* @return * @return
*/ */
TitleConfig getTitleConfig(); TitleConfig getTitleConfig();
Integer saveRecord(ChangeRecord changeRecord);
} }
\ No newline at end of file
...@@ -12,6 +12,9 @@ import org.springframework.stereotype.Service; ...@@ -12,6 +12,9 @@ import org.springframework.stereotype.Service;
import com.netease.mail.yanxuan.change.biz.config.AppConfig; import com.netease.mail.yanxuan.change.biz.config.AppConfig;
import com.netease.mail.yanxuan.change.biz.config.TitleConfig; import com.netease.mail.yanxuan.change.biz.config.TitleConfig;
import com.netease.mail.yanxuan.change.biz.service.ChangeFlowService; import com.netease.mail.yanxuan.change.biz.service.ChangeFlowService;
import com.netease.mail.yanxuan.change.dal.entity.ChangeRecord;
import com.netease.mail.yanxuan.change.dal.mapper.ChangeRecordMapper;
import com.netease.mail.yanxuan.change.dal.meta.model.vo.ChangeFlowVO;
/** /**
* @Author zcwang * @Author zcwang
...@@ -21,10 +24,18 @@ import com.netease.mail.yanxuan.change.biz.service.ChangeFlowService; ...@@ -21,10 +24,18 @@ import com.netease.mail.yanxuan.change.biz.service.ChangeFlowService;
public class ChangeFlowServiceImpl implements ChangeFlowService { public class ChangeFlowServiceImpl implements ChangeFlowService {
@Autowired @Autowired
private ChangeRecordMapper changeRecordMapper;
@Autowired
private AppConfig appConfig; private AppConfig appConfig;
@Override @Override
public TitleConfig getTitleConfig() { public TitleConfig getTitleConfig() {
return appConfig.getTitleConfig(); return appConfig.getTitleConfig();
} }
@Override
public Integer saveRecord(ChangeRecord changeRecord) {
return changeRecordMapper.insertSelective(changeRecord);
}
} }
\ No newline at end of file
...@@ -9,12 +9,13 @@ package com.netease.mail.yanxuan.change.common.enums; ...@@ -9,12 +9,13 @@ package com.netease.mail.yanxuan.change.common.enums;
/** /**
* @Author zcwang * @Author zcwang
* @Date 2022/11/14 * @Date 2022/11/14
* 变更主体枚举
*/ */
public enum ChangeSubjectEnum { public enum ChangeSubjectEnum {
PRODUCT(1, "商品变更"), PRODUCT(1, "商品变更"),
SUPPLIER(2, "供应商变更"), SUPPLIER(2, "供应商变更"),
Other(3, "其他变更"); OTHER(3, "其他变更");
private Integer type; private Integer type;
...@@ -32,4 +33,13 @@ public enum ChangeSubjectEnum { ...@@ -32,4 +33,13 @@ public enum ChangeSubjectEnum {
public String getDesc() { public String getDesc() {
return desc; return desc;
} }
public static Boolean getByType(Integer type) {
for (ChangeSubjectEnum value : ChangeSubjectEnum.values()) {
if (value.getType().equals(type)) {
return true;
}
}
return false;
}
} }
\ No newline at end of file
/**
* @(#)NeedFileEnum.java, 2022/11/15.
* <p/>
* Copyright 2022 Netease, Inc. All rights reserved.
* NETEASE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
package com.netease.mail.yanxuan.change.common.enums;
/**
* @Author zcwang
* @Date 2022/11/15
*/
public enum NeedFileEnum {
NEED(1, "需要上传文件"),
NOT_NEED(2, "无需上传文件");
private Integer status;
private String desc;
NeedFileEnum(Integer status, String desc) {
this.status = status;
this.desc = desc;
}
public Integer getStatus() {
return status;
}
}
\ No newline at end of file
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
<groupId>redis.clients</groupId> <groupId>redis.clients</groupId>
<artifactId>jedis</artifactId> <artifactId>jedis</artifactId>
</dependency> </dependency>
<dependency> <!--<dependency>
<groupId>org.springframework.data</groupId> <groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId> <artifactId>spring-data-redis</artifactId>
</dependency> </dependency>
......
...@@ -50,12 +50,17 @@ public class ChangeRecord { ...@@ -50,12 +50,17 @@ public class ChangeRecord {
/** /**
* 一级变更类型id * 一级变更类型id
*/ */
private Integer parentChangeClassId; private Long parentChangeClassId;
/** /**
* 二级变更类型id * 二级变更类型id
*/ */
private Integer sonChangeClassId; private Long sonChangeClassId;
/**
* 变更等级
*/
private Integer changeLevel;
/** /**
* 变更负责人 * 变更负责人
...@@ -63,6 +68,16 @@ public class ChangeRecord { ...@@ -63,6 +68,16 @@ public class ChangeRecord {
private String changeCommander; private String changeCommander;
/** /**
* 变更负责部门名
*/
private String changeDepartment;
/**
* 参与变更行动部门,json格式,查询用
*/
private String participateChangeExecDepartment;
/**
* 变更商品(变更主体为商品时有效) * 变更商品(变更主体为商品时有效)
*/ */
private String changeItem; private String changeItem;
...@@ -88,14 +103,9 @@ public class ChangeRecord { ...@@ -88,14 +103,9 @@ public class ChangeRecord {
private String changeRiskDesc; private String changeRiskDesc;
/** /**
* 变更验证措施 * 变更收益类型
*/
private String changeChecking;
/**
* 变更收益
*/ */
private String changeProfit; private Integer changeProfit;
/** /**
* 变更收益说明 * 变更收益说明
......
/**
* @(#)ChangeExecConfigReq.java, 2022/11/15.
* <p/>
* Copyright 2022 Netease, Inc. All rights reserved.
* NETEASE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
package com.netease.mail.yanxuan.change.dal.meta.model.req;
import lombok.Data;
/**
* @Author zcwang
* @Date 2022/11/15
*/
@Data
public class ChangeExecConfigReq {
/**
* 变更类型配置记录id
*/
private Long changeTemplateId;
/**
* 变更执行部门名
*/
private String changeExecDepartment;
/**
* 变更行动人类型
*/
private Integer changeExecUserType;
/**
* 变更行动人(不同类型存储不同内容)
*/
private String changeExecUser;
/**
* 变更风险描述
*/
private String changeRiskDesc;
/**
* 行动项
*/
private String changeExecProject;
/**
* 变更验证措施
*/
private String changeChecking;
}
\ No newline at end of file
/**
* @(#)ChangeFlowCreateReq.java, 2022/11/15.
* <p/>
* Copyright 2022 Netease, Inc. All rights reserved.
* NETEASE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
package com.netease.mail.yanxuan.change.dal.meta.model.req;
import java.util.List;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import lombok.Data;
/**
* @Author zcwang
* @Date 2022/11/15
*/
@Data
public class ChangeFlowCreateReq {
/**
* 变更主体
*/
@NotNull(message = "变更主体不能为空")
private Integer changeSubject;
/**
* 一级变更类型id
*/
@NotNull(message = "一级变更类型不能为空")
private Long parentChangeClassId;
/**
* 二级变更类型id
*/
@NotNull(message = "二级变更类型不能为空")
private Long sonChangeClassId;
/**
* 变更等级
*/
@NotNull(message = "变更等级不能为空")
private Integer changeLevel;
/**
* 变更负责人
*/
private String changeCommander;
/**
* 变更负责部门名
*/
private String changeDepartment;
/**
* 变更商品列表
*/
private String changeItems;
/**
* 变更供应商
*/
private String changeSupplier;
/**
* 变更原因
*/
@NotBlank(message = "变更原因不能为空")
@Size(max = 500,message = "变更原因限500字")
private String changeReason;
/**
* 变更内容
*/
@NotBlank(message = "变更内容不能为空")
@Size(max = 500,message = "变更内容限500字")
private String changeContent;
/**
* 变更工单附件
*/
private List<ChangeFlowFile> files;
/**
* 变更潜在风险
*/
private String changeRiskDesc;
/**
* 变更收益类型
*/
@NotNull(message = "变更收益类型不能为空")
private Integer changeProfit;
/**
* 变更收益说明
*/
@NotBlank(message = "变更收益说明不能为空")
@Size(max = 500, message = "变更收益说明限500字")
private String changeProfitDesc;
/**
* 变更结果确认时间
*/
@NotNull(message = "变更结果确认时间不能为空")
private Long changeConfirmResultTime;
/**
* 行动项
*/
@NotEmpty(message = "变更行动项不可为空")
private List<ChangeExecConfigReq> changeExecProject;
/**
* 创建端(普通or同舟)
*/
@NotNull(message = "创建端不能为空")
private Integer createSource;
}
\ No newline at end of file
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
*/ */
package com.netease.mail.yanxuan.change.web.controller; package com.netease.mail.yanxuan.change.web.controller;
import javax.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
...@@ -13,15 +15,21 @@ import org.springframework.web.bind.annotation.RequestBody; ...@@ -13,15 +15,21 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSON;
import com.netease.mail.yanxuan.change.biz.biz.ChangeFlowBiz;
import com.netease.mail.yanxuan.change.biz.config.TitleConfig; import com.netease.mail.yanxuan.change.biz.config.TitleConfig;
import com.netease.mail.yanxuan.change.biz.meta.AjaxResult; import com.netease.mail.yanxuan.change.biz.meta.AjaxResult;
import com.netease.mail.yanxuan.change.biz.service.ChangeFlowService; import com.netease.mail.yanxuan.change.biz.service.ChangeFlowService;
import com.netease.mail.yanxuan.change.dal.meta.model.req.ChangeFlowCreateReq;
import com.netease.mail.yanxuan.change.dal.meta.model.req.ChangeFlowReq; import com.netease.mail.yanxuan.change.dal.meta.model.req.ChangeFlowReq;
import lombok.extern.slf4j.Slf4j;
/** /**
* @Author zcwang * @Author zcwang
* @Date 2022/11/14 * @Date 2022/11/14
*/ */
@Slf4j
@RestController @RestController
@RequestMapping("/change/flow") @RequestMapping("/change/flow")
public class ChangeFlowController { public class ChangeFlowController {
...@@ -29,6 +37,9 @@ public class ChangeFlowController { ...@@ -29,6 +37,9 @@ public class ChangeFlowController {
@Autowired @Autowired
private ChangeFlowService changeFlowService; private ChangeFlowService changeFlowService;
@Autowired
private ChangeFlowBiz changeFlowBiz;
/** /**
* 变更工单详情查询 * 变更工单详情查询
* @return * @return
...@@ -58,12 +69,13 @@ public class ChangeFlowController { ...@@ -58,12 +69,13 @@ public class ChangeFlowController {
} }
/** /**
* 发起变更 * 发起变更,自动跳转到第一个节点
* @return * @return
*/ */
@PostMapping("/create") @PostMapping("/create")
public AjaxResult<Boolean> create() { public AjaxResult<Boolean> createAndSubmit(@RequestBody @Valid ChangeFlowCreateReq changeFlowCreateReq) {
return AjaxResult.success(); log.info("[createAndSubmit] createAndSubmit req={}", JSON.toJSONString(changeFlowCreateReq));
return AjaxResult.success(changeFlowBiz.createAndSubmit(changeFlowCreateReq));
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment