Commit 1cd9d79c by jx-art

新增变更模板接口编写完成

parent e26c439e
......@@ -13,7 +13,7 @@ public interface ChangeExecConfigService {
List<ChangeExecConfig> queryChangeExecConfig(Long changeTemplateId);
Boolean addChangeExecConfig(List<ChangeExecConfig> changeExecConfigs);
Boolean addChangeExecConfig(Long id,List<ChangeExecConfig> changeExecConfigs);
Boolean updateChangeExecConfig(ChangeExecConfig changeExecConfig);
......
package com.netease.mail.yanxuan.change.biz.service.impl;
import com.netease.mail.yanxuan.change.biz.meta.exception.ExceptionFactory;
import com.netease.mail.yanxuan.change.biz.service.change.ChangeConfigService;
import com.netease.mail.yanxuan.change.biz.service.change.ChangeExecConfigService;
import com.netease.mail.yanxuan.change.common.bean.AjaxResult;
......@@ -7,6 +8,7 @@ import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.netease.mail.yanxuan.change.biz.service.AdminChangeConfigService;
import com.netease.mail.yanxuan.change.biz.service.change.ChangeTypeService;
import com.netease.mail.yanxuan.change.common.bean.ResponseCode;
import com.netease.mail.yanxuan.change.common.bean.ResponseCodeEnum;
import com.netease.mail.yanxuan.change.dal.entity.ChangeConfig;
import com.netease.mail.yanxuan.change.dal.entity.ChangeExecConfig;
......@@ -18,6 +20,8 @@ import com.netease.mail.yanxuan.change.dal.meta.model.req.ChangeConfigReq;
import com.netease.mail.yanxuan.change.dal.meta.model.vo.ChangeConfigVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
/**
......@@ -79,9 +83,14 @@ public class AdminChangeConfigServiceImpl implements AdminChangeConfigService {
}
@Override
@Transactional
public AjaxResult createChange(ChangeConfigReq changeConfigReq) {
//一级类目 二级类目 都不可重复 一级类目与二级类目的关联关系是一对一关联 如果有重复的话就使用返回值提示重复
return null;
//添加一级二级类目
List<ChangeType> changeTypes = typeService.addChangeType(changeConfigReq.getChangeTypes());
ChangeConfig changeConfig = parameterSplicing(changeTypes,changeConfigReq);
changeConfig = changeConfigService.addChangeConfig(changeConfig);
execConfigService.addChangeExecConfig(changeConfig.getId(),changeConfigReq.getChangeExecConfigs());
return AjaxResult.success();
}
@Override
......@@ -106,4 +115,52 @@ public class AdminChangeConfigServiceImpl implements AdminChangeConfigService {
public AjaxResult queryConfigType() {
return AjaxResult.success(typeService.queryConfigType());
}
/**
* 添加变更模板并参数拼接
* @param changeTypes
* @param changeConfigReq
* @return
*/
private ChangeConfig parameterSplicing(List<ChangeType> changeTypes,ChangeConfigReq changeConfigReq){
ChangeConfig changeConfig = new ChangeConfig();
changeConfig.setParentChangeClassId(changeTypes.get(0).getId());
changeConfig.setSonChangeClassId(changeTypes.get(1).getId());
if (changeConfigReq.getChangeSubject() == null){
throw ExceptionFactory.createBiz(ResponseCode.PARAMETER_DEFICIENCY);
}
changeConfig.setChangeSubject(changeConfigReq.getChangeSubject());
if (changeConfigReq.getChangeLevel() == null){
throw ExceptionFactory.createBiz(ResponseCode.PARAMETER_DEFICIENCY);
}
changeConfig.setChangeLevel(changeConfigReq.getChangeLevel());
if (changeConfigReq.getChangeDepartment() == null){
throw ExceptionFactory.createBiz(ResponseCode.PARAMETER_DEFICIENCY);
}
changeConfig.setChangeDepartment(changeConfigReq.getChangeDepartment());
if (changeConfigReq.getChangeCommanderType() == null){
throw ExceptionFactory.createBiz(ResponseCode.PARAMETER_DEFICIENCY);
}
changeConfig.setChangeCommanderType(changeConfigReq.getChangeCommanderType());
if (changeConfigReq.getChangeCommander() == null){
throw ExceptionFactory.createBiz(ResponseCode.PARAMETER_DEFICIENCY);
}
changeConfig.setChangeCommander(changeConfigReq.getChangeCommander());
if (changeConfigReq.getNeedFile() == null){
throw ExceptionFactory.createBiz(ResponseCode.PARAMETER_DEFICIENCY);
}
changeConfig.setNeedFile(changeConfigReq.getNeedFile());
changeConfig.setCreateTime(System.currentTimeMillis());
changeConfig.setUpdateTime(System.currentTimeMillis());
if (changeConfigReq.getChangeExecConfigs() == null || changeConfigReq.getChangeExecConfigs().size() >=21){
throw ExceptionFactory.createBiz(ResponseCode.EXEC_CONFIG_LENGTH);
}
List<String> list = new ArrayList<>();
for (ChangeExecConfig execConfig : changeConfigReq.getChangeExecConfigs()){
list.add(execConfig.getChangeExecDepartment());
}
changeConfig.setParticipateChangeExecDepartment(list.toString());
return changeConfig;
}
}
......@@ -28,8 +28,7 @@ public class ChangeConfigServiceImpl implements ChangeConfigService {
@Override
public ChangeConfig addChangeConfig(ChangeConfig changeConfig) {
int id = mapper.insertSelective(changeConfig);
changeConfig.setId((long) id);
mapper.add(changeConfig);
return changeConfig;
}
......
package com.netease.mail.yanxuan.change.biz.service.impl.change;
import com.netease.mail.yanxuan.change.common.bean.ResponseCode;
import com.netease.mail.yanxuan.change.biz.meta.exception.ExceptionFactory;
import com.netease.mail.yanxuan.change.biz.service.change.ChangeExecConfigService;
import com.netease.mail.yanxuan.change.dal.entity.ChangeExecConfig;
import com.netease.mail.yanxuan.change.dal.mapper.ChangeExecConfigMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
......@@ -26,13 +23,13 @@ public class ChangeExecConfigServiceImpl implements ChangeExecConfigService {
}
@Override
@Transactional
public Boolean addChangeExecConfig(List<ChangeExecConfig> changeExecConfigs) {
if (changeExecConfigs == null || changeExecConfigs.size() >=21){
throw ExceptionFactory.createBiz(ResponseCode.EXEC_CONFIG_LENGTH);
}
public Boolean addChangeExecConfig(Long id,List<ChangeExecConfig> changeExecConfigs) {
long currentTime = System.currentTimeMillis();
//循环添加
for (ChangeExecConfig changeExecConfig : changeExecConfigs){
changeExecConfig.setChangeTemplateId(id);
changeExecConfig.setCreateTime(currentTime);
changeExecConfig.setUpdateTime(currentTime);
//行动项,变更风险描述, 变更验证措施, 需要判断字段长度 参数验证 暂不验证
mapper.insertSelective(changeExecConfig);
}
......
package com.netease.mail.yanxuan.change.biz.service.impl.change;
import com.netease.mail.yanxuan.change.common.bean.ResponseCode;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.netease.mail.yanxuan.change.biz.meta.exception.ExceptionFactory;
import com.netease.mail.yanxuan.change.biz.service.change.ChangeTypeService;
import com.netease.mail.yanxuan.change.dal.entity.ChangeType;
......@@ -11,9 +9,6 @@ import com.netease.mail.yanxuan.change.dal.meta.model.po.ChangeTypePo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import tk.mybatis.mapper.entity.Example;
import java.util.*;
/**
......@@ -36,17 +31,29 @@ public class ChangeTypeServiceImpl implements ChangeTypeService {
@Override
@Transactional
public List<ChangeType> addChangeType(List<ChangeType> changeTypes) {
if (changeTypes.size() != 2){
throw ExceptionFactory.createBiz(ResponseCode.PARAMETER_LENGTH);
}
//验证字符串长度
if (changeTypes.get(0).getTypeName().length() > 20 && changeTypes.get(0).getTypeName().length() > 20){
if (changeTypes.get(0).getTypeName().length() > 20 && changeTypes.get(1).getTypeName().length() > 20){
throw ExceptionFactory.createBiz(ResponseCode.PARAMETER_LENGTH);
}
queryChangeType(changeTypes);
int oneId = mapper.insertSelective(changeTypes.get(0));
//id 载入
changeTypes.get(0).setId((long) oneId);
changeTypes.get(1).setParentId((long) oneId);
int tow = mapper.insertSelective(changeTypes.get(1));
changeTypes.get(1).setId((long) tow);
ChangeType changeType = queryRepetitionChangeType(changeTypes);
if (changeType == null) {
//初始化参数载入
changeTypes.get(0).setCreateTime(System.currentTimeMillis());
changeTypes.get(0).setUpdateTime(System.currentTimeMillis());
changeTypes.get(0).setParentId(0L);
mapper.insertSelective(changeTypes.get(0));
}else{
changeTypes.set(0,changeType);
changeTypes.get(1).setParentId(changeType.getId());
}
//初始化参数载入
changeTypes.get(1).setParentId(changeTypes.get(0).getId());
changeTypes.get(1).setCreateTime(System.currentTimeMillis());
changeTypes.get(1).setUpdateTime(System.currentTimeMillis());
mapper.insertSelective(changeTypes.get(1));
return changeTypes;
}
......@@ -69,34 +76,6 @@ public class ChangeTypeServiceImpl implements ChangeTypeService {
return true;
}
/**
* 二级目录类型查询出所有一级二级
*
* @return
*/
// @Override
// public Map<ChangeType, List<ChangeType>> queryConfigType() {
// //获取数据,创建目录集合,遍历分组
// List<ChangeType> changeTypes = mapper.queryArrayChangeType();
// Map<ChangeType,List<ChangeType>> typeMap = new HashMap<ChangeType,List<ChangeType>>();
// for (ChangeType changeType : changeTypes) {
// if (changeType.getParentId() == 0){
// //如果是一级 插入MAP 并创建List列表
// typeMap.put(changeType,new ArrayList<ChangeType>());
// }else{
// //二级 就找到父类的一级 并add进入一级的列表
// for(ChangeType tpye : typeMap.keySet()){
// if (tpye.getId() == changeType.getParentId()){
// typeMap.get(tpye).add(changeType);
// }
// }
// }
// }
// //MAP 去重如果父类下边包裹的List数量为0的时候就自动剔除
// typeMap.entrySet().removeIf(next -> next.getValue().size() == 0);
// return typeMap;
// }
@Override
public List<ChangeTypePo> queryConfigType() {
//获取数据,创建目录集合,遍历分组
......@@ -125,20 +104,23 @@ public class ChangeTypeServiceImpl implements ChangeTypeService {
* @param changeTypes
* @return
*/
private void queryChangeType(List<ChangeType> changeTypes) {
private ChangeType queryRepetitionChangeType(List<ChangeType> changeTypes) {
if (changeTypes.get(0) == null || changeTypes.get(1) == null){
throw ExceptionFactory.createParamFail();
}
int i = 0;
for (ChangeType changeType : changeTypes){
if (StringUtils.isEmpty(changeType.getTypeName())){
throw ExceptionFactory.createBiz(ResponseCode.PARAM_MISS);
//获取父类是否存在
ChangeType changeParentType = mapper.queryTypeName(changeTypes.get(0).getTypeName());
if (changeParentType == null){
return null;
}
if (mapper.queryTypeName(changeType.getTypeName()) != null){
throw ExceptionFactory.createBiz(i == 0?ResponseCode.CHANGE_TYPE_NAME_ONE:ResponseCode.CHANGE_TYPE_NAME_TOW);
//如果存在查询父类下面所有子类 查询是否有重复的
List<ChangeType> sonChangeTypes = mapper.queryParent(changeParentType.getId());
for (ChangeType changeType : sonChangeTypes){
if (changeType.getTypeName().equals(changeTypes.get(1).getTypeName())){
throw ExceptionFactory.createBiz(ResponseCode.CHANGE_TYPE_NAME_TOW);
}
i++;
}
return changeParentType;
}
......
......@@ -172,6 +172,8 @@ public enum ResponseCode {
EXEC_CONFIG_LENGTH(414, "请检查行动方案配置数量"),
PARAMETER_DEFICIENCY(415,"参数缺失请检查参数"),
CHANGE_TYPE_NAME_ONE(4001,"一级变更类型重复,请检查后添加~"),
CHANGE_TYPE_NAME_TOW(4002,"二级变更类型重复,请检查后添加~");
......
......@@ -8,11 +8,9 @@ package com.netease.mail.yanxuan.change.dal.mapper;
import com.netease.mail.yanxuan.change.dal.entity.ChangeType;
import com.netease.mail.yanxuan.change.dal.meta.model.po.ChangeConfigPo;
import com.netease.mail.yanxuan.change.dal.meta.model.po.ChangeExecConfigPo;
import com.netease.mail.yanxuan.change.dal.meta.model.req.ChangeConfigQueryReq;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import com.netease.mail.yanxuan.change.dal.entity.ChangeConfig;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
......@@ -36,4 +34,6 @@ public interface ChangeConfigMapper extends tk.mybatis.mapper.common.Mapper<Chan
List<ChangeType> queryByparentChangeClassId();
//暂时弃用
//ChangeExecConfigPo queryChangeDepartment(@Param("id")Long id);
void add(ChangeConfig changeConfig);
}
\ No newline at end of file
......@@ -8,7 +8,6 @@ package com.netease.mail.yanxuan.change.dal.mapper;
import com.netease.mail.yanxuan.change.dal.meta.model.po.ChangeTypePo;
import org.apache.ibatis.annotations.Mapper;
import com.netease.mail.yanxuan.change.dal.entity.ChangeType;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
......@@ -21,8 +20,8 @@ import java.util.List;
@Mapper
public interface ChangeTypeMapper extends tk.mybatis.mapper.common.Mapper<ChangeType> {
@Select("select id from TB_YX_QC_CHANGE_TYPE where type_name = #{typeName} and `delete` = 0")
Integer queryTypeName(@Param("typeName") String typeName);
@Select("select * from TB_YX_QC_CHANGE_TYPE where type_name = #{typeName} and `delete` = 0")
ChangeType queryTypeName(@Param("typeName") String typeName);
@Select("select * from TB_YX_QC_CHANGE_TYPE where id in(#{id},#{sonChangeClassId}) and `delete` = #{delete} ")
......@@ -34,4 +33,6 @@ public interface ChangeTypeMapper extends tk.mybatis.mapper.common.Mapper<Change
@Select("select * from TB_YX_QC_CHANGE_TYPE where `delete` = 0 ")
List<ChangeTypePo> queryArrayChangeTypes();
@Select("select * from TB_YX_QC_CHANGE_TYPE where parent_id = #{id} and `delete` = 0")
List<ChangeType> queryParent(@Param("id") Long id);
}
\ No newline at end of file
package com.netease.mail.yanxuan.change.dal.meta.model.req;
import com.netease.mail.yanxuan.change.dal.entity.ChangeExecConfig;
import com.netease.mail.yanxuan.change.dal.meta.model.po.ChangeConfigPo;
import com.netease.mail.yanxuan.change.dal.entity.ChangeType;
import lombok.Data;
import java.util.List;
......@@ -14,9 +14,39 @@ import java.util.List;
public class ChangeConfigReq {
/**
* 变更主体PO
* 变更主体
*/
private ChangeConfigPo changeConfigPo;
private Integer changeSubject;
/**
* 变更等级
*/
private Integer changeLevel;
/**
* 变更负责部门名
*/
private String changeDepartment;
/**
* 变更负责人类型
*/
private Integer changeCommanderType;
/**
* 变更负责人详情(不同类型存储不同内容)
*/
private String changeCommander;
/**
* 是否需要资料上传
*/
private Integer needFile;
/**
* 变更类型
*/
private List<ChangeType> changeTypes;
/**
* 变更执行方案
......
......@@ -72,4 +72,77 @@
<!-- ORDER BY coreDepartment DESC LIMIT 1;-->
<!-- </select>-->
<insert id="add" keyColumn="id" keyProperty="id" parameterType="com.netease.mail.yanxuan.change.dal.entity.ChangeConfig" useGeneratedKeys="true">
insert into TB_YX_QC_CHANGE_CONFIG
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="changeSubject != null">
change_subject,
</if>
<if test="parentChangeClassId != null">
parent_change_class_id,
</if>
<if test="sonChangeClassId != null">
son_change_class_id,
</if>
<if test="changeLevel != null">
change_level,
</if>
<if test="changeDepartment != null">
change_department,
</if>
<if test="changeCommanderType != null">
change_commander_type,
</if>
<if test="participateChangeExecDepartment != null">
participate_change_exec_department,
</if>
<if test="changeCommander != null">
change_commander,
</if>
<if test="needFile != null">
need_file,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="changeSubject != null">
#{changeSubject,jdbcType=INTEGER},
</if>
<if test="parentChangeClassId != null">
#{parentChangeClassId,jdbcType=INTEGER},
</if>
<if test="sonChangeClassId != null">
#{sonChangeClassId,jdbcType=INTEGER},
</if>
<if test="changeLevel != null">
#{changeLevel,jdbcType=INTEGER},
</if>
<if test="changeDepartment != null">
#{changeDepartment,jdbcType=VARCHAR},
</if>
<if test="changeCommanderType != null">
#{changeCommanderType,jdbcType=INTEGER},
</if>
<if test="participateChangeExecDepartment != null">
#{participateChangeExecDepartment,jdbcType=VARCHAR},
</if>
<if test="changeCommander != null">
#{changeCommander,jdbcType=VARCHAR},
</if>
<if test="needFile != null">
#{needFile,jdbcType=INTEGER},
</if>
<if test="createTime != null">
#{createTime,jdbcType=BIGINT},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=BIGINT},
</if>
</trim>
</insert>
</mapper>
......@@ -18,7 +18,10 @@ public class ChangeConfigController {
@Autowired
private AdminChangeConfigService service;
/**
* 通过参数查询配置模板
* @return
*/
@GetMapping("/list")
public AjaxResult queryChanges(
@RequestParam(name = "pageNum",defaultValue = "1") Integer pageNum,
......@@ -39,6 +42,12 @@ public class ChangeConfigController {
return service.queryChanges(pageNum,pageSize,req);
}
/**
* 查询变更模板详情
* @param id
* @param sonChangeClassId
* @return
*/
@GetMapping("/detail")
public AjaxResult queryDetail(
@RequestParam(name = "id") Long id,
......@@ -46,20 +55,33 @@ public class ChangeConfigController {
return service.queryDetail(id, sonChangeClassId);
}
/**
* 新增变更模板详情
* @param changeConfigReq
* @return
*/
@PostMapping("/create")
public AjaxResult createChange(
@RequestBody ChangeConfigReq changeConfigReq){
return service.createChange(changeConfigReq);
}
/**
* 修改变更模板详情
* @param changeConfigReq
* @return
*/
@PostMapping("/modify")
public AjaxResult modifyChange(
@RequestBody ChangeConfigReq changeConfigReq){
return service.modifyChange(changeConfigReq);
}
/**
* 删除模板配置
* @param id
* @return
*/
@PostMapping("/delete")
public AjaxResult deleteChange(
@RequestBody Long id){
......@@ -67,6 +89,10 @@ public class ChangeConfigController {
return service.deleteChange(id);
}
/**
* 查询所有模板配置类型
* @return
*/
@GetMapping("/query/config/type")
public AjaxResult queryConfigType(){
return service.queryConfigType();
......
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