Commit 40dd9ccc by 翁国栋

审批校验

parent fabb756b
......@@ -154,6 +154,7 @@ public class AdminSpmkController {
}
List<FlowChildren> listFlowChildren = jsonObject.parseArray(ad.getFlowChildren(),FlowChildren.class);
RouterUtils.updateRefuseToAgree(
listFlowChildren,
asId,
......@@ -171,6 +172,21 @@ public class AdminSpmkController {
);
listFlowChildren.forEach(l->{
//如果大节点已经完成
if(l.getClassName().equals("audit")){
if(l.getExecute().equals("2")){
l.getRelation().get(0).getUsers().forEach(v->{
if(!v.getExecute().equals("2")){
v.setExecute("2");
}
});
}else if(l.getExecute().equals("1")){
//大节点未执行完
}
}
});
// 更新 flowChildren
SpmkApproveDetailSummary sadsUpdate = SpmkApproveDetailSummary.builder().id(ad.getId()).flowChildren(JSONArray.fromObject(listFlowChildren).toString()).build();
/*// 审批详情 审批时添加 附件
......@@ -180,10 +196,16 @@ public class AdminSpmkController {
sadsUpdate.updateById();
//最后一条数据
FlowChildren fc = CollUtil.getLast(listFlowChildren);
/** TODO:每次审批都校验一次json是否正确
* 1.验证当前流程是否已完成,如果已完成验证是否有子节点出现未完成的状态
* 2.验证当前节点上面的节点是否已完成,未完成的都改为已完成
* 3.验证当前流程是否全部完成,如果已经完成,修改所有的节点为已完成
* 4.验证当前节点
*/
if (fc.getExecute() == "2") {
// 查询 SpmkApproveSummary 状态
aSummary = spmkApproveSummaryMapper.selectOne(new QueryWrapper<SpmkApproveSummary>().lambda()
......
......@@ -7,11 +7,15 @@ import java.util.List;
import cn.hutool.json.JSONObject;
import cn.timer.api.bean.spmk.*;
import cn.timer.api.config.enuminterface.JxglEnumInterface;
import cn.timer.api.config.enuminterface.SpmkEnumInterface;
import cn.timer.api.dao.spmk.*;
import cn.timer.api.dto.spmk.FlowChildren;
import cn.timer.api.dto.spmk.Router;
import cn.timer.api.dto.spmk.User;
import com.alibaba.fastjson.JSON;
import net.sf.json.JSONArray;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -115,9 +119,71 @@ public class SpmkServiceImpl implements SpmkService{
if (ad == null) {
return null;
}
//修正json
List<FlowChildren> listFlowChildren = jsonObject.parseArray(ad.getFlowChildren(), FlowChildren.class);
for (FlowChildren l :listFlowChildren) {
//如果大节点已经完成 子节点全部改为已完成
if(l.getClassName().equals("audit")){
if(l.getExecute().equals("2")){
l.getRelation().get(0).getUsers().forEach(v->{
if(!v.getExecute().equals("2")){
v.setExecute("2");
}
});
}
// else if(l.getExecute().equals("1")){
// int count1=0;
// int count2 = 0;
// //大节点未执行完
// List<User> listUser = l.getRelation().get(0).getUsers();
// for (int i = 0; i < listUser.size(); i++) {
// User currentUser = listUser.get(i);
// String execute = listUser.get(i).getExecute();
// //统计数子节点的数量
// if(execute.equals("1")){
// count1=+1;
// }
// if(execute.equals("2")){
// count2=+1;
// }
// //当前用户执行记录
// SpmkApproveExecuteRecord spmkApproveExecuteRecord = spmkApproveExecuteRecordMapper.selectExecuteRecordById(Integer.parseInt(currentUser.getId()), asId);
// if(spmkApproveExecuteRecord!=null){
// //如果json状态等于执行记录的里状态就是对的
// if(spmkApproveExecuteRecord.getSts().toString().equals(execute)){
// continue;
// }else{
// l.getRelation().get(0).getUsers().get(i).setExecute(spmkApproveExecuteRecord.getSts().toString());
// }
// }
// }
// if(count1==listUser.size()){
// l.setExecute("1");
// }
// if(count2==listUser.size()){
// l.setExecute("2");
// }
// }
else if(l.getExecute().equals("0")) {
//大节点未执行 子节点全部改为未执行
if (l.getExecute().equals(JxglEnumInterface.ProcessNodeSts.NON_EXECUTION.getType())) {
l.getRelation().get(0).getUsers().forEach(v -> {
if (!v.getExecute().equals("0")) {
v.setExecute("0");
}
});
}
}
}
}
ad.setFlowChildren(JSONArray.fromObject(listFlowChildren).toString());
ad.updateById();
//审批操作记录
List<SpmkApproveExecuteRecord> listAer = spmkApproveExecuteRecordMapper.selectListByAsId(asId);
BeanUtil.copyProperties(ad, adD, "requestData","froms","router","flowChildren","spmkApproveExecuteRecord");
if(ad.getRequestData() !=null) {
adD.setRequestData(jsonObject.parseObject(ad.getRequestData(), JSONObject.class));
}
......
......@@ -167,7 +167,7 @@
-->
<select id="selectExecuteRecordById" resultType="cn.timer.api.bean.spmk.SpmkApproveExecuteRecord">
SELECT sr.id FROM spmk_approve_execute_record sr
SELECT sr.id,sr.sts FROM spmk_approve_execute_record sr
LEFT JOIN spmk_executor se ON se.approve_execute_record_id=sr.id
WHERE sr.approve_summary_id = #{approveSummaryId} and se.emp_num = #{userId}
</select>
......
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