|
@@ -3,9 +3,13 @@ package com.malk.shantai.service.impl;
|
|
|
import cn.hutool.http.HttpUtil;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.malk.server.common.McR;
|
|
|
import com.malk.server.dingtalk.DDR_New;
|
|
|
import com.malk.shantai.config.StEkbConfig;
|
|
|
+import com.malk.shantai.entity.Shantai;
|
|
|
+import com.malk.shantai.mapper.ShantaiMapper;
|
|
|
import com.malk.shantai.service.StDingProcService;
|
|
|
import com.malk.service.dingtalk.DDClient;
|
|
|
import com.malk.service.dingtalk.DDClient_Workflow;
|
|
@@ -27,7 +31,7 @@ import java.util.*;
|
|
|
|
|
|
@Service
|
|
|
@Slf4j
|
|
|
-public class StDingProcServiceImpl implements StDingProcService {
|
|
|
+public class StDingProcServiceImpl extends ServiceImpl<ShantaiMapper, Shantai> implements StDingProcService {
|
|
|
|
|
|
@Autowired
|
|
|
private DDClient_Workflow ddClient_workflow;
|
|
@@ -38,6 +42,9 @@ public class StDingProcServiceImpl implements StDingProcService {
|
|
|
@Autowired
|
|
|
private StEkbConfig stEkbConfig;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ShantaiMapper shantaiMapper;
|
|
|
+
|
|
|
@Value("${download.path}")
|
|
|
private String filePath;
|
|
|
|
|
@@ -209,7 +216,18 @@ public class StDingProcServiceImpl implements StDingProcService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public McR commentSync(Map map){
|
|
|
+ public McR commentSync(Map map,String flowId){
|
|
|
+ //查询表中是否存在同步评论记录
|
|
|
+ LambdaQueryWrapper<Shantai> shantaiLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ shantaiLambdaQueryWrapper.eq(Shantai::getFlowId,flowId)
|
|
|
+ .eq(Shantai::getValidFlag,"1");
|
|
|
+ Shantai shantai = shantaiMapper.selectOne(shantaiLambdaQueryWrapper);
|
|
|
+
|
|
|
+ if (Objects.nonNull(shantai) && shantai.getState().equals("1")){
|
|
|
+ log.info("该单据Id:{}已同步过水单,本次不进行同步",flowId);
|
|
|
+ return McR.success();
|
|
|
+ }
|
|
|
+
|
|
|
//获取提交人
|
|
|
String userId = map.get("userId").toString();
|
|
|
DDR_New ddrNew = (DDR_New) UtilHttp.doPost("https://oapi.dingtalk.com/topapi/v2/user/get", null, ddClient.initTokenParams(), UtilMap.map("userid", userId), DDR_New.class);
|
|
@@ -241,9 +259,29 @@ public class StDingProcServiceImpl implements StDingProcService {
|
|
|
String state = map.get("state").toString();
|
|
|
String procInstId = map.get("procInstId").toString();
|
|
|
|
|
|
+ if (Objects.nonNull(shantai) && dentries.isEmpty()){
|
|
|
+ log.info("该单据Id:{}本次无水单上传,不进行同步",flowId);
|
|
|
+ return McR.success();
|
|
|
+ }
|
|
|
+
|
|
|
//新增评论
|
|
|
comment(dentries,state,userId,procInstId);
|
|
|
|
|
|
+ //更新表中同步状态
|
|
|
+ if (dentries.isEmpty()){
|
|
|
+ shantai.setState("2");
|
|
|
+ }else {
|
|
|
+ shantai.setState("1");
|
|
|
+ }
|
|
|
+ if (Objects.isNull(shantai)){
|
|
|
+ shantai.setFlowId(flowId);
|
|
|
+ shantai.setProcInstId(procInstId);
|
|
|
+ shantaiMapper.insert(shantai);
|
|
|
+ }else {
|
|
|
+ //更新评论状态
|
|
|
+ shantaiMapper.updateById(shantai);
|
|
|
+ }
|
|
|
+
|
|
|
return McR.success();
|
|
|
}
|
|
|
|
|
@@ -328,6 +366,21 @@ public class StDingProcServiceImpl implements StDingProcService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void commentSyncAll() {
|
|
|
+ //获取所有评论未同步水单的单据列表
|
|
|
+ LambdaQueryWrapper<Shantai> shantaiLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ shantaiLambdaQueryWrapper.eq(Shantai::getState,"2")
|
|
|
+ .eq(Shantai::getValidFlag,"1");
|
|
|
+ List<Shantai> shantaiList = shantaiMapper.selectList(shantaiLambdaQueryWrapper);
|
|
|
+ for (Shantai shantai : shantaiList) {
|
|
|
+ String flowId = shantai.getFlowId();
|
|
|
+ log.info("开始定时同步评论水单:{}",flowId);
|
|
|
+ Map flowInfo = getFlowInfo(flowId);
|
|
|
+ commentSync(flowInfo,flowId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private void comment(List<Map> dentries, String state, String userId, String procInstId) {
|
|
|
Map body = new HashMap<>();
|
|
|
Map fileMap = new HashMap<>();
|