|
|
@@ -3,6 +3,7 @@ package com.lc.ibps.business.service.impl;
|
|
|
import cn.hutool.json.JSONArray;
|
|
|
import cn.hutool.json.JSONObject;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
+import com.lc.ibps.api.base.constants.StateEnum;
|
|
|
import com.lc.ibps.api.form.sql.util.BeanUtils;
|
|
|
import com.lc.ibps.base.core.constants.StringPool;
|
|
|
import com.lc.ibps.base.core.util.AppUtil;
|
|
|
@@ -12,6 +13,8 @@ import com.lc.ibps.base.framework.table.ICommonDao;
|
|
|
import com.lc.ibps.base.saas.token.ITenantTokenService;
|
|
|
import com.lc.ibps.base.web.context.ContextUtil;
|
|
|
import com.lc.ibps.bpmn.api.IBpmInstService;
|
|
|
+import com.lc.ibps.business.dao.Approval;
|
|
|
+import com.lc.ibps.business.dto.ApprovalDTO;
|
|
|
import com.lc.ibps.business.service.AuditService;
|
|
|
import com.lc.ibps.cloud.entity.APIResult;
|
|
|
import com.lc.ibps.cloud.message.util.MessageQueueProductorUtil;
|
|
|
@@ -22,6 +25,9 @@ import com.lc.ibps.untils.SqlUtil;
|
|
|
import lombok.extern.log4j.Log4j2;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Propagation;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
@@ -51,6 +57,12 @@ public class AuditServiceImpl implements AuditService {
|
|
|
@Resource
|
|
|
private INewsMgrService newsMgrService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private Approval approval;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private IBpmInstService iBpmInstService;
|
|
|
+
|
|
|
@Override
|
|
|
public void personnelTrain(String[] records) throws Exception {
|
|
|
log.warn(" com.lc.ibps.business.service.impl.AuditServiceImpl.personnelTrain()--->人员培训通知:records: {}", Arrays.toString(records));
|
|
|
@@ -514,7 +526,7 @@ public class AuditServiceImpl implements AuditService {
|
|
|
return namesBuilder.toString();
|
|
|
}
|
|
|
|
|
|
- public String buildInsertSql(Map<String, Object> map , String tableName) throws Exception {
|
|
|
+ public String buildInsertSql(Map<String, Object> map , String tableName) {
|
|
|
StringBuilder sql = new StringBuilder("insert into "+tableName+" (");
|
|
|
for (Object key : map.keySet()) {
|
|
|
sql.append(key).append(",");
|
|
|
@@ -530,69 +542,121 @@ public class AuditServiceImpl implements AuditService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public APIResult<Map<String, Object>> Approval(String id) throws Exception {
|
|
|
+ public APIResult<Map<String, Object>> Approval(String id) {
|
|
|
+ APIResult<Map<String, Object>> result = insertData(id);
|
|
|
+ if (result.getState() == 200) {
|
|
|
+ startBpm((List<String>)result.getData().get("idArr"), (List<String>) result.getData().get("oldIds"));
|
|
|
+ result.setState(StateEnum.SUCCESS.getCode());
|
|
|
+ result.setMessage("请求成功");
|
|
|
+ }else{
|
|
|
+ result.setState(StateEnum.ERROR.getCode());
|
|
|
+ log.warn("当前id查询不到对应的数据,id是" + id);
|
|
|
+ result.setMessage("数据为空,请确认后再操作");
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public APIResult<Map<String, Object>>insertData(String id){
|
|
|
APIResult<Map<String,Object>> result = new APIResult<>();
|
|
|
- String sql = "select t_rksbjhbzb.*,t_rksbjhb.id_ as zhuId,t_rksbjhb.di_dian_ as zhuDiDian ,t_rksbjhb.ping_shen_lei_xin as pslx ,t_rksbjhb.shen_bao_shi_jian as sbsj "+
|
|
|
+ String sql = "select t_rksbjhbzb.*,t_rksbjhb.id_ as zhuId,t_rksbjhb.di_dian_ as zhuDiDian ,t_rksbjhb.ping_shen_lei_xin as pslx ,t_rksbjhb.shen_bao_shi_jian as sbsj, "+
|
|
|
" t_rksbjhb.ping_shen_shi_jia as xcpssj,t_rksbjhb.nian_du_ as nd "+
|
|
|
" from t_rksbjhbzb join t_rksbjhb on t_rksbjhbzb.parent_id_ = t_rksbjhb.id_ where t_rksbjhb.id_ = '" + id +"'";
|
|
|
List<Map<String,Object>> query = (List<Map<String,Object>>) commonDao.query(sql);
|
|
|
- if(Collections.isNotEmpty(query)){
|
|
|
- //封装流程的数据
|
|
|
- IBpmInstService bpmInstService = AppUtil.getBean(IBpmInstService.class);
|
|
|
- if (StringUtils.isBlank(ContextUtil.getCurrentAccessToken())) {
|
|
|
- ITenantTokenService tenantTokenService = AppUtil.getBean(ITenantTokenService.class);
|
|
|
- String accessToken = tenantTokenService.getAccessToken();
|
|
|
- ContextUtil.setCurrentAccessToken(accessToken);
|
|
|
- }
|
|
|
+ if(Collections.isNotEmpty(query)) {
|
|
|
//封装bo
|
|
|
List<String> idArr = new ArrayList<>();
|
|
|
List<String> oldIds = new ArrayList<>();
|
|
|
- for (Map<String,Object> item :query) {
|
|
|
+ for (Map<String, Object> item : query) {
|
|
|
oldIds.add(item.get("id_").toString());
|
|
|
String use = item.get("fu_ze_ren_").toString();
|
|
|
String[] userIds = use.split(",");
|
|
|
- for (String uid: userIds) {
|
|
|
- Map<String, Object> itemMap = new HashMap<>();
|
|
|
+ for (String uid : userIds) {
|
|
|
+ ApprovalDTO dto = new ApprovalDTO();
|
|
|
String boId = UniqueIdUtil.getId();
|
|
|
- itemMap.put("id_",boId);
|
|
|
+ dto.setId(boId);
|
|
|
idArr.add(boId);
|
|
|
- itemMap.put("create_time_", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
|
|
- itemMap.put("create_by_",'1');
|
|
|
- itemMap.put("update_time_",new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
|
|
- itemMap.put("di_dian_",item.get("zhuDiDian").toString());
|
|
|
- itemMap.put("bian_zhi_ren_",uid);
|
|
|
- itemMap.put("ping_shen_lei_xin",BeanUtils.isNotEmpty(item.get("pslx")) ? item.get("pslx").toString():"");
|
|
|
- itemMap.put("shen_bao_shi_jian",BeanUtils.isNotEmpty(item.get("sbsj")) ? item.get("sbsj").toString():"");
|
|
|
- itemMap.put("ping_shen_shi_jia",BeanUtils.isNotEmpty(item.get("xcpssj")) ? item.get("xcpssj").toString():"");
|
|
|
- itemMap.put("nian_du_",BeanUtils.isNotEmpty(item.get("nd")) ? item.get("nd").toString():"");
|
|
|
- itemMap.put("pai_xu_hao_",item.get("pai_xu_hao_").toString());
|
|
|
- itemMap.put("wen_jian_ming_che",item.get("wen_jian_ming_che").toString());
|
|
|
- itemMap.put("wen_jian_shuo_min",item.get("wen_jian_shuo_min").toString());
|
|
|
- itemMap.put("tian_xie_shuo_min",BeanUtils.isNotEmpty(item.get("tian_xie_shuo_min"))?item.get("tian_xie_shuo_min").toString():"");
|
|
|
- itemMap.put("zhu_yi_shi_xiang_",BeanUtils.isNotEmpty(item.get("zhu_yi_shi_xiang_"))?item.get("zhu_yi_shi_xiang_").toString():"");
|
|
|
- itemMap.put("fu_ze_ren_",uid);
|
|
|
- itemMap.put("wan_cheng_qi_xian",item.get("wan_cheng_qi_xian").toString());
|
|
|
- itemMap.put("ji_hua_zhu_biao_i",item.get("zhuId").toString());
|
|
|
- itemMap.put("ji_hua_zi_biao_id",item.get("id_").toString());
|
|
|
- commonDao.execute(this.buildInsertSql(itemMap, "t_rksbclb"));
|
|
|
+ dto.setCreateTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
|
|
+ //itemMap.put("create_time_", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
|
|
+ dto.setUpdateBy("1");
|
|
|
+ dto.setCreateBy(uid);;
|
|
|
+ //itemMap.put("create_by_", '1');
|
|
|
+ //itemMap.put("update_time_", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
|
|
+ dto.setDiDian(item.get("zhuDiDian").toString());
|
|
|
+ // itemMap.put("di_dian_", item.get("zhuDiDian").toString());
|
|
|
+ //itemMap.put("bian_zhi_ren_", uid);
|
|
|
+ dto.setBianZhiRen(uid);
|
|
|
+ //itemMap.put("ping_shen_lei_xin", BeanUtils.isNotEmpty(item.get("pslx")) ? item.get("pslx").toString() : "");
|
|
|
+ dto.setPingShenLeiXing(BeanUtils.isNotEmpty(item.get("pslx")) ? item.get("pslx").toString() : "");
|
|
|
+ //itemMap.put("shen_bao_shi_jian", BeanUtils.isNotEmpty(item.get("sbsj")) ? item.get("sbsj").toString() : "");
|
|
|
+ dto.setShenBaoShiJian(BeanUtils.isNotEmpty(item.get("sbsj")) ? item.get("sbsj").toString() : "");
|
|
|
+ //itemMap.put("ping_shen_shi_jia", BeanUtils.isNotEmpty(item.get("xcpssj")) ? item.get("xcpssj").toString() : "");
|
|
|
+ dto.setPingShenShiJian(BeanUtils.isNotEmpty(item.get("xcpssj")) ? item.get("xcpssj").toString() : "");
|
|
|
+ //itemMap.put("nian_du_", BeanUtils.isNotEmpty(item.get("nd")) ? item.get("nd").toString() : "");
|
|
|
+ dto.setNianDu(BeanUtils.isNotEmpty(item.get("nd")) ? item.get("nd").toString() : "");
|
|
|
+ //itemMap.put("pai_xu_hao_", item.get("pai_xu_hao_").toString());
|
|
|
+ dto.setPaiXuHao(item.get("pai_xu_hao_").toString());
|
|
|
+ //itemMap.put("wen_jian_ming_che", item.get("wen_jian_ming_che").toString());
|
|
|
+ dto.setWenJianMingCheng(item.get("wen_jian_ming_che").toString());
|
|
|
+ //itemMap.put("wen_jian_shuo_min", item.get("wen_jian_shuo_min").toString());
|
|
|
+ dto.setWenJianShuoMing(item.get("wen_jian_shuo_min").toString());
|
|
|
+ //itemMap.put("tian_xie_shuo_min", BeanUtils.isNotEmpty(item.get("tian_xie_shuo_min")) ? item.get("tian_xie_shuo_min").toString() : "");
|
|
|
+ dto.setTianXieShuoMing(BeanUtils.isNotEmpty(item.get("tian_xie_shuo_min")) ? item.get("tian_xie_shuo_min").toString() : "");
|
|
|
+ //itemMap.put("zhu_yi_shi_xiang_", BeanUtils.isNotEmpty(item.get("zhu_yi_shi_xiang_")) ? item.get("zhu_yi_shi_xiang_").toString() : "");
|
|
|
+ dto.setZhuYiShiXiang( BeanUtils.isNotEmpty(item.get("zhu_yi_shi_xiang_")) ? item.get("zhu_yi_shi_xiang_").toString() : "");
|
|
|
+ //itemMap.put("fu_ze_ren_", uid);
|
|
|
+ dto.setFuZeRen(uid);
|
|
|
+ //itemMap.put("wan_cheng_qi_xian", item.get("wan_cheng_qi_xian").toString());
|
|
|
+ dto.setWanChengQiXian(item.get("wan_cheng_qi_xian").toString());
|
|
|
+ //itemMap.put("ji_hua_zhu_biao_i", item.get("zhuId").toString());
|
|
|
+ dto.setJiHuaZhuBiaoId(item.get("zhuId").toString());
|
|
|
+ //itemMap.put("ji_hua_zi_biao_id", item.get("id_").toString());
|
|
|
+ dto.setJiHuaZiBiaoId(item.get("id_").toString());
|
|
|
+ //itemMap.put("shi_fou_guo_shen_","待编制");
|
|
|
+ dto.setShiFouGuoShen("待编制");
|
|
|
+ approval.add(dto);
|
|
|
+ // commonDao.execute(buildInsertSql(itemMap, "t_rksbclb"));
|
|
|
}
|
|
|
}
|
|
|
- String[] strings = idArr.toArray(new String[0]);
|
|
|
- APIResult<String> apiResult = bpmInstService.startFlowFromList(strings, "rksbclb", "Process_0d1f058");
|
|
|
- int state = apiResult.getState();
|
|
|
- if("200".equals(String.valueOf(state))){
|
|
|
- //已经推送过流程的数据防止重复推送,yi_tui_song_=1 表示数据是yi_tui_song_推送的数据
|
|
|
- String join = String.join(",", oldIds);
|
|
|
- String upSql = "UPDATE t_rksbjhbzb SET yi_tui_song_ = '1' where find_in_set(id_,'"+ join + "') ";
|
|
|
- commonDao.execute(upSql);
|
|
|
+ String selectSql = " select * from t_rksbclb where find_in_set(id_,'" + String.join(",",idArr) + "')";
|
|
|
+ List<Map<String ,Object>> list =(List<Map<String ,Object>>) commonDao.query(selectSql);
|
|
|
+ if(list.size()>0){
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("idArr",idArr);
|
|
|
+ map.put("oldIds",oldIds);
|
|
|
+ result.setData(map);
|
|
|
+ result.setState(StateEnum.SUCCESS.getCode());
|
|
|
+ result.setMessage("请求成功");
|
|
|
+ }else{
|
|
|
+ result.setState(StateEnum.ERROR.getCode());
|
|
|
+ log.warn("新增数据失败" + idArr);
|
|
|
+ result.setMessage("数据添加失败");
|
|
|
}
|
|
|
- result.setState(200);
|
|
|
- result.setMessage("请求成功");
|
|
|
}else{
|
|
|
- result.setState(404);
|
|
|
+ result.setState(StateEnum.ERROR.getCode());
|
|
|
log.warn("当前id查询不到对应的数据,id是" + id);
|
|
|
result.setMessage("数据为空,请确认后再操作");
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
+
|
|
|
+ @Transactional
|
|
|
+ public void startBpm(List<String> idArr, List<String> oldIds) {
|
|
|
+// IBpmInstService bpmInstService = AppUtil.getBean(IBpmInstService.class);
|
|
|
+// if (StringUtils.isBlank(ContextUtil.getCurrentAccessToken())) {
|
|
|
+// ITenantTokenService tenantTokenService = AppUtil.getBean(ITenantTokenService.class);
|
|
|
+// String accessToken = tenantTokenService.getAccessToken();
|
|
|
+// ContextUtil.setCurrentAccessToken(accessToken);
|
|
|
+// }
|
|
|
+ String[] strings = idArr.toArray(new String[0]);
|
|
|
+ APIResult<String> apiResult = iBpmInstService.startFlowFromList(strings, "rksbclb", "Process_0d1f058");
|
|
|
+ int state = apiResult.getState();
|
|
|
+ if("200".equals(String.valueOf(state))){
|
|
|
+ //已经推送过流程的数据防止重复推送,yi_tui_song_=1 表示数据是yi_tui_song_推送的数据
|
|
|
+ String join = String.join(",", oldIds);
|
|
|
+ String upSql = "UPDATE t_rksbjhbzb SET yi_tui_song_ = '1' where find_in_set(id_,'"+ join + "') ";
|
|
|
+ commonDao.execute(upSql);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
}
|