|
@@ -1,5 +1,6 @@
|
|
package org.springblade.manager.controller;
|
|
package org.springblade.manager.controller;
|
|
|
|
|
|
|
|
+import cn.hutool.log.StaticLog;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
@@ -30,8 +31,10 @@ import org.springblade.business.entity.ContractLog;
|
|
import org.springblade.business.entity.InformationQuery;
|
|
import org.springblade.business.entity.InformationQuery;
|
|
import org.springblade.business.feign.ContractLogClient;
|
|
import org.springblade.business.feign.ContractLogClient;
|
|
import org.springblade.business.feign.InformationQueryClient;
|
|
import org.springblade.business.feign.InformationQueryClient;
|
|
|
|
+import org.springblade.business.feign.TaskClient;
|
|
import org.springblade.business.vo.SaveContractLogVO;
|
|
import org.springblade.business.vo.SaveContractLogVO;
|
|
import org.springblade.common.constant.CommonConstant;
|
|
import org.springblade.common.constant.CommonConstant;
|
|
|
|
+import org.springblade.common.utils.BaseUtils;
|
|
import org.springblade.common.utils.CommonUtil;
|
|
import org.springblade.common.utils.CommonUtil;
|
|
import org.springblade.common.utils.MathUtil;
|
|
import org.springblade.common.utils.MathUtil;
|
|
import org.springblade.common.utils.SnowFlakeUtil;
|
|
import org.springblade.common.utils.SnowFlakeUtil;
|
|
@@ -52,7 +55,6 @@ import org.springblade.manager.enums.ExecuteType;
|
|
import org.springblade.manager.mapper.ExcelTabMapper;
|
|
import org.springblade.manager.mapper.ExcelTabMapper;
|
|
import org.springblade.manager.mapper.WbsTreePrivateMapper;
|
|
import org.springblade.manager.mapper.WbsTreePrivateMapper;
|
|
import org.springblade.manager.service.*;
|
|
import org.springblade.manager.service.*;
|
|
-import org.springblade.manager.service.impl.WbsTreeContractServiceImpl;
|
|
|
|
import org.springblade.manager.utils.ExcelInfoUtils;
|
|
import org.springblade.manager.utils.ExcelInfoUtils;
|
|
import org.springblade.manager.utils.FileUtils;
|
|
import org.springblade.manager.utils.FileUtils;
|
|
import org.springblade.manager.utils.RegularExpressionUtil;
|
|
import org.springblade.manager.utils.RegularExpressionUtil;
|
|
@@ -82,6 +84,7 @@ import java.net.URLEncoder;
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
+import java.util.concurrent.atomic.AtomicInteger;
|
|
import java.util.regex.Matcher;
|
|
import java.util.regex.Matcher;
|
|
import java.util.regex.Pattern;
|
|
import java.util.regex.Pattern;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
@@ -147,6 +150,9 @@ public class ExcelTabController extends BladeController {
|
|
|
|
|
|
private final IWbsParamService wbsParamService;
|
|
private final IWbsParamService wbsParamService;
|
|
|
|
|
|
|
|
+ private final TaskClient taskClient;
|
|
|
|
+
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
StringRedisTemplate RedisTemplate;
|
|
StringRedisTemplate RedisTemplate;
|
|
|
|
|
|
@@ -2216,34 +2222,139 @@ public class ExcelTabController extends BladeController {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- @PostMapping("/data-batch-refresh")
|
|
|
|
|
|
+ public static final String CACHE_DEL="delete from m_cache where remark is null";
|
|
|
|
+ @GetMapping("/data-batch-refresh")
|
|
@ApiOperationSupport(order = 100)
|
|
@ApiOperationSupport(order = 100)
|
|
@ApiOperation(value = "批量重新保存", notes = "批量重新保存")
|
|
@ApiOperation(value = "批量重新保存", notes = "批量重新保存")
|
|
- public R saveBussDataBatchRefresh(Long pkeyId){
|
|
|
|
- List<Map<String ,Object>> listMaps= this.jdbcTemplate.queryForList("");
|
|
|
|
- if(listMaps.size()>0){
|
|
|
|
- listMaps.forEach(node->{
|
|
|
|
- try {
|
|
|
|
- this.start(node.get("pkeyId").toString());
|
|
|
|
- }catch (Exception e){
|
|
|
|
- e.printStackTrace();
|
|
|
|
- }
|
|
|
|
|
|
+ @ApiImplicitParams(value = {
|
|
|
|
+ @ApiImplicitParam(name = "pkeyId", value = "共同祖先节点pkeyId", required = true),
|
|
|
|
+ @ApiImplicitParam(name = "reset", value = "是否重置任务,是:1 否:非1"),
|
|
|
|
+ @ApiImplicitParam(name = "mode", value = "执行模式,0未上报,1已上报,2全部", required = true)
|
|
|
|
+ })
|
|
|
|
+ public R saveBussDataBatchRefresh(Long pkeyId,Integer mode,Integer reset){
|
|
|
|
+ /*进度条(未上报30工序执行一批)(已上报15工序执行一批)*/
|
|
|
|
+ WbsTreeContract parent =this.wbsTreeContractService.getOne(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getPKeyId,pkeyId));
|
|
|
|
+ if(reset!=null&&reset==1){
|
|
|
|
+ /*重置任务*/
|
|
|
|
+ this.jdbcTemplate.execute(CACHE_DEL);
|
|
|
|
+ }
|
|
|
|
+ this.batchRedo(parent.getProjectId(),parent.getContractId(),parent.getTreeCode(),"1", mode);
|
|
|
|
+ return R.success("完成");
|
|
|
|
+ }
|
|
|
|
|
|
- });
|
|
|
|
|
|
+ public void batchInsert(List<String> sqlInit){
|
|
|
|
+ try {
|
|
|
|
+ List<List<String>> sqlListSeg = BaseUtils.splitList(sqlInit, 200);
|
|
|
|
+ sqlListSeg.parallelStream().map(l -> String.join(";", l)).forEach(this.jdbcTemplate::execute);
|
|
|
|
+ }catch (Exception e){
|
|
|
|
+ e.printStackTrace();
|
|
}
|
|
}
|
|
- return R.success("无数据");
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- public R start(String nodeId) throws Exception {
|
|
|
|
- JSONArray dataArray = new JSONArray();
|
|
|
|
-// String nodeId = tableInfo1.getString("nodeId");
|
|
|
|
- String contractId ="1630017379264610305";
|
|
|
|
- String projectId = "1630011899725201410";
|
|
|
|
- String classify = "1";
|
|
|
|
|
|
|
|
- /*全加载,或者可以优化成依赖加载*/
|
|
|
|
|
|
+ public void batchRedo(String projectId,String contractId,String treeCode,String classify ,Integer mode){
|
|
|
|
+ String XXt="002004";
|
|
|
|
+ List<String> list= this.jdbcTemplate.queryForList("select tree_code treeCode from m_wbs_tree_contract where contract_id=1630017379264610305 and is_deleted=0 and (id in(1541601335840210946,1541601355272421378,1703032661549219842,1541708754314547201,1575309161938681858) or old_id in(1541601335840210946,1541601355272421378,1703032661549219842,1541708754314547201,1575309161938681858)) and tree_code is not null ORDER BY tree_code",String.class);
|
|
|
|
+ if(list.size()<1){
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ Set<String> treeCodeSet = new HashSet<>(list);
|
|
|
|
+ List<String>treeCodeList = new ArrayList<>();
|
|
|
|
+ treeCodeSet.forEach(t->{
|
|
|
|
+ if(BaseUtils.notInChain(treeCodeList,t)){
|
|
|
|
+ treeCodeList.add(t);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ /*删除测试分支*/
|
|
|
|
+ treeCodeList.removeIf(s->s.startsWith(XXt));
|
|
|
|
+ if(Func.isNotEmpty(contractId)&&Func.isNotBlank(treeCode)) {
|
|
|
|
+ /*List<Map<String, Object>> listMaps = this.jdbcTemplate.queryForList("select a.p_key_id pkeyId,a.update_user user,b.status from m_wbs_tree_contract a join u_information_query b on a.p_key_id = b.wbs_id where a.contract_id=" + contractId + " and a.is_deleted=0 and b.is_deleted=0 and b.classify=1 and a.node_type=6 and a.tree_code like '" + treeCode + "%' and b.is_deleted=0 ORDER BY a.sort");*/
|
|
|
|
+ List<Redo> redoList = this.jdbcTemplate.query("select a.p_key_id pkeyId,a.update_user userId,b.status,tree_code treeCode from m_wbs_tree_contract a join u_information_query b on a.p_key_id = b.wbs_id where a.contract_id=" + contractId + " and a.is_deleted=0 and b.is_deleted=0 and b.classify=1 and a.node_type=6 and a.tree_code like '" + treeCode + "%' and b.is_deleted=0 ORDER BY a.tree_code", new BeanPropertyRowMapper<>(Redo.class));
|
|
|
|
+ redoList.removeIf(x->!BaseUtils.inChain(treeCodeList,x.getTreeCode()));
|
|
|
|
+ List<Map<String,Object>> excludeListMap = this.jdbcTemplate.queryForList("select id from m_cache where remark is null");
|
|
|
|
+ if(excludeListMap.size()>0){
|
|
|
|
+ List<String> excludeList= excludeListMap.stream().map(m->m.get("id").toString()).collect(Collectors.toList());
|
|
|
|
+ /*排除已经执行的*/
|
|
|
|
+ redoList.removeIf(x->excludeList.contains(x.getPkeyId()));
|
|
|
|
+ }
|
|
|
|
+ /*st03 未上报 st12 已上报*/
|
|
|
|
+ boolean st03=false,st12=false;
|
|
|
|
+ if(mode==2){
|
|
|
|
+ st03=true;
|
|
|
|
+ st12=true;
|
|
|
|
+ }else if(mode==0){
|
|
|
|
+ st03=true;
|
|
|
|
+ }else if(mode==1){
|
|
|
|
+ st12=true;
|
|
|
|
+ }
|
|
|
|
+ if (redoList.size() > 0) {
|
|
|
|
+ /*未上报*/
|
|
|
|
+ List<String> status0 = redoList.stream().filter(m -> m.getStatus().equals(0)||m.getStatus().equals(3)).map(Redo::getPkeyId).collect(Collectors.toList());
|
|
|
|
+ /*已上报*/
|
|
|
|
+ List<String> status12 = redoList.stream().filter(m -> m.getStatus().equals(1)||m.getStatus().equals(2)).map(Redo::getPkeyId).collect(Collectors.toList());
|
|
|
|
+ if(status0.size()>0&&st03){
|
|
|
|
+ List<List<String>> status0Seg= BaseUtils.splitList(status0,30);
|
|
|
|
+ List<String> sqlIntA= new ArrayList<>();
|
|
|
|
+ String start ="未上报数据共计"+status0.size()+"条,开始任务";
|
|
|
|
+ StaticLog.info(start);
|
|
|
|
+ AtomicInteger sum= new AtomicInteger();
|
|
|
|
+ sqlIntA.add("insert into m_cache (id,remark,create_time) VALUES ("+SnowFlakeUtil.getId()+",'"+start+"',NOW())");
|
|
|
|
+ status0Seg.forEach(l->{
|
|
|
|
+ try {
|
|
|
|
+ sqlIntA.addAll(l.stream().map(id->"insert into m_cache (id) VALUES ("+id+")").collect(Collectors.toList()));
|
|
|
|
+ this.synPDFInfo(contractId,String.join(",",l),"1",projectId);
|
|
|
|
+ sum.addAndGet(l.size());
|
|
|
|
+ double d=100*(double) sum.get()/(double)status0.size();
|
|
|
|
+ String str ="未上报数据共计"+status0.size()+"条,已经执行"+sum.get()+"条("+d+"%)";
|
|
|
|
+ sqlIntA.add("insert into m_cache (id,remark,create_time) VALUES ("+SnowFlakeUtil.getId()+",'"+str+"',NOW())");
|
|
|
|
+ this.batchInsert(sqlIntA);
|
|
|
|
+ sqlIntA.clear();
|
|
|
|
+ }catch (Exception e){
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
|
|
|
|
+ }
|
|
|
|
+ if(status12.size()>0&&st12){
|
|
|
|
+ try {
|
|
|
|
+ String nodeIds = status12.stream().distinct().collect(Collectors.joining(","));
|
|
|
|
+ List<Map<String,Object>> taskList= this.jdbcTemplate.queryForList("select c.id taskId,b.wbs_id nodeId from u_information_query b join u_task c on b.id=c.form_data_id where b.is_deleted=0 and b.classify=1 and b.status in(1,2)and b.wbs_id in("+nodeIds+") ORDER BY c.update_time ");
|
|
|
|
+ List<String> taskIds= taskList.stream().collect(Collectors.toMap(m->m.get("nodeId"),m->m,(m1,m2)->m2)).values().stream().map(m->m.get("taskId").toString()).collect(Collectors.toList());
|
|
|
|
+ if(taskIds.size()>0) {
|
|
|
|
+ /*处理已经上报部分 */
|
|
|
|
+ List<List<String>> taskIdsSeg= BaseUtils.splitList(taskIds,15);
|
|
|
|
+ List<String> sqlIntA= new ArrayList<>();
|
|
|
|
+ String start ="已经上报数据共计"+taskIds.size()+"条,开始任务";
|
|
|
|
+ StaticLog.info(start);
|
|
|
|
+ AtomicInteger sum= new AtomicInteger();
|
|
|
|
+ sqlIntA.add("insert into m_cache (id,remark,create_time) VALUES ("+SnowFlakeUtil.getId()+",'"+start+"',NOW())");
|
|
|
|
+ taskIdsSeg.forEach(l->{
|
|
|
|
+ try {
|
|
|
|
+ sqlIntA.addAll(l.stream().map(id->"insert into m_cache (id) VALUES ("+id+")").collect(Collectors.toList()));
|
|
|
|
+ this.taskClient.reSigningEVisa(String.join(",",l),contractId,projectId,AuthUtil.getHeader());
|
|
|
|
+ sum.addAndGet(l.size());
|
|
|
|
+ double d=100*(double) sum.get()/(double)taskIds.size();
|
|
|
|
+ String str ="未上报数据共计"+taskIdsSeg.size()+"条,已经执行"+sum.get()+"条("+d+"%)";
|
|
|
|
+ sqlIntA.add("insert into m_cache (id,remark,create_time) VALUES ("+SnowFlakeUtil.getId()+",'"+str+"',NOW())");
|
|
|
|
+ this.batchInsert(sqlIntA);
|
|
|
|
+ sqlIntA.clear();
|
|
|
|
+ }catch (Exception e){
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ this.jdbcTemplate.execute("insert into m_cache (id,remark,create_time) VALUES ("+SnowFlakeUtil.getId()+",'完成',NOW())");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ @Deprecated
|
|
|
|
+ public void redo(String nodeId,String projectId,String contractId, String classify) throws Exception {
|
|
|
|
+ JSONArray dataArray = new JSONArray();
|
|
List<AppWbsTreeContractVO> tableAll = wbsTreeContractService.searchNodeAllTable(nodeId, "1", contractId, projectId,null);
|
|
List<AppWbsTreeContractVO> tableAll = wbsTreeContractService.searchNodeAllTable(nodeId, "1", contractId, projectId,null);
|
|
List<Long> tableAllIds = tableAll.stream().map(AppWbsTreeContractVO::getPKeyId).collect(Collectors.toList());
|
|
List<Long> tableAllIds = tableAll.stream().map(AppWbsTreeContractVO::getPKeyId).collect(Collectors.toList());
|
|
for (Long pk : tableAllIds) {
|
|
for (Long pk : tableAllIds) {
|
|
@@ -2254,7 +2365,6 @@ public class ExcelTabController extends BladeController {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
List<TableInfo> tableInfoList = this.excelTabService.getTableInfoList(dataArray);
|
|
List<TableInfo> tableInfoList = this.excelTabService.getTableInfoList(dataArray);
|
|
- /*默认额外加载的默认不更新,除非有元素数据变动*/
|
|
|
|
tableInfoList.removeIf(e -> e.getPkeyId() == null);
|
|
tableInfoList.removeIf(e -> e.getPkeyId() == null);
|
|
tableInfoList.forEach(e -> {
|
|
tableInfoList.forEach(e -> {
|
|
e.setToBeUpdated(false);
|
|
e.setToBeUpdated(false);
|
|
@@ -2270,20 +2380,19 @@ public class ExcelTabController extends BladeController {
|
|
//保存数据到数据库
|
|
//保存数据到数据库
|
|
R<Object> result = this.excelTabService.saveOrUpdateInfo(tableInfoList);
|
|
R<Object> result = this.excelTabService.saveOrUpdateInfo(tableInfoList);
|
|
if (!result.isSuccess()) {
|
|
if (!result.isSuccess()) {
|
|
- return R.fail(result.getMsg());
|
|
|
|
|
|
+ R.fail(result.getMsg());
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
List<String> errorPKeyIds = new ArrayList<>();
|
|
List<String> errorPKeyIds = new ArrayList<>();
|
|
//单个pdf加载
|
|
//单个pdf加载
|
|
- if (tableInfoList != null) {
|
|
|
|
- for (TableInfo tableInfo : tableInfoList) {
|
|
|
|
- R bussPdfInfo = excelTabService.getBussPdfInfo(Long.parseLong(tableInfo.getPkeyId()));
|
|
|
|
|
|
+ for (TableInfo tableInfo : tableInfoList) {
|
|
|
|
+ R bussPdfInfo = excelTabService.getBussPdfInfo(Long.parseLong(tableInfo.getPkeyId()));
|
|
|
|
|
|
- if (ObjectUtil.isEmpty(bussPdfInfo) || bussPdfInfo.getCode() != 200) {
|
|
|
|
- //如果返回的单张pdfUrl为空,那么表示发生异常,返回异常信息
|
|
|
|
- errorPKeyIds.add(tableInfo.getPkeyId());
|
|
|
|
- }
|
|
|
|
|
|
+ if (ObjectUtil.isEmpty(bussPdfInfo) || bussPdfInfo.getCode() != 200) {
|
|
|
|
+ //如果返回的单张pdfUrl为空,那么表示发生异常,返回异常信息
|
|
|
|
+ errorPKeyIds.add(tableInfo.getPkeyId());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -2297,7 +2406,8 @@ public class ExcelTabController extends BladeController {
|
|
}
|
|
}
|
|
if (errorTabs.size() > 0) {
|
|
if (errorTabs.size() > 0) {
|
|
List<String> names = errorTabs.stream().map(WbsTreeContract::getNodeName).collect(Collectors.toList());
|
|
List<String> names = errorTabs.stream().map(WbsTreeContract::getNodeName).collect(Collectors.toList());
|
|
- return R.fail("以下的表在生成pdf文件时发生了异常【" + StringUtils.join(names, "、") + "】");
|
|
|
|
|
|
+ R.fail("以下的表在生成pdf文件时发生了异常【" + StringUtils.join(names, "、") + "】");
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -2306,7 +2416,6 @@ public class ExcelTabController extends BladeController {
|
|
|
|
|
|
//更新缓存
|
|
//更新缓存
|
|
informationQueryClient.delAsyncWbsTree(contractId);
|
|
informationQueryClient.delAsyncWbsTree(contractId);
|
|
- return R.success("OK");
|
|
|
|
}
|
|
}
|
|
/***
|
|
/***
|
|
* 覆盖上传- (修改为上传导入模板)
|
|
* 覆盖上传- (修改为上传导入模板)
|
|
@@ -4008,6 +4117,7 @@ public class ExcelTabController extends BladeController {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
@PostMapping("/save_nodeId")
|
|
@PostMapping("/save_nodeId")
|
|
@ApiOperationSupport(order = 72)
|
|
@ApiOperationSupport(order = 72)
|
|
@ApiOperation(value = "pdf", notes = "pdf")
|
|
@ApiOperation(value = "pdf", notes = "pdf")
|