feat: (REQ-3300) 变签详情页添加API
This commit is contained in:
parent
ec35f45ea6
commit
5d71979ad0
@ -1,14 +1,19 @@
|
||||
package cn.axzo.visa.api.changerecord;
|
||||
|
||||
import cn.axzo.framework.domain.web.result.ApiResult;
|
||||
import cn.axzo.visa.api.req.VisaChangeApproveCreateReq;
|
||||
import cn.axzo.visa.api.req.VisaChangeDiscussCreateReq;
|
||||
import cn.axzo.visa.api.req.VisaChangeTempCreateReq;
|
||||
import cn.axzo.visa.api.request.VisaChangeApproveCreateReq;
|
||||
import cn.axzo.visa.api.request.VisaChangeDiscussCreateReq;
|
||||
import cn.axzo.visa.api.request.VisaChangeTempCreateReq;
|
||||
import cn.axzo.visa.api.request.ChangeStatusRequest;
|
||||
import cn.axzo.visa.api.request.VisaDetailByIdRequest;
|
||||
import cn.axzo.visa.api.response.VisaDetailByIdResponse;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
/**
|
||||
* @author xudawei
|
||||
* @date 2025/01/15
|
||||
@ -44,4 +49,16 @@ public interface ChangeRecordApi {
|
||||
@PostMapping("/api/visa/change/approveCreate")
|
||||
ApiResult<Long> approveCreateVisaChangeRecord(@RequestBody @Validated VisaChangeApproveCreateReq req);
|
||||
|
||||
/**
|
||||
* 变签状态变更
|
||||
*/
|
||||
@PostMapping("/api/visa/changeStatus")
|
||||
boolean changeStatus(@RequestBody @Valid ChangeStatusRequest request);
|
||||
|
||||
/**
|
||||
* 变签详情
|
||||
*/
|
||||
@PostMapping("/api/visa/visaDetailById")
|
||||
VisaDetailByIdResponse visaDetailById(@RequestBody @Valid VisaDetailByIdRequest request);
|
||||
|
||||
}
|
||||
|
||||
@ -1,6 +1,13 @@
|
||||
package cn.axzo.visa.api.changerecord;
|
||||
|
||||
import cn.axzo.framework.domain.web.result.ApiListResult;
|
||||
import cn.axzo.visa.api.request.FetchVisaLogByVisaIdRequest;
|
||||
import cn.axzo.visa.api.response.FetchVisaLogByVisaIdResponse;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
/**
|
||||
* @author xudawei
|
||||
@ -10,6 +17,10 @@ import org.springframework.cloud.openfeign.FeignClient;
|
||||
@FeignClient(name = "nanopart", url = "${axzo.service.nanopart:http://nanopart:8080}")
|
||||
public interface ChangeRecordLogApi {
|
||||
|
||||
|
||||
/**
|
||||
* 根据变签Id,获取变签日志
|
||||
*/
|
||||
@PostMapping("api/visa/log/fetchVisaLogByVisaId")
|
||||
ApiListResult<FetchVisaLogByVisaIdResponse> fetchVisaLogByVisaId(@RequestBody @Valid FetchVisaLogByVisaIdRequest req);
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,31 @@
|
||||
package cn.axzo.visa.api.enums;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 按钮枚举
|
||||
* @author xudawei
|
||||
* @since 2025-01-15
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public enum VisaButtonTypeEnum {
|
||||
|
||||
UPDATE("update", "编辑"),
|
||||
DELETE("delete", "删除"),
|
||||
FORBID("forbid", "作废"),
|
||||
EXECUTE("execute", "执行"),
|
||||
TO_APPROVE("to_approve", "提交审批"),
|
||||
UPLOAD_FILE("upload_file", "上传附件"),
|
||||
CHAT_GROUP_RECORD("chat_group_record", "查看洽商记录"),
|
||||
TO_HANDLE("to_handle", "去处理"),
|
||||
;
|
||||
|
||||
|
||||
private String code;
|
||||
|
||||
private String desc;
|
||||
|
||||
}
|
||||
@ -0,0 +1,65 @@
|
||||
package cn.axzo.visa.api.enums;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 变签日志类型
|
||||
* @author xudawei
|
||||
* @since 2025-01-15
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public enum VisaLogTypeEnum {
|
||||
|
||||
CHAT_GROUP("chat_group", "发起群聊洽商","发起群聊洽商","%s发起群聊洽商"),
|
||||
EDIT_FORM("edit_form", "编辑表单","%s编辑表单","%s编辑一下表单字段:"),
|
||||
EDIT_AMOUNT("edit_amount", "编辑金额变化","%s编辑金额变化","原值:金额变化:%s;/n 新值:金额变化:%s;"),
|
||||
UPLOAD_FILE("upload_file", "上传附件","%s上传附件","%s上传%d个附件:"),
|
||||
DELETE_UPLOAD_FILE("delete_upload_file", "删除附件","%s删除附件","%s删除%d个附件:"),
|
||||
TO_EXECUTE("to_execute", "发起执行","发起执行", "%s发起执行"),
|
||||
TO_APPRROVE("to_apprrove", "发起审批","发起%s审批", "%s发起%s审批"),
|
||||
APPROVED_AGRESS("approved_agress", "审批流:某审批人审批通过","%s审批通过", "%s审批通过"),
|
||||
FORBIDED("forbided", "单据作废","单据废止", "%s操作废止单据"),
|
||||
REVERT_APPROVE("revert_approve", "审批流:撤回审批","审批流程撤回", "%s撤回审批流程"),
|
||||
REJECT_APPROVE("reject_approve", "审批流:已驳回","%s驳回审批", "%s已驳回,原因为%s"),
|
||||
TRANSMIT_APPROVE("transmit_approve", "审批流操作:转交","审批人变更", "%s将审批转交至%s,原因为%s"),
|
||||
FALLBACK_APPROVE("fallback_approve", "审批流操作:回退","%s回退审批", "%s回退审批至审批节点:%s"),
|
||||
APPROVE_COMPLETED("approved_completed", "审批流:审批通过","%s通过", "%s流程已完成"),
|
||||
;
|
||||
|
||||
/**
|
||||
* 审批不通过的日志集合
|
||||
*/
|
||||
private static final Set<VisaLogTypeEnum> approveNotAgree = Sets.newHashSet(REVERT_APPROVE, REJECT_APPROVE, FALLBACK_APPROVE);
|
||||
|
||||
/**
|
||||
* 审批不通过的日志集合
|
||||
*/
|
||||
// private static final Set<VisaLogTypeEnum> approveNotAgree = Sets.newHashSet(EDIT_FORM, EDIT_AMOUNT, UPLOAD_FILE, DELETE_UPLOAD_FILE, APPROVED_AGRESS);
|
||||
|
||||
|
||||
|
||||
private String code;
|
||||
|
||||
private String action;
|
||||
|
||||
private String title;
|
||||
|
||||
private String content;
|
||||
|
||||
// private boolean
|
||||
|
||||
/**
|
||||
* 是否审批不通过
|
||||
*/
|
||||
public static boolean isApproveNotAgree(VisaLogTypeEnum logType) {
|
||||
return Objects.nonNull(logType) && approveNotAgree.contains(logType);
|
||||
}
|
||||
|
||||
}
|
||||
@ -14,16 +14,17 @@ import lombok.Getter;
|
||||
@AllArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public enum VisaStatusEnum {
|
||||
|
||||
TO_REPORT("to_report", "待提报"),
|
||||
DECIDING("deciding", "决策中"),
|
||||
EXECUTING("executing","执行中"),
|
||||
APPROVING("approving","审批中"),
|
||||
COMPLETED("completed","已完成"),
|
||||
FORBIDED("forbided","已废除"),
|
||||
REPORT_FROM_APPROVE( "report_from_approve","审批到待提报"),
|
||||
DECIDING_FROM_APPROVE( "deciding_from_approve","审批到决策中"),
|
||||
TO_REPORT("to_report", "待提报", null),
|
||||
DECIDING("deciding", "决策中", VisaLogTypeEnum.CHAT_GROUP),
|
||||
EXECUTING("executing","执行中", VisaLogTypeEnum.TO_EXECUTE),
|
||||
APPROVING("approving","审批中", VisaLogTypeEnum.TO_APPRROVE),
|
||||
COMPLETED("completed","已完成",VisaLogTypeEnum.APPROVE_COMPLETED),
|
||||
FORBIDED("forbided","已废除",VisaLogTypeEnum.FORBIDED),
|
||||
REPORT_FROM_APPROVE("report_from_approve","审批到待提报", null),
|
||||
DECIDING_FROM_APPROVE("deciding_from_approve","审批到决策中", null),
|
||||
;
|
||||
|
||||
private final String code;
|
||||
private final String desc;
|
||||
private final VisaLogTypeEnum logType;
|
||||
}
|
||||
|
||||
@ -0,0 +1,52 @@
|
||||
package cn.axzo.visa.api.request;
|
||||
|
||||
import cn.axzo.visa.api.enums.VisaLogTypeEnum;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* @author xudawei
|
||||
* @date 2025/01/16
|
||||
* @desc 添加变签日志
|
||||
*/
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public class AddVisaLogRequest {
|
||||
|
||||
/**
|
||||
* 变签Id
|
||||
*/
|
||||
@NotNull(message = "变签Id不能为空")
|
||||
private Long visaId;
|
||||
|
||||
/**
|
||||
* 日志类型
|
||||
*/
|
||||
@NotNull(message = "日志类型不能为空")
|
||||
private VisaLogTypeEnum logType;
|
||||
|
||||
/**
|
||||
* 操作人Id
|
||||
*/
|
||||
@NotNull(message = "操作人Id不能为空")
|
||||
private Long personId;
|
||||
/**
|
||||
* 操作人单位Id
|
||||
*/
|
||||
@NotNull(message = "操作人单位Id不能为空")
|
||||
private Long ouId;
|
||||
/**
|
||||
* 操作人项目Id
|
||||
*/
|
||||
@NotNull(message = "操作人项目Id不能为空")
|
||||
private Long workspaceId;
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,67 @@
|
||||
package cn.axzo.visa.api.request;
|
||||
|
||||
import cn.axzo.framework.domain.ServiceException;
|
||||
import cn.axzo.visa.api.enums.VisaLogTypeEnum;
|
||||
import cn.axzo.visa.api.enums.VisaStatusEnum;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author xudawei
|
||||
* @date 2025/01/16
|
||||
* @desc 变签Id获取变签日志
|
||||
*/
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public class ChangeStatusRequest {
|
||||
|
||||
/**
|
||||
* 变签Id
|
||||
*/
|
||||
@NotNull(message = "变签Id不能为空")
|
||||
private Long visaId;
|
||||
/**
|
||||
* 更新成状态
|
||||
*/
|
||||
@NotNull(message = "更新成状态不能为空")
|
||||
private VisaStatusEnum updateStatus;
|
||||
/**
|
||||
* 操作人Id
|
||||
*/
|
||||
@NotNull(message = "操作人Id不能为空")
|
||||
private Long personId;
|
||||
/**
|
||||
* 操作人单位Id
|
||||
*/
|
||||
@NotNull(message = "操作人单位Id不能为空")
|
||||
private Long ouId;
|
||||
/**
|
||||
* 操作人项目Id
|
||||
*/
|
||||
@NotNull(message = "操作人项目Id不能为空")
|
||||
private Long workspaceId;
|
||||
|
||||
/**
|
||||
* 日志类型,
|
||||
* 审批不通过(已驳回、已撤回、已中止) 才需要传这个信息
|
||||
* 1 REVERT_APPROVE("revert_approve", "审批流:撤回审批","审批流程撤回", "%s撤回审批流程"),
|
||||
* 2 REJECT_APPROVE("reject_approve", "审批流:已驳回","%s驳回审批", "%s已驳回,原因为%s"),
|
||||
* 3 FALLBACK_APPROVE("fallback_approve", "审批流操作:回退","%s回退审批", "%s回退审批至审批节点:%s"),
|
||||
*/
|
||||
private VisaLogTypeEnum logType;
|
||||
|
||||
public void check() {
|
||||
if (Objects.nonNull(logType) && !VisaLogTypeEnum.isApproveNotAgree(logType)) {
|
||||
throw new ServiceException("不是审核不通过日志");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
package cn.axzo.visa.api.request;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* @author xudawei
|
||||
* @date 2025/01/16
|
||||
* @desc 变签Id获取变签日志
|
||||
*/
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public class FetchVisaLogByVisaIdRequest {
|
||||
|
||||
/**
|
||||
* 变签Id
|
||||
*/
|
||||
@NotNull(message = "变签Id不能为空")
|
||||
private Long visaId;
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
package cn.axzo.visa.api.req;
|
||||
package cn.axzo.visa.api.request;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
@ -1,4 +1,4 @@
|
||||
package cn.axzo.visa.api.req;
|
||||
package cn.axzo.visa.api.request;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@ -1,4 +1,4 @@
|
||||
package cn.axzo.visa.api.req;
|
||||
package cn.axzo.visa.api.request;
|
||||
|
||||
import cn.axzo.visa.api.enums.VisaTypeEnum;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
@ -0,0 +1,27 @@
|
||||
package cn.axzo.visa.api.request;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* @author xudawei
|
||||
* @date 2025/01/16
|
||||
* @desc 变签Id获取变签日志
|
||||
*/
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public class VisaDetailByIdRequest {
|
||||
|
||||
/**
|
||||
* 变签Id
|
||||
*/
|
||||
@NotNull(message = "变签Id不能为空")
|
||||
private Long visaId;
|
||||
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
package cn.axzo.visa.api.response;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author xudawei
|
||||
* @date 2025/01/16
|
||||
* @desc 变签Id获取变签日志
|
||||
*/
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public class FetchVisaLogByVisaIdResponse {
|
||||
|
||||
/**
|
||||
* 操作标题
|
||||
*/
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 操作内容
|
||||
*/
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createAt;
|
||||
|
||||
}
|
||||
@ -0,0 +1,176 @@
|
||||
package cn.axzo.visa.api.response;
|
||||
|
||||
import cn.axzo.visa.api.enums.VisaButtonTypeEnum;
|
||||
import cn.axzo.visa.api.enums.VisaTypeEnum;
|
||||
import cn.axzo.visa.api.request.VisaChangeTempCreateReq;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author xudawei
|
||||
* @date 2025/01/16
|
||||
* @desc 变签Id获取变签日志
|
||||
*/
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public class VisaDetailByIdResponse {
|
||||
|
||||
/**
|
||||
* 变签Id
|
||||
*/
|
||||
private Long visaId;
|
||||
|
||||
|
||||
/**
|
||||
* 单号
|
||||
*/
|
||||
private String no;
|
||||
|
||||
/**
|
||||
* 主题
|
||||
*/
|
||||
private String topic;
|
||||
|
||||
/**
|
||||
* 项目
|
||||
*/
|
||||
private Long relationWorkspaceId;
|
||||
|
||||
/**
|
||||
* 项目名称
|
||||
*/
|
||||
private String relationWorkspaceName;
|
||||
|
||||
/**
|
||||
* 工程
|
||||
*/
|
||||
private Long relationProject;
|
||||
|
||||
/**
|
||||
* 工程名称
|
||||
*/
|
||||
private String relationProjectName;
|
||||
|
||||
/**
|
||||
* 区域集合
|
||||
*/
|
||||
private JSONObject relationArea;
|
||||
|
||||
/**
|
||||
* 提交日期
|
||||
*/
|
||||
private Date submitDate;
|
||||
|
||||
/**
|
||||
* 专业集合
|
||||
*/
|
||||
private JSONObject relationProfessional;
|
||||
|
||||
/**
|
||||
* 发生原因
|
||||
*/
|
||||
private String reason;
|
||||
|
||||
/**
|
||||
* 单据类型
|
||||
*/
|
||||
private VisaTypeEnum type;
|
||||
|
||||
/**
|
||||
* 相关单位及人员
|
||||
*/
|
||||
private List<VisaChangeTempCreateReq.RelationUnitAndPerson> relationUnitAndPersonList;
|
||||
|
||||
/**
|
||||
* 发生内容说明
|
||||
*/
|
||||
private List<VisaChangeTempCreateReq.ChangeContextAndDescription> changeContextAndDescriptionList;
|
||||
|
||||
/**
|
||||
* 有符号的变更金额
|
||||
*/
|
||||
private BigDecimal amountChange;
|
||||
|
||||
/**
|
||||
* 关联的单据,key: 单据类型,value: 单据id集合
|
||||
* <p>
|
||||
* TASK :任务单 RECTIFY :整改单 CHANGE:变更单
|
||||
* 只有变更签证类型即{@code type}为“技术核定”或“工程签证”时才可能会有关联变更单
|
||||
* </p>
|
||||
*/
|
||||
private Map<String, List<Long>> relationOrderMap;
|
||||
|
||||
/**
|
||||
* 附件
|
||||
*/
|
||||
private List<String> attach;
|
||||
|
||||
/**
|
||||
* 按钮
|
||||
*/
|
||||
private List<VisaButtonTypeEnum> btnList;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class RelationUnitAndPerson {
|
||||
/**
|
||||
* 单位类型 1:施工单位 2:建设单位 3:监理单位 4:劳务分包 5:专业分包 9:项目内班组 13:设计单位
|
||||
*/
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 单位id
|
||||
*/
|
||||
private Long unitId;
|
||||
|
||||
/**
|
||||
* 单位名称
|
||||
*/
|
||||
private String unitName;
|
||||
|
||||
/**
|
||||
* 确认人名称
|
||||
*/
|
||||
private String realName;
|
||||
|
||||
/**
|
||||
* 确认人personId
|
||||
*/
|
||||
private Long personId;
|
||||
}
|
||||
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class ChangeContextAndDescription {
|
||||
/**
|
||||
* 内容类型,1:图片 2:图纸批注
|
||||
*/
|
||||
private Integer Type;
|
||||
|
||||
/**
|
||||
* 图片或图纸
|
||||
*/
|
||||
private String imgUrl;
|
||||
|
||||
/**
|
||||
* 内容说明
|
||||
*/
|
||||
private String text;
|
||||
|
||||
}
|
||||
}
|
||||
@ -2,15 +2,21 @@ package cn.axzo.visa.server.controller;
|
||||
|
||||
import cn.axzo.framework.domain.web.result.ApiResult;
|
||||
import cn.axzo.visa.api.changerecord.ChangeRecordApi;
|
||||
import cn.axzo.visa.api.req.VisaChangeApproveCreateReq;
|
||||
import cn.axzo.visa.api.req.VisaChangeDiscussCreateReq;
|
||||
import cn.axzo.visa.api.req.VisaChangeTempCreateReq;
|
||||
import cn.axzo.visa.api.request.ChangeStatusRequest;
|
||||
import cn.axzo.visa.api.request.VisaChangeApproveCreateReq;
|
||||
import cn.axzo.visa.api.request.VisaChangeDiscussCreateReq;
|
||||
import cn.axzo.visa.api.request.VisaChangeTempCreateReq;
|
||||
import cn.axzo.visa.api.request.VisaDetailByIdRequest;
|
||||
import cn.axzo.visa.api.response.VisaDetailByIdResponse;
|
||||
import cn.axzo.visa.server.service.ChangeRecordService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
/**
|
||||
* @author xudawei
|
||||
* @date 2025/01/15
|
||||
@ -38,4 +44,19 @@ public class ChangeRecordController implements ChangeRecordApi {
|
||||
public ApiResult<Long> approveCreateVisaChangeRecord(VisaChangeApproveCreateReq req) {
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* 变签状态变更
|
||||
*/
|
||||
@Override
|
||||
public boolean changeStatus(@RequestBody @Valid ChangeStatusRequest request) {
|
||||
return changeRecordService.changeStatus(request);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 变签详情
|
||||
*/
|
||||
public VisaDetailByIdResponse visaDetailById(@RequestBody @Valid VisaDetailByIdRequest request) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,13 +1,20 @@
|
||||
package cn.axzo.visa.server.controller;
|
||||
|
||||
import cn.axzo.framework.domain.web.result.ApiListResult;
|
||||
import cn.axzo.visa.api.changerecord.ChangeRecordLogApi;
|
||||
import cn.axzo.visa.api.request.FetchVisaLogByVisaIdRequest;
|
||||
import cn.axzo.visa.api.response.FetchVisaLogByVisaIdResponse;
|
||||
import cn.axzo.visa.server.service.ChangeRecordLogService;
|
||||
import cn.axzo.visa.server.service.ChangeRecordService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xudawei
|
||||
* @date 2025/01/15
|
||||
@ -15,10 +22,18 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
public class ChangeRecordLogController implements ChangeRecordLogApi {
|
||||
|
||||
@Autowired
|
||||
private ChangeRecordLogService changeRecordLogService;
|
||||
|
||||
/**
|
||||
* 根据变签Id,获取变签日志
|
||||
*/
|
||||
@RequestMapping(value = "api/visa/log/fetchVisaLogByVisaId", method = RequestMethod.POST)
|
||||
public ApiListResult<FetchVisaLogByVisaIdResponse> fetchVisaLogByVisaId(@RequestBody @Valid FetchVisaLogByVisaIdRequest req) {
|
||||
List<FetchVisaLogByVisaIdResponse> responseList = changeRecordLogService.fetchVisaLogByVisaId(req.getVisaId());
|
||||
return ApiListResult.ok(responseList);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -31,10 +31,10 @@ public class ChangeRecordLog extends BaseEntity<ChangeRecordLog> {
|
||||
private Long visaId;
|
||||
|
||||
/**
|
||||
* 操作名称
|
||||
* 操作动作
|
||||
*/
|
||||
@TableField(value = "name")
|
||||
private String name;
|
||||
@TableField(value = "action")
|
||||
private String action;
|
||||
|
||||
/**
|
||||
* 操作标题
|
||||
|
||||
@ -1,7 +1,11 @@
|
||||
package cn.axzo.visa.server.service;
|
||||
|
||||
import cn.axzo.visa.api.enums.VisaLogTypeEnum;
|
||||
import cn.axzo.visa.api.response.FetchVisaLogByVisaIdResponse;
|
||||
import cn.axzo.visa.server.domain.ChangeRecordLog;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xudawei
|
||||
* @date 2025/01/15
|
||||
@ -14,4 +18,15 @@ public interface ChangeRecordLogService {
|
||||
*/
|
||||
void addLog(ChangeRecordLog log);
|
||||
|
||||
/**
|
||||
* 缺少REQ对象
|
||||
*/
|
||||
void addLog(Long visaId, VisaLogTypeEnum type, Long personId, Long ouId, Long workspaceId);
|
||||
|
||||
/**
|
||||
* 通过变签Id获取日志
|
||||
* @param visaId 变签Id
|
||||
*/
|
||||
List<FetchVisaLogByVisaIdResponse> fetchVisaLogByVisaId(Long visaId);
|
||||
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package cn.axzo.visa.server.service;
|
||||
|
||||
import cn.axzo.visa.api.enums.VisaStatusEnum;
|
||||
import cn.axzo.visa.api.request.ChangeStatusRequest;
|
||||
|
||||
/**
|
||||
* @author xudawei
|
||||
@ -11,9 +11,7 @@ public interface ChangeRecordService {
|
||||
|
||||
/**
|
||||
* 状态变更
|
||||
* @param changeRecordNo 变签单号
|
||||
* @param updateStatus 更新状态
|
||||
*/
|
||||
Boolean changeStatus(String changeRecordNo, VisaStatusEnum updateStatus);
|
||||
Boolean changeStatus(ChangeStatusRequest request);
|
||||
|
||||
}
|
||||
|
||||
@ -1,13 +1,22 @@
|
||||
package cn.axzo.visa.server.service.impl;
|
||||
|
||||
import cn.axzo.framework.domain.ServiceException;
|
||||
import cn.axzo.visa.api.enums.VisaLogTypeEnum;
|
||||
import cn.axzo.visa.api.response.FetchVisaLogByVisaIdResponse;
|
||||
import cn.axzo.visa.server.domain.ChangeRecordLog;
|
||||
import cn.axzo.visa.server.mapper.ChangeRecordLogDao;
|
||||
import cn.axzo.visa.server.service.ChangeRecordLogService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.google.common.collect.Lists;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author xudawei
|
||||
* @date 2025/01/15
|
||||
@ -25,4 +34,61 @@ public class ChangeRecordLogServiceImpl extends ServiceImpl<ChangeRecordLogDao,
|
||||
public void addLog(ChangeRecordLog log) {
|
||||
this.saveOrUpdate(log);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addLog(Long visaId, VisaLogTypeEnum type, Long personId, Long ouId, Long workspaceId) {
|
||||
ChangeRecordLog log = null;
|
||||
ChangeRecordLog.ChangeRecordLogBuilder builder = ChangeRecordLog.builder();
|
||||
builder.visaId(visaId)
|
||||
.action(type.getAction());
|
||||
switch (type) {
|
||||
case EDIT_FORM:
|
||||
//TODO 获取名称
|
||||
builder.title(String.format(type.getTitle()))
|
||||
.content(String.format(type.getContent()));
|
||||
break;
|
||||
case EDIT_AMOUNT:
|
||||
//TODO 获取名称
|
||||
builder.title(String.format(type.getTitle()))
|
||||
.content(String.format(type.getContent()));
|
||||
break;
|
||||
case UPLOAD_FILE:
|
||||
//TODO 获取名称
|
||||
builder.title(String.format(type.getTitle()))
|
||||
.content(String.format(type.getContent()));
|
||||
break;
|
||||
case DELETE_UPLOAD_FILE:
|
||||
//TODO 获取名称
|
||||
builder.title(String.format(type.getTitle()))
|
||||
.content(String.format(type.getContent()));
|
||||
break;
|
||||
default:
|
||||
throw new ServiceException("变签日志类型不匹配");
|
||||
|
||||
}
|
||||
this.addLog(builder.build());
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过变签Id获取日志
|
||||
* @param visaId 变签Id
|
||||
*/
|
||||
public List<FetchVisaLogByVisaIdResponse> fetchVisaLogByVisaId(Long visaId) {
|
||||
if (Objects.isNull(visaId)) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
List<ChangeRecordLog> logList = this.lambdaQuery().eq(ChangeRecordLog::getVisaId, visaId)
|
||||
.eq(ChangeRecordLog::getIsDelete, 0)
|
||||
.orderByDesc(ChangeRecordLog::getCreateAt)
|
||||
.list();
|
||||
if (CollectionUtils.isEmpty(logList)) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
return logList.stream().map(item -> FetchVisaLogByVisaIdResponse.builder()
|
||||
.title(item.getTitle())
|
||||
.content(item.getContent())
|
||||
.createAt(item.getCreateAt())
|
||||
.build()).collect(Collectors.toList());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,17 +1,20 @@
|
||||
package cn.axzo.visa.server.service.impl;
|
||||
|
||||
import cn.axzo.framework.domain.ServiceException;
|
||||
import cn.axzo.visa.api.enums.VisaLogTypeEnum;
|
||||
import cn.axzo.visa.api.enums.VisaStatusEnum;
|
||||
import cn.axzo.visa.api.request.ChangeStatusRequest;
|
||||
import cn.axzo.visa.server.domain.ChangeRecord;
|
||||
import cn.axzo.visa.server.domain.ChangeRecordLog;
|
||||
import cn.axzo.visa.server.mapper.ChangeRecordDao;
|
||||
import cn.axzo.visa.server.service.ChangeRecordLogService;
|
||||
import cn.axzo.visa.server.service.ChangeRecordService;
|
||||
import com.alibaba.excel.util.StringUtils;
|
||||
import cn.hutool.core.lang.Pair;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.google.common.collect.Lists;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
@ -29,55 +32,121 @@ public class ChangeRecordServiceImpl extends ServiceImpl<ChangeRecordDao, Change
|
||||
@Resource
|
||||
private ChangeRecordLogService changeRecordLogService;
|
||||
|
||||
public Boolean changeStatus(String changeRecordNo, VisaStatusEnum updateStatus) {
|
||||
if (StringUtils.isBlank(changeRecordNo) || Objects.isNull(updateStatus)) {
|
||||
return false;
|
||||
}
|
||||
public Boolean changeStatus(ChangeStatusRequest request) {
|
||||
request.check();
|
||||
// 1 构建前置状态与日志
|
||||
Pair<List<VisaStatusEnum>, ChangeRecordLog> pair = this.buildPreStatusAndLog(request.getUpdateStatus(), request.getLogType());
|
||||
// 2 更新状态
|
||||
this.updateVisaStatus(request.getVisaId(), pair.getKey(), request.getUpdateStatus());
|
||||
// 3 新增日志
|
||||
this.addLog(pair.getValue());
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean update = this.lambdaUpdate().eq(ChangeRecord::getNo, changeRecordNo)
|
||||
/**
|
||||
* 更新变签状态
|
||||
*/
|
||||
private boolean updateVisaStatus(Long visaId, List<VisaStatusEnum> statusList, VisaStatusEnum updateStatus) {
|
||||
boolean update = this.lambdaUpdate().eq(ChangeRecord::getId, visaId)
|
||||
.eq(ChangeRecord::getIsDelete, 0)
|
||||
.in(ChangeRecord::getStatus, this.preStatusListByUpdateStatus(updateStatus))
|
||||
.in(ChangeRecord::getStatus, statusList)
|
||||
.set(ChangeRecord::getStatus, updateStatus)
|
||||
.update();
|
||||
if (!update) {
|
||||
throw new ServiceException("更新状态失败");
|
||||
}
|
||||
ChangeRecordLog log = ChangeRecordLog.builder().build();
|
||||
changeRecordLogService.addLog(log);
|
||||
return true;
|
||||
return update;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加日志
|
||||
*/
|
||||
private void addLog(ChangeRecordLog log) {
|
||||
if (Objects.nonNull(log) && StringUtils.hasText(log.getTitle())) {
|
||||
changeRecordLogService.addLog(log);
|
||||
}
|
||||
}
|
||||
|
||||
private String userName(Long personId, Long ouId, Long workspaceId) {
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新前置状态
|
||||
*/
|
||||
private List<VisaStatusEnum> preStatusListByUpdateStatus(VisaStatusEnum updateStatus) {
|
||||
private Pair<List<VisaStatusEnum>, ChangeRecordLog> buildPreStatusAndLog(VisaStatusEnum updateStatus, VisaLogTypeEnum logType) {
|
||||
List<VisaStatusEnum> preStatusList;
|
||||
ChangeRecordLog.ChangeRecordLogBuilder builder = ChangeRecordLog.builder();
|
||||
switch (updateStatus) {
|
||||
case DECIDING:
|
||||
// 动作: 创建群聊洽商
|
||||
// 状态流转:[待提报|审核不通过的待提报] --> [决策中]
|
||||
builder.action(updateStatus.getLogType().getAction());
|
||||
builder.title(updateStatus.getLogType().getTitle());
|
||||
builder.content(updateStatus.getLogType().getContent());
|
||||
|
||||
preStatusList = Lists.newArrayList(VisaStatusEnum.TO_REPORT, VisaStatusEnum.REPORT_FROM_APPROVE);
|
||||
break;
|
||||
case EXECUTING:
|
||||
// 动作:执行
|
||||
// 状态流转:[决策中|审核不通过的待提报]-->[执行中]
|
||||
builder.action(updateStatus.getLogType().getAction());
|
||||
builder.title(updateStatus.getLogType().getTitle());
|
||||
builder.content(updateStatus.getLogType().getContent());
|
||||
|
||||
preStatusList = Lists.newArrayList(VisaStatusEnum.DECIDING, VisaStatusEnum.DECIDING_FROM_APPROVE);
|
||||
break;
|
||||
case APPROVING:
|
||||
// 动作:发起审批
|
||||
// 状态流转:[待提报|审批不通过的待提报|决策中|审批不通过的决策中|执行中]-->[审批中]
|
||||
builder.action(updateStatus.getLogType().getAction());
|
||||
builder.title(updateStatus.getLogType().getTitle());
|
||||
builder.content(updateStatus.getLogType().getContent());
|
||||
|
||||
preStatusList = Lists.newArrayList(VisaStatusEnum.TO_REPORT, VisaStatusEnum.REPORT_FROM_APPROVE, VisaStatusEnum.DECIDING, VisaStatusEnum.DECIDING_FROM_APPROVE,VisaStatusEnum.EXECUTING);
|
||||
break;
|
||||
case REPORT_FROM_APPROVE:
|
||||
//TODO
|
||||
// 动作:审批不通过(已驳回、已撤回、已中止)
|
||||
// 状态流转:[审批中]-->[审核不通过的待提报]
|
||||
builder.action(logType.getAction());
|
||||
builder.title(logType.getTitle());
|
||||
builder.content(logType.getContent());
|
||||
|
||||
preStatusList = Lists.newArrayList(VisaStatusEnum.APPROVING);
|
||||
break;
|
||||
case DECIDING_FROM_APPROVE:
|
||||
preStatusList = Lists.newArrayList(VisaStatusEnum.TO_REPORT, VisaStatusEnum.REPORT_FROM_APPROVE, VisaStatusEnum.APPROVING);
|
||||
break;
|
||||
case DECIDING:
|
||||
preStatusList = Lists.newArrayList(VisaStatusEnum.TO_REPORT, VisaStatusEnum.REPORT_FROM_APPROVE,VisaStatusEnum.APPROVING);
|
||||
break;
|
||||
case EXECUTING:
|
||||
preStatusList = Lists.newArrayList(VisaStatusEnum.DECIDING);
|
||||
break;
|
||||
case APPROVING:
|
||||
preStatusList = Lists.newArrayList(VisaStatusEnum.TO_REPORT, VisaStatusEnum.REPORT_FROM_APPROVE, VisaStatusEnum.DECIDING, VisaStatusEnum.DECIDING_FROM_APPROVE,VisaStatusEnum.EXECUTING);
|
||||
break;
|
||||
case COMPLETED:
|
||||
//TODO
|
||||
// 动作:审批不通过(已驳回、已撤回、已中止)
|
||||
// 状态流转:[审批中]-->[审核不通过的决策中]
|
||||
builder.action(logType.getAction());
|
||||
builder.title(logType.getTitle());
|
||||
builder.content(logType.getContent());
|
||||
|
||||
preStatusList = Lists.newArrayList(VisaStatusEnum.APPROVING);
|
||||
break;
|
||||
case FORBIDED:
|
||||
// 动作:作废
|
||||
// 状态流转:[待提报|审核不通过的待提报|决策中|审核不通过的决策中|执行中|审批中]-->[审核不通过的决策中]
|
||||
builder.action(updateStatus.getLogType().getAction());
|
||||
builder.title(updateStatus.getLogType().getTitle());
|
||||
builder.content(updateStatus.getLogType().getContent());
|
||||
|
||||
preStatusList = Lists.newArrayList(VisaStatusEnum.TO_REPORT, VisaStatusEnum.REPORT_FROM_APPROVE, VisaStatusEnum.DECIDING, VisaStatusEnum.DECIDING_FROM_APPROVE,VisaStatusEnum.EXECUTING,VisaStatusEnum.APPROVING);
|
||||
break;
|
||||
case COMPLETED:
|
||||
// 动作:整个审批通过
|
||||
// 状态流转:[审批中]-->[已完成]
|
||||
builder.action(updateStatus.getLogType().getAction());
|
||||
builder.title(updateStatus.getLogType().getTitle());
|
||||
builder.content(updateStatus.getLogType().getContent());
|
||||
|
||||
preStatusList = Lists.newArrayList(VisaStatusEnum.APPROVING);
|
||||
break;
|
||||
default:
|
||||
throw new ServiceException("更新状态不匹配");
|
||||
throw new ServiceException("更新状态类型不匹配");
|
||||
}
|
||||
return preStatusList;
|
||||
return Pair.of(preStatusList, builder.build());
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user