Commit 2b85771d by tangzhaoqian Committed by chenzg

审批人审批,热部署关闭(启动会导致 反序列化 转换 对象出错)

parent f8b0dff9
......@@ -102,11 +102,11 @@
</dependency>
<!-- optional这个需要为 true 热部署才有效 -->
<dependency>
<!-- <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
</dependency> -->
<!-- swagger2 -->
<dependency>
......@@ -272,7 +272,7 @@
<version>1.1.10</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.baomidou/mybatis-plus-boot-starter -->
<!-- mybatis-plus -->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
......
package cn.timer.api.bean.spmk;
import java.util.Date;
import java.util.List;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
......@@ -57,4 +58,6 @@ public class SpmkApproveExecuteRecord extends Model<SpmkApproveExecuteRecord> {
@ApiModelProperty(value = "创建时间 ", example = "创建时间")
private Date createTime;
private List<SpmkExecutor> spmkExecutors;
}
\ No newline at end of file
......@@ -64,7 +64,7 @@ public class SpmkApproveSummary extends Model<SpmkApproveSummary> {
private String approveName;
@TableField(fill = FieldFill.INSERT)
@ApiModelProperty(value = "状态 0审批中 1审批撤销 2审批拒绝 3审批通过/审批完成", example = "101")
@ApiModelProperty(value = "状态 0审批中 1审批撤销 2审批通过/审批完成 3审批拒绝", example = "101")
private Integer sts;
@ApiModelProperty(value = "当前审批人 ", example = "当前审批人")
......
......@@ -18,7 +18,11 @@ public class MyMetaObjectHandler implements MetaObjectHandler {
log.info("start insert fill ....");
Date date = new Date();
this.strictInsertFill(metaObject, "createTime", Date.class, date); // 起始版本 3.3.0(推荐使用)
this.strictInsertFill(metaObject, "sts", Integer.class, 0); // 起始版本 3.3.0(推荐使用)
this.strictInsertFill(metaObject, "lrsjTime", Date.class, date);
this.strictInsertFill(metaObject, "regTime", Date.class, date);
this.strictInsertFill(metaObject, "registerTime", Date.class, date);
this.strictInsertFill(metaObject, "addtime", Date.class, date);
this.strictInsertFill(metaObject, "sts", int.class, 0); // 起始版本 3.3.0(推荐使用)
}
......@@ -27,6 +31,7 @@ public class MyMetaObjectHandler implements MetaObjectHandler {
log.info("start update fill ....");
Date date = new Date();
this.strictUpdateFill(metaObject, "updateTime", Date.class, date); // 起始版本 3.3.0(推荐使用)
this.strictUpdateFill(metaObject, "modifyTime", Date.class, date);
}
}
......@@ -60,7 +60,9 @@ import cn.timer.api.dao.spmk.SpmkExecutorMapper;
import cn.timer.api.dao.spmk.SpmkInitiatorConfigMapper;
import cn.timer.api.dao.spmk.SpmkSpglMapper;
import cn.timer.api.dao.spmk.SpmkSpzMapper;
import cn.timer.api.dto.spmk.ApprovingDto;
import cn.timer.api.dto.spmk.FlowChildren;
import cn.timer.api.dto.spmk.FromData;
import cn.timer.api.dto.spmk.Router;
import cn.timer.api.dto.spmk.Spmk;
import cn.timer.api.dto.spmk.SpmkApprovalTemplateDto;
......@@ -377,18 +379,6 @@ public class SpmkServiceImpl {
}
/**
* 图标列表
*/
@GetMapping(value = "/icon")
@ApiOperation(value = "图标列表", httpMethod = "GET", notes = "接口发布说明")
public Result<List<SpmkIcon>> selectListIcon(@CurrentUser UserBean userBean){
List<SpmkIcon> spmkIcons = SpmkIcon.builder().build().selectAll();
return ResultUtil.data(spmkIcons,"获取图标列表成功");
}
/**
* 假期规则列表
*/
@GetMapping(value = "/jqgz")
......@@ -475,7 +465,18 @@ public class SpmkServiceImpl {
@Autowired
private SpmkCustomApprovalMapper spmkCustomApprovalMapper;
/**
* 图标列表
*/
@GetMapping(value = "/icon")
@ApiOperation(value = "99.图标列表", httpMethod = "GET", notes = "接口发布说明")
@ApiOperationSupport(order = 99)
public Result<List<SpmkIcon>> selectListIcon(@CurrentUser UserBean userBean){
List<SpmkIcon> spmkIcons = SpmkIcon.builder().build().selectAll();
return ResultUtil.data(spmkIcons,"获取图标列表成功");
}
//TODO 审批模板组
......@@ -488,7 +489,7 @@ public class SpmkServiceImpl {
@ApiOperationSupport(order = 1)
public Result<Object> saveAtg(@RequestBody SpmkApprovalTemplateG spmkApprovalTemplateG){
return spmkApprovalTemplateG.insertOrUpdate() ? ResultUtil.success("操作成功!") : ResultUtil.error("操作失败!");
return spmkApprovalTemplateG.insertOrUpdate() ? ResultUtil.data(spmkApprovalTemplateG, "操作成功!") : ResultUtil.error("操作失败!");
}
......@@ -550,7 +551,13 @@ public class SpmkServiceImpl {
at.setFroms(ObjectUtil.serialize(spmkApprovalTemplateDto.getFroms()));
at.setRouter(ObjectUtil.serialize(spmkApprovalTemplateDto.getRouter()));
return at.insertOrUpdate() ? ResultUtil.success("操作成功!") : ResultUtil.error("操作失败!-2");
if (!at.insertOrUpdate())
return ResultUtil.error("操作失败!-2");
// 清空前端不需要的字段再返回,节省流量
at.setFroms(null);
at.setRouter(null);
return ResultUtil.data(at, "操作成功!");
}
......@@ -601,7 +608,7 @@ public class SpmkServiceImpl {
@ApiOperationSupport(order = 9)
public Result<Object> saveAg(@CurrentUser UserBean userBean,@RequestBody SpmkApprovalG spmkApprovalG){
spmkApprovalG.setOrgCode(userBean.getOrgCode());
return spmkApprovalG.insertOrUpdate() ? ResultUtil.success("操作成功!") : ResultUtil.error("操作失败!");
return spmkApprovalG.insertOrUpdate() ? ResultUtil.data(spmkApprovalG, "操作成功!") : ResultUtil.error("操作失败!");
}
......@@ -639,7 +646,6 @@ public class SpmkServiceImpl {
@ApiOperation(value = "12.排序-审批组", httpMethod = "PUT", notes = "排序-审批组")
@ApiOperationSupport(order = 12)
public Result<Object> ranksAg(@RequestBody List<SpmkApprovalG> list){
return spmkApprovalGMapper.updateListRandsById(list) ? ResultUtil.success("操作成功!") : ResultUtil.error("操作失败!");
}
......@@ -670,9 +676,18 @@ public class SpmkServiceImpl {
Console.log("自定义审批id: " + id);
List<SpmkInitiatorConfig> listIc = spmkCustomApprovalDto.getInitiatorConfigs();
for (int i = 0, n = listIc.size(); i < n; i++) {
listIc.get(i).setCustomApprovalId(id);
if (listIc != null && listIc.size() > 0) {
for (int i = 0, n = listIc.size(); i < n; i++) {
listIc.get(i).setCustomApprovalId(id);
}
if (!spmkInitiatorConfigMapper.insertList(listIc)) {
// 手动抛出异常,事务回滚
throw new Exception();
}
}
SpmkInitiatorConfig.builder().build().delete(new QueryWrapper<SpmkInitiatorConfig>().lambda().eq(SpmkInitiatorConfig::getCustomApprovalId, id));
//
/**
......@@ -681,27 +696,30 @@ public class SpmkServiceImpl {
* 2.新增 最新的 SpmkInitiatorConfig-审批发起人配置,
* 3.新增 SpmkCustomApproval-自定义审批
*/
if (!SpmkInitiatorConfig.builder().build().delete(new QueryWrapper<SpmkInitiatorConfig>().lambda().eq(SpmkInitiatorConfig::getCustomApprovalId, id)) ||
!spmkInitiatorConfigMapper.insertList(listIc)) {
// 手动抛出异常,事务回滚
throw new Exception();
}
return ResultUtil.success("操作成功!");
// 清空前端不需要的字段再返回,节省流量
ca.setFroms(null);
ca.setRouter(null);
return ResultUtil.data(ca, "操作成功!");
}
/**
* 删除-自定义审批
* @throws Exception
*/
@DeleteMapping(value = "/delete_custom_approval/{id}")
@ApiOperation(value = "14.删除-自定义审批", httpMethod = "DELETE", notes = "删除-自定义审批")
@Transactional(rollbackFor = Exception.class)
@ApiOperationSupport(order = 14)
public Result<Object> deleteCaById(@PathVariable int id){
return SpmkCustomApproval.builder().id(id).build().deleteById() &&
SpmkInitiatorConfig.builder().build().delete(new QueryWrapper<SpmkInitiatorConfig>().lambda().eq(SpmkInitiatorConfig::getCustomApprovalId, id)) ?
ResultUtil.success("操作成功!") : ResultUtil.error("没有找到该对象");
public Result<Object> deleteCaById(@PathVariable int id) throws Exception{
SpmkInitiatorConfig.builder().build().delete(new QueryWrapper<SpmkInitiatorConfig>().lambda().eq(SpmkInitiatorConfig::getCustomApprovalId, id));
if (!SpmkCustomApproval.builder().id(id).build().deleteById()) {
throw new Exception();
}
return ResultUtil.success("操作成功!");
}
......@@ -712,8 +730,14 @@ public class SpmkServiceImpl {
@ApiOperation(value = "15.id查询-自定义审批", httpMethod = "GET", notes = "id查询-自定义审批")
@ApiOperationSupport(order = 15)
public Result<Object> selectCaById(@PathVariable int id){
return ResultUtil.data(SpmkCustomApproval.builder().id(id).build().selectById(),"操作成功!");
SpmkCustomApproval ca = SpmkCustomApproval.builder().id(id).build().selectById();
SpmkCustomApprovalDto caD = SpmkCustomApprovalDto.builder()
.froms((List<JSONObject>)ObjectUtil.unserialize(ca.getFroms()))
.router(ObjectUtil.unserialize(ca.getRouter()))
.build();
BeanUtil.copyProperties(ca, caD,"froms","router");
return ResultUtil.data(caD,"操作成功!");
}
......@@ -756,14 +780,18 @@ public class SpmkServiceImpl {
List<Router> listRouter = new ArrayList<Router>();
listRouter.add(spmkApproveSummaryDto.getRouter());
JSONObject jSONObject = spmkApproveSummaryDto.getRequestData().put("orgCode", userBean.getOrgCode());
JSONObject jSONObject = spmkApproveSummaryDto.getRequestData()
.put("orgCode", FromData.builder().value(String.valueOf(userBean.getOrgCode())).build())
.put("initiator", FromData.builder().value(spmkApproveSummaryDto.getInitiator()).build());
RouterUtils.NextNode(listRouter, jSONObject, ISFIRST);
List<FlowChildren> listFlowChildren = new ArrayList<FlowChildren>();
RouterUtils.getIsFlowChildren(listRouter,listFlowChildren);
System.out.println(jSONObject);
System.out.println(listRouter);
System.out.println(listFlowChildren);
// System.out.println(jSONObject);
// System.out.println(listRouter);
// System.out.println(listFlowChildren);
// 当前审批人
String currentApprover = jSONObject.getStr("current_approver");
......@@ -775,18 +803,22 @@ public class SpmkServiceImpl {
.title(spmkApproveSummaryDto.getTitle())
.initiator(spmkApproveSummaryDto.getInitiator())
.approveName(spmkApproveSummaryDto.getApproveName())
.sts(0)
.currentApprover(currentApprover).build();
if (!as.insert()) {
return ResultUtil.error("操作失败!");
}
// 插入记录
RouterUtils.insertogExecuteRecord(listFlowChildren, as.getId());
// 封装 审批详情
SpmkApproveDetail ad = SpmkApproveDetail.builder().build();
ad.setApproveSummaryId(as.getId());
ad.setName(spmkApproveSummaryDto.getTitle());
ad.setRequestData(ObjectUtil.serialize(spmkApproveSummaryDto.getRequestData()));
ad.setFroms(ObjectUtil.serialize(spmkApproveSummaryDto.getFroms()));
ad.setFroms(ObjectUtil.serialize((List<JSONObject>)spmkApproveSummaryDto.getFroms()));
ad.setRouter(ObjectUtil.serialize(listRouter.get(0)));
ad.setFlowChildren(ObjectUtil.serialize(listFlowChildren));
......@@ -837,6 +869,41 @@ public class SpmkServiceImpl {
return ResultUtil.data(adD, "操作成功!");
}
//TODO 审批人审批
/**
* 审批人审批
*/
@PostMapping(value = "/approving")
@ApiOperation(value = "20.审批人审批", httpMethod = "POST", notes = "审批人审批")
@ApiOperationSupport(order = 19)
public Result<Object> approving(@RequestBody ApprovingDto approvingDto) {
SpmkApproveDetail ad = SpmkApproveDetail.builder().build()
.selectOne(new QueryWrapper<SpmkApproveDetail>()
.lambda()
.eq(SpmkApproveDetail::getApproveSummaryId, approvingDto.getAsId()));
SpmkApproveSummary aSummary = spmkApproveSummaryMapper.selectById(approvingDto.getAsId());
if (aSummary.getSts() == 0) {
List<FlowChildren> listFlowChildren = (List<FlowChildren>)ObjectUtil.unserialize(ad.getFlowChildren());
RouterUtils.approving(
listFlowChildren,
approvingDto.getAsId(),
approvingDto.getExecuteRecordId(),
approvingDto.getExecutorId(),
approvingDto.getOpinion(),
approvingDto.getSts());
System.out.println(listFlowChildren);
// 更新 flowChildren
SpmkApproveDetail.builder().id(ad.getId()).froms(ObjectUtil.serialize(listFlowChildren)).build().updateById();
}else {
return ResultUtil.error("该审批已结束!");
}
return ResultUtil.data(null, "操作成功!");
}
......
package cn.timer.api.dto.spmk;
import java.util.Date;
import java.util.List;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import cn.hutool.json.JSONObject;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ApprovingDto {
@ApiModelProperty(value = "审批汇总id", example = "2")
private Integer asId;
@ApiModelProperty(value = "审批执行记录id", example = "10")
private Integer executeRecordId;
@ApiModelProperty(value = "执行人记录id", example = "10")
private Integer executorId;
@ApiModelProperty(value = "意见", example = "MMMMMMMM")
private String opinion;
@ApiModelProperty(value = "状态 2同意 3拒绝", example = "2")
private Integer sts;
}
package cn.timer.api.dto.spmk;
import java.io.Serializable;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Builder;
......@@ -18,10 +19,14 @@ public class Condition implements Serializable {
*/
private static final long serialVersionUID = 1L;
private String className;
private String displayName;
private String key;
private String format;
private String value;
private List<String> values;
}
......@@ -55,4 +55,9 @@ public class Router extends JSONSupport implements Serializable{
*/
private List<Router> children;
/**
* 名称
*/
private String name;
}
package cn.timer.api.dto.spmk;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Entity;
import cn.timer.api.bean.spmk.SpmkApprovalG;
import cn.hutool.json.JSONObject;
import cn.timer.api.bean.spmk.SpmkCustomApproval;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class SpmkApprovalGDto extends SpmkApprovalG {
public class SpmkApprovalGDto implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "编号 编号", example = "101")
private Integer id;
@ApiModelProperty(value = "企业组织代码 企业组织代码", example = "101")
private Integer orgCode;
@ApiModelProperty(value = "组名 ", example = "组名")
private String name;
@ApiModelProperty(value = "排序 排序", example = "101")
private Integer ranks;
@ApiModelProperty(value = "是否可编辑 0是 1否", example = "101")
private Integer isEditable;
private List<SpmkCustomApproval> spmkCustomApprovals;
}
package cn.timer.api.dto.spmk;
import java.util.Date;
import java.util.List;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
......@@ -38,7 +39,7 @@ public class SpmkApproveSummaryDto{
private JSONObject requestData;
@ApiModelProperty(value = "审批表单 ", example = "审批表单")
private JSONObject froms;
private List<JSONObject> froms;
@ApiModelProperty(value = "审批流程 ", example = "审批流程")
private Router router;
......
......@@ -54,13 +54,12 @@ public class SpmkCustomApprovalDto {
private Integer assoType;
@ApiModelProperty(value = "审批表单 ", example = "审批表单")
private JSONObject froms;
private List<JSONObject> froms;
@ApiModelProperty(value = "审批流程 ", example = "审批流程")
private Router router;
@ApiModelProperty(value = "可见发起人配置 ", example = "可见发起人配置 ")
private List<SpmkInitiatorConfig> initiatorConfigs;
}
......@@ -9,9 +9,10 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.lang.Console;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ReflectUtil;
import cn.hutool.json.JSONObject;
import cn.timer.api.bean.spmk.SpmkApproveExecuteRecord;
import cn.timer.api.bean.spmk.SpmkApproveSummary;
import cn.timer.api.bean.spmk.SpmkExecutor;
import cn.timer.api.bean.yggl.YgglMainEmp;
import cn.timer.api.bean.zzgl.ZzglBmgwM;
import cn.timer.api.dto.spmk.Condition;
......@@ -83,6 +84,7 @@ public class RouterUtils {
if (isFirse) {
obj.put("current_approver", listUser.get(i).getName());
}
break user;
// case EXECUTING:
// listUser.get(i).setExecute(EXECUTED);
......@@ -90,7 +92,7 @@ public class RouterUtils {
}
}
isAuditNext = true;
NextNode(router.getChildren(),obj, isFirse, isAuditNext);
NextNode(router.getChildren(), obj , isFirse, isAuditNext);
break;
case COPY:
if (!isAuditNext) {
......@@ -102,7 +104,7 @@ public class RouterUtils {
for (int i = 0; i < listRelations.size(); i++) {
// 装配 部门人员
if (RELATION_TYPE_DEPARTMENT.equals(listRelations.get(i).getType())) {
List<YgglMainEmp> listYgglMainEmp = selectOtherlistent(obj.get("orgCode",Integer.class), Integer.valueOf(listRelations.get(i).getDepartmentId()));
List<YgglMainEmp> listYgglMainEmp = selectOtherlistent(Integer.parseInt(obj.get("orgCode",FromData.class).getValue()), Integer.valueOf(listRelations.get(i).getDepartmentId()));
List<User> listUsers = new ArrayList<User>();
for (YgglMainEmp emp : listYgglMainEmp) {
User user = new User();
......@@ -111,11 +113,12 @@ public class RouterUtils {
listUsers.add(user);
}
listRelations.get(i).setUsers(listUsers);
}else if (RELATION_TYPE_USERS.equals(listRelations.get(i).getType())) {
// 直接跳过,此处 else if代码段 只做说明,可不写
}
}
NextNode(router.getChildren(),obj, isFirse, isAuditNext);
NextNode(router.getChildren(), obj , isFirse, isAuditNext);
break;
}
break;
......@@ -146,13 +149,13 @@ public class RouterUtils {
}
}
NextNode(router.getChildren(),obj, isFirse, isAuditNext);
NextNode(router.getChildren(),obj , isFirse, isAuditNext);
break;
}
break;
case EXECUTED:
Console.log("下一个节点");
NextNode(router.getChildren(),obj, isFirse, isAuditNext);
NextNode(router.getChildren(),obj , isFirse, isAuditNext);
break;
}
......@@ -168,10 +171,12 @@ public class RouterUtils {
routerRule.setFlow(true);
}else {
for (Condition condition : listCondition) {
// 判断条件
if (!stringCompare(obj.get(condition.getKey(),FromData.class).getValue(), condition.getValue(), condition.getFormat())) {
condition_b = false;
}
for (String string : condition.getValues()) {
// 判断条件
if (!stringCompare(obj.get(condition.getKey(),FromData.class).getValue(), string , condition.getFormat())) {
condition_b = false;
}
}
}
}
......@@ -179,12 +184,12 @@ public class RouterUtils {
routerRule.setExecute(EXECUTED);
if (routerRule.getFlow()) {
Console.log("条件逻辑");
NextNode(routerRule.getChildren(),obj, isFirse, isAuditNext);
NextNode(routerRule.getChildren(), obj , isFirse, isAuditNext);
}
break;
case EXECUTED:
if (routerRule.getFlow()) {
NextNode(routerRule.getChildren(),obj, isFirse, isAuditNext);
NextNode(routerRule.getChildren(), obj , isFirse, isAuditNext);
}
break rulefor;
}
......@@ -278,22 +283,265 @@ public class RouterUtils {
}
}
}
};
// 审批执行记录 持久化
public static void insertogExecuteRecord(List<FlowChildren> listFlowChildren,Integer asId) {
for (int i = 0,m = listFlowChildren.size() ; i < m; i++) {
if (UNEXECUTED.equals(listFlowChildren.get(i).getExecute()))
continue;
switch (listFlowChildren.get(i).getClassName()) {
case CREATOR:
SpmkApproveExecuteRecord aer = SpmkApproveExecuteRecord
.builder()
.approveSummaryId(asId)
.name("发起申请")
.type(0)
.sts(2)
.build();
// 新增 审批执行记录
aer.insert();
// 新增 执行人
User user = listFlowChildren.get(i).getRelation().get(0).getUsers().get(0);
SpmkExecutor.builder()
.approveExecuteRecordId(aer.getId())
.empNum(Integer.parseInt(user.getId()))
.executorName(user.getName())
.sts(2)
.build()
.insert();
break;
case AUDIT:
SpmkApproveExecuteRecord aer2 = SpmkApproveExecuteRecord
.builder()
.approveSummaryId(asId)
.name("审批人")
.type(2)
.sts(1)
.build();
// 新增 审批执行记录
aer2.insert();
// 新增 执行人
List<User> listUser = listFlowChildren.get(i).getRelation().get(0).getUsers();
executor:
for (User user2 : listUser) {
SpmkExecutor executor = SpmkExecutor.builder()
.approveExecuteRecordId(aer2.getId())
.empNum(Integer.parseInt(user2.getId()))
.executorName(user2.getName())
.build();
switch (user2.getExecute()) {
case EXECUTING:
executor.setSts(1);
executor.insert();
break executor;
case EXECUTED:
executor.setSts(2);
executor.insert();
break;
}
}
break;
case COPY:
SpmkApproveExecuteRecord aer3 = SpmkApproveExecuteRecord
.builder()
.approveSummaryId(asId)
.name("抄送人")
.type(1)
.sts(2)
.build();
// 新增 审批执行记录
aer3.insert();
List<Relation> listRelation = listFlowChildren.get(i).getRelation();
for (Relation relation : listRelation) {
List<User> listUser2 = relation.getUsers();
// 新增 执行人
for (User user2 : listUser2) {
SpmkExecutor executor = SpmkExecutor.builder()
.approveExecuteRecordId(aer3.getId())
.empNum(Integer.parseInt(user2.getId()))
.executorName(user2.getName())
.sts(2)
.build();
executor.insert();
}
}
break;
}
}
}
/**
* 审批持久化
* @param listFlowChildren 节点
* @param asId 审批汇总Id
* @param executorId 执行人记录Id
* @param opinion 意见
* @param sts 状态 1执行中 2通过 3拒绝
*/
public static void approving(List<FlowChildren> listFlowChildren,Integer asId,Integer executeRecordId, Integer executorId, String opinion,Integer sts ) {
boolean hasNextApprover = false;
for (int i = 0,n = listFlowChildren.size(); i < n; i++) {
// 新增 执行人
List<User> listUser = listFlowChildren.get(i).getRelation().get(0).getUsers();
if (EXECUTED.equals(listFlowChildren.get(i).getExecute())) {
continue;
}else if (EXECUTING.equals(listFlowChildren.get(i).getExecute())) {
// 新增 执行人
// listUser = flowChildren.getRelation().get(0).getUsers();
for (int i_user = 0, n_user = listUser.size(); i_user < n_user; i_user++) {
if (EXECUTED.equals(listUser.get(i_user).getExecute())) {
continue;
}else if (EXECUTING.equals(listUser.get(i_user).getExecute())) {
SpmkExecutor.builder()
.id(executorId)
.opinion(opinion)
.empNum(Integer.parseInt(listUser.get(i_user).getId()))
.executorName(listUser.get(i_user).getName())
.sts(sts)
.build()
.updateById();
listUser.get(i_user).setExecute(EXECUTED);
// 0未执行 1执行中 2同意 3拒绝
if (sts == 3) {
// 更新 审批汇总 状态
SpmkApproveSummary.builder().id(asId).sts(sts).build().updateById();
return;
}
}else if (UNEXECUTED.equals(listUser.get(i_user).getExecute())) {
SpmkExecutor.builder()
.approveExecuteRecordId(executeRecordId)
.empNum(Integer.parseInt(listUser.get(i_user).getId()))
.executorName(listUser.get(i_user).getName())
.sts(1)
.build()
.insert();
hasNextApprover = true;
listUser.get(i_user).setExecute(EXECUTING);
}
}
if (!hasNextApprover) {
SpmkApproveExecuteRecord aer = SpmkApproveExecuteRecord
.builder()
.id(executeRecordId)
.sts(2)
.build();
// 更新 审批执行记录
aer.updateById();
listFlowChildren.get(i).setExecute(EXECUTED);
}
}else if (UNEXECUTED.equals(listFlowChildren.get(i).getExecute())) {
if (!hasNextApprover) {
switch (listFlowChildren.get(i).getClassName()) {
case CREATOR:
SpmkApproveExecuteRecord aer = SpmkApproveExecuteRecord
.builder()
.approveSummaryId(asId)
.name("发起申请")
.type(0)
.sts(2)
.build();
// 新增 审批执行记录
aer.insert();
// 新增 执行人
User user = listFlowChildren.get(i).getRelation().get(0).getUsers().get(0);
SpmkExecutor.builder()
.approveExecuteRecordId(aer.getId())
.empNum(Integer.parseInt(user.getId()))
.executorName(user.getName())
.sts(2)
.build()
.insert();
listFlowChildren.get(i).setExecute(EXECUTED);
break;
case AUDIT:
SpmkApproveExecuteRecord aer2 = SpmkApproveExecuteRecord
.builder()
.approveSummaryId(asId)
.name("审批人")
.type(2)
.sts(1)
.build();
// 新增 审批执行记录
aer2.insert();
// 新增 执行人
// listUser = flowChildren.getRelation().get(0).getUsers();
for (int i_user2 = 0,n_user2 = listUser.size(); i_user2 < n_user2; i_user2++) {
User u = listUser.get(i_user2);
SpmkExecutor executor = SpmkExecutor.builder()
.approveExecuteRecordId(aer2.getId())
.empNum(Integer.parseInt(listUser.get(i_user2).getId()))
.executorName(listUser.get(i_user2).getName())
.sts(1)
.build();
executor.insert();
listUser.get(i_user2).setExecute(EXECUTING);
}
listFlowChildren.get(i).setExecute(EXECUTING);
break;
case COPY:
SpmkApproveExecuteRecord aer3 = SpmkApproveExecuteRecord
.builder()
.approveSummaryId(asId)
.name("抄送人")
.type(1)
.sts(2)
.build();
// 新增 审批执行记录
aer3.insert();
List<Relation> listRelation = listFlowChildren.get(i).getRelation();
for (Relation relation : listRelation) {
List<User> listUser2 = relation.getUsers();
// 新增 执行人
for (User user2 : listUser2) {
SpmkExecutor executor = SpmkExecutor.builder()
.approveExecuteRecordId(aer3.getId())
.empNum(Integer.parseInt(user2.getId()))
.executorName(user2.getName())
.sts(2)
.build();
executor.insert();
}
}
listFlowChildren.get(i).setExecute(EXECUTED);
break;
}
}
}
}
};
}
}
......@@ -141,7 +141,7 @@ pagehelper:
logging:
level:
root: info
cn.timer.api.dao: error
cn.timer.api.dao: debug
pattern:
console: '--%p--%m%n'
......
......@@ -60,9 +60,9 @@
b.is_opinion SpmkCustomApproval_is_opinion,
b.update_time SpmkCustomApproval_update_time,
b.create_time SpmkCustomApproval_create_time,
b.asso_type SpmkCustomApproval_asso_type,
b.asso_type SpmkCustomApproval_asso_type<!-- ,
b.froms SpmkCustomApproval_froms,
b.router SpmkCustomApproval_router
b.router SpmkCustomApproval_router -->
</sql>
<select id="selectListAgInCa" resultMap="BaseResultMapDto">
......@@ -73,16 +73,16 @@
LEFT JOIN spmk_custom_approval b ON a.id = b.approval_g_id
WHERE b.org_code = #{org_code} AND b.id in
(
SELECT custom_approval_id FROM spmk_initiator_config WHERE emp_num = #{emp_num} GROUP BY custom_approval_id
)
WHERE a.org_code = #{org_code}
<!-- AND b.id IN (
SELECT custom_approval_id FROM spmk_initiator_config WHERE asso_id = #{emp_num} AND type = 1 GROUP BY custom_approval_id
) -->
ORDER BY a.ranks, b.ranks
</select>
<update id="updateListRandsById" parameterType="list">
<foreach item="item" index="index" collection="list" open="" separator=";" close="">
UPDATE spmk_approval_template_g
UPDATE spmk_approval_g
<set>
<if test ='null != item.ranks'>ranks = #{item.ranks},</if>
</set>
......
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