Commit 9c33c8a9 by “zcwang”

add: 引用变更

parent 7b0420cf
......@@ -84,7 +84,8 @@ CREATE TABLE `TB_YX_QC_CHANGE_FILE`
`file_url` varchar(255) NOT NULL DEFAULT '' COMMENT '文件地址',
`create_time` bigint(20) NOT NULL DEFAULT '0' COMMENT '创建时间',
`update_time` bigint(20) NOT NULL DEFAULT '0' COMMENT '更新时间',
PRIMARY KEY (`id`)
PRIMARY KEY (`id`),
KEY `key_record_id` (`change_record_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='附件表';
CREATE TABLE `TB_YX_QC_CHANGE_EXEC_RECORD`
......
......@@ -21,6 +21,7 @@ import org.springframework.util.CollectionUtils;
import com.alibaba.fastjson.JSON;
import com.netease.mail.yanxuan.change.biz.config.AppConfig;
import com.netease.mail.yanxuan.change.biz.meta.exception.ExceptionFactory;
import com.netease.mail.yanxuan.change.biz.service.ChangeFileService;
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.bean.CommonConstants;
......@@ -32,11 +33,14 @@ import com.netease.mail.yanxuan.change.common.enums.ChangeSubjectEnum;
import com.netease.mail.yanxuan.change.common.enums.FlowOperationTypeEnum;
import com.netease.mail.yanxuan.change.common.enums.FlowxOperationEnum;
import com.netease.mail.yanxuan.change.common.util.DateUtils;
import com.netease.mail.yanxuan.change.dal.entity.ChangeFile;
import com.netease.mail.yanxuan.change.dal.entity.ChangeRecord;
import com.netease.mail.yanxuan.change.dal.meta.model.req.ChangeExecConfigReq;
import com.netease.mail.yanxuan.change.dal.meta.model.req.ChangeFlowCancelReq;
import com.netease.mail.yanxuan.change.dal.meta.model.req.ChangeFlowCreateReq;
import com.netease.mail.yanxuan.change.dal.meta.model.req.ChangeFlowFile;
import com.netease.mail.yanxuan.change.dal.meta.model.req.ChangeFlowSubmitReq;
import com.netease.mail.yanxuan.change.dal.meta.model.vo.BasicChangeFlowVO;
import com.netease.mail.yanxuan.change.integration.flow.FlowRpcService;
import com.netease.yanxuan.flowx.sdk.meta.controller.communal.AjaxResponse;
import com.netease.yanxuan.flowx.sdk.meta.dto.base.FlowDataDTO;
......@@ -65,6 +69,9 @@ public class ChangeFlowBiz {
@Autowired
private FlowRpcService flowRpcService;
@Autowired
private ChangeFileService changeFileService;
public String createAndSubmit(ChangeFlowCreateReq changeFlowCreateReq) {
// String uid = RequestLocalBean.getUid();
String uid = "x@mesg.com";
......@@ -248,7 +255,9 @@ public class ChangeFlowBiz {
log.info("[submitFlow] changeFlowReq:{}", JSON.toJSONString(changeFlowSubmitReq));
Long flowId = changeFlowSubmitReq.getFlowId();
// 查询工单有效性
ChangeRecord changeRecord = this.checkFlow(flowId, changeFlowSubmitReq.getCurrentNodeId());
ChangeRecord changeRecord = this.getFlowInfo(flowId);
// 检查工单节点
this.checkNode(changeRecord.getFlowNode(), changeFlowSubmitReq.getCurrentNodeId());
// todo:检验操作权限
// String uid = RequestLocalBean.getUid();
......@@ -270,22 +279,27 @@ public class ChangeFlowBiz {
ChangeFlowEnum.CHANGE_FLOW_SUBMIT.getTopoId(), JSON.toJSONString(content));
}
private ChangeRecord checkFlow(Long flowId, String currentNodeId) {
private ChangeRecord getFlowInfo(Long flowId) {
ChangeRecord changeRecord = changeFlowService.getByFlowId(flowId);
if (changeRecord == null) {
throw ExceptionFactory.createBiz(ResponseCode.ERROR_FLOW_ID, "工单id不存在");
}
if (!changeRecord.getFlowNode().equals(currentNodeId)) {
throw ExceptionFactory.createBiz(ResponseCode.NODE_ERROR, "工单已流转至其他节点");
}
return changeRecord;
}
private void checkNode(String recordNode, String currentNodeId){
if (!recordNode.equals(currentNodeId)) {
throw ExceptionFactory.createBiz(ResponseCode.NODE_ERROR, "工单已流转至其他节点");
}
};
public Boolean cancel(ChangeFlowCancelReq req) {
log.info("[cancel] req:{}", JSON.toJSONString(req));
Long flowId = req.getFlowId();
// 查询工单有效性
ChangeRecord changeRecord = checkFlow(flowId, ChangeFlowEnum.CHANGE_FLOW_EXE.getNodeId());
ChangeRecord changeRecord = getFlowInfo(flowId);
// 检查工单节点
this.checkNode(changeRecord.getFlowNode(), ChangeFlowEnum.CHANGE_FLOW_EXE.getNodeId());
// todo:检查审核人
// 获取工单详情
......@@ -308,4 +322,17 @@ public class ChangeFlowBiz {
changeRecord.setUpdateTime(DateUtils.getCurrentTime());
return changeFlowService.updateRecord(changeRecord);
}
public BasicChangeFlowVO quote(Long flowId) {
// 获取工单详情
ChangeRecord changeRecord = this.getFlowInfo(flowId);
// 获取附件
List<ChangeFlowFile> changeFileList = changeFileService.getChangeFileList(changeRecord.getId());
return BasicChangeFlowVO.builder().parentChangeClassId(changeRecord.getParentChangeClassId())
.sonChangeClassId(changeRecord.getSonChangeClassId()).changeSubject(changeRecord.getChangeSubject())
.changeItem(changeRecord.getChangeItem()).changeSupplier(changeRecord.getChangeSupplier())
.changeReason(changeRecord.getChangeReason()).changeContent(changeRecord.getChangeContent())
.changeRiskDesc(changeRecord.getChangeRiskDesc()).changeProfit(changeRecord.getChangeProfit())
.changeProfitDesc(changeRecord.getChangeProfitDesc()).files(changeFileList).build();
}
}
/**
* @(#)ChangeFileService.java, 2022/11/21.
* <p/>
* Copyright 2022 Netease, Inc. All rights reserved.
* NETEASE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
package com.netease.mail.yanxuan.change.biz.service;
import java.util.List;
import com.netease.mail.yanxuan.change.dal.entity.ChangeFile;
import com.netease.mail.yanxuan.change.dal.meta.model.req.ChangeFlowFile;
/**
* @Author zcwang
* @Date 2022/11/21
*/
public interface ChangeFileService {
/**
* 获取工单对应的附件
* @param changeRecordId
* @return
*/
List<ChangeFlowFile> getChangeFileList(Long changeRecordId);
}
\ No newline at end of file
/**
* @(#)ChangeFileServiceImpl.java, 2022/11/21.
* <p/>
* Copyright 2022 Netease, Inc. All rights reserved.
* NETEASE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
package com.netease.mail.yanxuan.change.biz.service.impl;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.netease.mail.yanxuan.change.biz.service.ChangeFileService;
import com.netease.mail.yanxuan.change.dal.entity.ChangeFile;
import com.netease.mail.yanxuan.change.dal.mapper.ChangeFileMapper;
import com.netease.mail.yanxuan.change.dal.meta.model.req.ChangeFlowFile;
/**
* @Author zcwang
* @Date 2022/11/21
*/
@Service
public class ChangeFileServiceImpl implements ChangeFileService {
@Autowired
private ChangeFileMapper changeFileMapper;
@Override
public List<ChangeFlowFile> getChangeFileList(Long changeRecordId) {
List<ChangeFile> changeFiles = changeFileMapper.selectByChangeRecordId(changeRecordId);
if (CollectionUtils.isNotEmpty(changeFiles)) {
return changeFiles.stream().map(c -> ChangeFlowFile.builder().fileType(c.getFileType()).fileName(c.getFileName())
.fileUrl(c.getFileUrl()).build()).collect(Collectors.toList());
}
return new ArrayList<>();
}
}
\ No newline at end of file
......@@ -6,7 +6,11 @@
*/
package com.netease.mail.yanxuan.change.dal.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import com.netease.mail.yanxuan.change.dal.entity.ChangeFile;
......@@ -16,4 +20,7 @@ import com.netease.mail.yanxuan.change.dal.entity.ChangeFile;
*/
@Mapper
public interface ChangeFileMapper extends tk.mybatis.mapper.common.Mapper<ChangeFile> {
@Select("SELECT * FROM TB_YX_QC_CHANGE_FILE WHERE change_record_id = #{changeRecordId}")
List<ChangeFile> selectByChangeRecordId(@Param("changeRecordId") Long changeRecordId);
}
\ No newline at end of file
......@@ -6,12 +6,18 @@
*/
package com.netease.mail.yanxuan.change.dal.meta.model.req;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Author zcwang
* @Date 2022/11/14
*/
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Data
public class ChangeFlowFile {
......
/**
* @(#)BasicChangeFlowVO.java, 2022/11/21.
* <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.vo;
import java.util.List;
import com.netease.mail.yanxuan.change.dal.entity.ChangeFile;
import com.netease.mail.yanxuan.change.dal.meta.model.req.ChangeFlowFile;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Author zcwang
* @Date 2022/11/21
*/
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Data
public class BasicChangeFlowVO {
/**
* 一级变更类型id
*/
private Long parentChangeClassId;
/**
* 二级变更类型id
*/
private Long sonChangeClassId;
/**
* 变更主体
*/
private Integer changeSubject;
/**
* 变更商品(变更主体为商品时有效)
*/
private String changeItem;
/**
* 变更供应商(变更主体为供应商时有效)
*/
private String changeSupplier;
/**
* 变更原因
*/
private String changeReason;
/**
* 变更内容
*/
private String changeContent;
/**
* 变更潜在风险描述
*/
private String changeRiskDesc;
/**
* 变更收益类型
*/
private Integer changeProfit;
/**
* 变更收益说明
*/
private String changeProfitDesc;
/**
* 附件
*/
private List<ChangeFlowFile> files;
}
\ No newline at end of file
......@@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSON;
......@@ -23,6 +24,7 @@ import com.netease.mail.yanxuan.change.biz.service.ChangeFlowService;
import com.netease.mail.yanxuan.change.dal.meta.model.req.ChangeFlowCancelReq;
import com.netease.mail.yanxuan.change.dal.meta.model.req.ChangeFlowCreateReq;
import com.netease.mail.yanxuan.change.dal.meta.model.req.ChangeFlowSubmitReq;
import com.netease.mail.yanxuan.change.dal.meta.model.vo.BasicChangeFlowVO;
import lombok.extern.slf4j.Slf4j;
......@@ -111,9 +113,8 @@ public class ChangeFlowController {
* @return
*/
@GetMapping("/quote")
public AjaxResult<Void> quote() {
return AjaxResult.success();
public AjaxResult<BasicChangeFlowVO> quote(@RequestParam Long flowId) {
return AjaxResult.success(changeFlowBiz.quote(flowId));
}
......
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