|
@@ -1209,6 +1209,9 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
@ApiOperation(value = "批量上报")
|
|
|
@PushMessage(clientId = ClientIdConstant.BUSINESS_CLIENT_ID)
|
|
|
public R<Object> batchTask(@RequestBody StartTaskVO startTaskVO) {
|
|
|
+ if (ObjectUtil.isEmpty(SecureUtil.getUserId()) || SecureUtil.getUserId() == -1L) {
|
|
|
+ throw new ServiceException("未获取到当前用户信息");
|
|
|
+ }
|
|
|
if (StringUtils.isNotEmpty(startTaskVO.getIds())) {
|
|
|
//获取数据源id
|
|
|
String[] ids = startTaskVO.getIds().split(",");
|
|
@@ -1264,7 +1267,10 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
taskVO.setFormDataId(id);
|
|
|
//设置上报类型
|
|
|
taskVO.setApprovalType(1);
|
|
|
- //上报
|
|
|
+
|
|
|
+ taskVO.setReportUserId(SecureUtil.getUserId().toString());
|
|
|
+ taskVO.setReportUserName(SecureUtil.getNickName());
|
|
|
+
|
|
|
if (this.taskClient.startTask(taskVO).getData()) {
|
|
|
LambdaUpdateWrapper<InformationQuery> wrappers = Wrappers.lambdaUpdate();
|
|
|
wrappers.set(InformationQuery::getReportNumber, taskVO.getBatch()).set(InformationQuery::getStatus, 1);
|
|
@@ -1380,7 +1386,7 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
tabOwner = "1,2,3,4,5,6"; //如果选择的是否复制数据=0(否),默认所属方123456
|
|
|
}
|
|
|
/*用来标识新旧工序结对*/
|
|
|
- Map<Long,Long> peerMap = new HashMap<>();
|
|
|
+ Map<Long, Long> peerMap = new HashMap<>();
|
|
|
//TODO 单份复制
|
|
|
if (("1").equals(vo.getCopyType())) {
|
|
|
//首先查询需要复制的节点及其下级所有子节点的信息
|
|
@@ -1428,8 +1434,8 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
//重塑关键信息
|
|
|
//重塑primaryKeyId
|
|
|
newData.setPKeyId(SnowFlakeUtil.getId());
|
|
|
- if(nodeOld.getNodeType()!=null&&nodeOld.getNodeType()==6){
|
|
|
- peerMap.put(newData.getPKeyId(),nodeOld.getPKeyId());
|
|
|
+ if (nodeOld.getNodeType() != null && nodeOld.getNodeType() == 6) {
|
|
|
+ peerMap.put(newData.getPKeyId(), nodeOld.getPKeyId());
|
|
|
}
|
|
|
//设置旧ID
|
|
|
if (StringUtils.isNotEmpty(nodeOld.getOldId())) {
|
|
@@ -1596,7 +1602,7 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
this.addCopyTabFile(new HashSet<>(newTabs), oldTabs);
|
|
|
}
|
|
|
/*复制formulaOption*/
|
|
|
- this.copyFormulaOptions(saveList,peerMap);
|
|
|
+ this.copyFormulaOptions(saveList, peerMap);
|
|
|
//更新redis缓存
|
|
|
informationQueryService.delAsyncWbsTree(needCopyNode.getContractId());
|
|
|
|
|
@@ -1670,7 +1676,7 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
List<WbsTreeContract> needCopyTab = needCopyNodeAndTabMap.get("tab:" + needCopyNodeRoot.getPKeyId());
|
|
|
|
|
|
//构造新的节点、表、数据
|
|
|
- this.addCopyNodesAndTabsBuildData(addNodeList, addTabList, needCopyNodes, needCopyTab, needCopyNode, toCopyNode, resultTablesData, 1, tabOwner, vo.getIsCopyData(),peerMap);
|
|
|
+ this.addCopyNodesAndTabsBuildData(addNodeList, addTabList, needCopyNodes, needCopyTab, needCopyNode, toCopyNode, resultTablesData, 1, tabOwner, vo.getIsCopyData(), peerMap);
|
|
|
|
|
|
//附件
|
|
|
addNewFileTabs.addAll(addTabList);
|
|
@@ -1699,7 +1705,7 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
List<WbsTreeContract> needCopyTab = needCopyNodeAndTabMap.get("tab:" + needCopyNodeRoot.getPKeyId());
|
|
|
|
|
|
//构造新的节点、表、数据
|
|
|
- this.addCopyNodesAndTabsBuildData(addNodeList, addTabList, needCopyNodes, needCopyTab, needCopyNode, toCopyNode, resultTablesData, 0, tabOwner, vo.getIsCopyData(),peerMap);
|
|
|
+ this.addCopyNodesAndTabsBuildData(addNodeList, addTabList, needCopyNodes, needCopyTab, needCopyNode, toCopyNode, resultTablesData, 0, tabOwner, vo.getIsCopyData(), peerMap);
|
|
|
|
|
|
//附件
|
|
|
addNewFileTabs.addAll(addTabList);
|
|
@@ -1716,7 +1722,7 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
List<WbsTreeContract> needCopyTab = needCopyNodeAndTabMap.get("tab:" + needCopyNodeRoot.getPKeyId());
|
|
|
|
|
|
//构造新的节点、表、数据
|
|
|
- this.addCopyNodesAndTabsBuildData(addNodeList, addTabList, needCopyNodes, needCopyTab, needCopyNode, toCopyNode, resultTablesData, 0, tabOwner, vo.getIsCopyData(),peerMap);
|
|
|
+ this.addCopyNodesAndTabsBuildData(addNodeList, addTabList, needCopyNodes, needCopyTab, needCopyNode, toCopyNode, resultTablesData, 0, tabOwner, vo.getIsCopyData(), peerMap);
|
|
|
|
|
|
//附件
|
|
|
addNewFileTabs.addAll(addTabList);
|
|
@@ -1779,9 +1785,9 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
throw new ServiceException("保存数据异常,请联系管理员");
|
|
|
}
|
|
|
}
|
|
|
- if(nodes.size()>0){
|
|
|
+ if (nodes.size() > 0) {
|
|
|
/*复制formulaOpion*/
|
|
|
- this.copyFormulaOptions(nodes,peerMap);
|
|
|
+ this.copyFormulaOptions(nodes, peerMap);
|
|
|
}
|
|
|
if (row) {
|
|
|
//更新redis缓存
|
|
@@ -1818,24 +1824,24 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
}
|
|
|
|
|
|
@Async
|
|
|
- public void copyFormulaOptions( List<WbsTreeContract> saveList,Map<Long,Long> peerMap){
|
|
|
- if(peerMap.size()>0){
|
|
|
+ public void copyFormulaOptions(List<WbsTreeContract> saveList, Map<Long, Long> peerMap) {
|
|
|
+ if (peerMap.size() > 0) {
|
|
|
try {
|
|
|
- String sqlTemplate="INSERT INTO m_formula_option (id,parent_id,contract_id,val) select #1,#2,contract_id,val from m_formula_option where id=#3";
|
|
|
- Map<Long,Long> idMap = saveList.stream().filter(e->e.getNodeType()!=null&&e.getNodeType()==6).collect(Collectors.toMap(WbsTreeContract::getPKeyId,WbsTreeContract::getId));
|
|
|
- List<String> sqlList= new ArrayList<>();
|
|
|
- for(Map.Entry<Long,Long> p:peerMap.entrySet()){
|
|
|
- try {
|
|
|
- String newPkeyId=p.getKey().toString();
|
|
|
- String oldPkeyId=p.getValue().toString();
|
|
|
- String newId=idMap.get(p.getKey()).toString();
|
|
|
- sqlList.add(sqlTemplate.replace("#1", newPkeyId).replace("#2", newId).replace("#3", oldPkeyId));
|
|
|
- }catch (Exception e){
|
|
|
- e.printStackTrace();
|
|
|
+ String sqlTemplate = "INSERT INTO m_formula_option (id,parent_id,contract_id,val) select #1,#2,contract_id,val from m_formula_option where id=#3";
|
|
|
+ Map<Long, Long> idMap = saveList.stream().filter(e -> e.getNodeType() != null && e.getNodeType() == 6).collect(Collectors.toMap(WbsTreeContract::getPKeyId, WbsTreeContract::getId));
|
|
|
+ List<String> sqlList = new ArrayList<>();
|
|
|
+ for (Map.Entry<Long, Long> p : peerMap.entrySet()) {
|
|
|
+ try {
|
|
|
+ String newPkeyId = p.getKey().toString();
|
|
|
+ String oldPkeyId = p.getValue().toString();
|
|
|
+ String newId = idMap.get(p.getKey()).toString();
|
|
|
+ sqlList.add(sqlTemplate.replace("#1", newPkeyId).replace("#2", newId).replace("#3", oldPkeyId));
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- BaseUtils.splitList(sqlList,50).parallelStream().map(l->String.join(";",l)).forEach(this.jdbcTemplate::execute);
|
|
|
- }catch (Exception e){
|
|
|
+ BaseUtils.splitList(sqlList, 50).parallelStream().map(l -> String.join(";", l)).forEach(this.jdbcTemplate::execute);
|
|
|
+ } catch (Exception e) {
|
|
|
StaticLog.error("formulaOption复制失败");
|
|
|
}
|
|
|
}
|
|
@@ -2175,7 +2181,7 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
private void addCopyNodesAndTabsBuildData
|
|
|
(List<WbsTreeContract> addNodeList, List<WbsTreeContract> addTabList, List<WbsTreeContract> needNodes, List<WbsTreeContract> needTabs, WbsTreeContract
|
|
|
needCopyNode, WbsTreeContract toCopyNode, List<String> resultTablesData, Integer isSameNode, String
|
|
|
- tabOwner, Integer isCopyData,Map<Long,Long> peerMap ) {
|
|
|
+ tabOwner, Integer isCopyData, Map<Long, Long> peerMap) {
|
|
|
int var = 0;
|
|
|
if (needNodes.size() == 1) {
|
|
|
//判断是否为最下级节点
|
|
@@ -2207,8 +2213,8 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
//获取当前复制的节点的sort
|
|
|
obj.setSort(ObjectUtils.isNotEmpty(needNode.getSort()) ? needNode.getSort() : 0);
|
|
|
addNodeList.add(obj);
|
|
|
- if(obj.getNodeType()!=null&&obj.getNodeType()==6){
|
|
|
- peerMap.put(obj.getPKeyId(),needNode.getPKeyId());
|
|
|
+ if (obj.getNodeType() != null && obj.getNodeType() == 6) {
|
|
|
+ peerMap.put(obj.getPKeyId(), needNode.getPKeyId());
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
@@ -2314,8 +2320,8 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
obj.setSort(ObjectUtils.isNotEmpty(node.getSort()) ? node.getSort() : 0);
|
|
|
|
|
|
addNodeList.add(obj);
|
|
|
- if(obj.getNodeType()!=null&&obj.getNodeType()==6){
|
|
|
- peerMap.put(obj.getPKeyId(),node.getPKeyId());
|
|
|
+ if (obj.getNodeType() != null && obj.getNodeType() == 6) {
|
|
|
+ peerMap.put(obj.getPKeyId(), node.getPKeyId());
|
|
|
}
|
|
|
//构造当前节点下所有元素表
|
|
|
List<WbsTreeContract> tabs = tabMap.get(oldId);
|