|
@@ -6272,9 +6272,9 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
//先查出当前节点下所有的表单
|
|
|
String selectAllNodeTable;
|
|
|
if(dto.getClassify().equals("1")){
|
|
|
- selectAllNodeTable="select * from m_wbs_tree_contract where p_id="+dto.getNodeId()+" and table_owner in (1,2,3) and is_deleted=0";
|
|
|
+ selectAllNodeTable="select m1.* from m_wbs_tree_contract m1 join m_wbs_tree_contract m2 on m1.excel_id=m2.excel_id where m1.p_id="+dto.getNodeId()+" and m1.table_owner in (1,2,3) and m1.is_deleted=0 and m2.p_key_id="+dto.getPkeyId();
|
|
|
}else {
|
|
|
- selectAllNodeTable="select * from m_wbs_tree_contract where p_id="+dto.getNodeId()+" and table_owner in (4,5,6) and is_deleted=0";
|
|
|
+ selectAllNodeTable="select m1.* from m_wbs_tree_contract m1 join m_wbs_tree_contract m2 on m1.excel_id=m2.excel_id where m1.p_id="+dto.getNodeId()+" and m1.table_owner in (4,5,6) and m1.is_deleted=0 and m2.p_key_id="+dto.getPkeyId();
|
|
|
}
|
|
|
List<WbsTreeContract> tables = jdbcTemplate.query(selectAllNodeTable, new BeanPropertyRowMapper<>(WbsTreeContract.class));
|
|
|
//查询出当前表单
|
|
@@ -6290,13 +6290,15 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
List<WbsTreeContract>resultList=new ArrayList<>();
|
|
|
for (WbsTreeContract table : tables) {
|
|
|
if(Objects.equals(table.getExcelId(), excelId)){
|
|
|
- if(sufix!=0&&table.getNodeName().contains("_")){
|
|
|
- int suffix = Integer.parseInt(table.getNodeName().substring(nodeName.lastIndexOf("_") +1));
|
|
|
- if(suffix>=sufix){
|
|
|
+ if(Objects.equals(table.getNodeName(), wbsContract.getNodeName()) ||table.getNodeName().contains("PL")){
|
|
|
+ if(sufix!=0&&table.getNodeName().contains("_")){
|
|
|
+ int suffix = Integer.parseInt(table.getNodeName().substring(nodeName.lastIndexOf("_") +1));
|
|
|
+ if(suffix>=sufix){
|
|
|
+ resultList.add(table);
|
|
|
+ }
|
|
|
+ }else if(sufix==0){
|
|
|
resultList.add(table);
|
|
|
}
|
|
|
- }else if(sufix==0){
|
|
|
- resultList.add(table);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -6308,6 +6310,8 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
Map<WbsTreeContract, Map<String,String>> reData = new HashMap<>();
|
|
|
String key = dto.getKey();
|
|
|
String[] strings = key.split("__");
|
|
|
+ List<String> keys=new ArrayList<>();
|
|
|
+ int x=0;
|
|
|
int i=0;
|
|
|
boolean flag=false;
|
|
|
for (WbsTreeContract contract : resultList) {
|
|
@@ -6320,12 +6324,41 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
String htmlString = IoUtil.readToString(fileInputStream);
|
|
|
Document doc = Jsoup.parse(htmlString);
|
|
|
Elements keyNames = doc.getElementsByAttribute("keyname");
|
|
|
+ List<String> strings1=new ArrayList<>();
|
|
|
+ if(Objects.equals(contract.getPKeyId(), dto.getPkeyId())){
|
|
|
+ String sql="select "+strings[0]+ " from "+contract.getInitTableName()+" where p_key_id="+contract.getPKeyId();
|
|
|
+ strings1= jdbcTemplate.queryForList(sql, String.class);
|
|
|
+ }
|
|
|
for (Element keyName : keyNames) {
|
|
|
String result = keyName.attr("keyname");
|
|
|
if(result.contains(strings[0])){
|
|
|
+ if(x==0){
|
|
|
+ keys.add(result);
|
|
|
+ }
|
|
|
if (i < numbers.size()) {
|
|
|
- map.put(result, numbers.get(i));
|
|
|
- i++;
|
|
|
+ if(Objects.equals(contract.getPKeyId(), dto.getPkeyId())){
|
|
|
+ int i1 = removeUnderscoreAndCombine(strings[1]);
|
|
|
+ int i2 = removeUnderscoreAndCombine(result.split("__")[1]);
|
|
|
+ if(i2>=i1){
|
|
|
+ map.put(result, numbers.get(i));
|
|
|
+ i++;
|
|
|
+ }else {
|
|
|
+ if(strings1.size()>0){
|
|
|
+ String string = strings1.get(0);
|
|
|
+ if(StringUtils.isNotEmpty(string)){
|
|
|
+ String[] split = string.split("☆");
|
|
|
+ for (String s : split) {
|
|
|
+ if(Objects.equals(s.split("_\\^_")[1], result.split("__")[1])){
|
|
|
+ map.put(result, s.split("_\\^_")[0]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ map.put(result, numbers.get(i));
|
|
|
+ i++;
|
|
|
+ }
|
|
|
} else {
|
|
|
flag=true;
|
|
|
break;
|
|
@@ -6335,12 +6368,54 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
if(!map.isEmpty()){
|
|
|
reData.put(contract,map);
|
|
|
}
|
|
|
+ x++;
|
|
|
+ }
|
|
|
+ //剩余数据处理 添加复制表
|
|
|
+ if(i<numbers.size()){
|
|
|
+ List<String> numbers2 = numbers.subList(i, numbers.size());
|
|
|
+ int m=0;
|
|
|
+ int y=1;
|
|
|
+ do{
|
|
|
+ WbsTreeContract wbsTreeContract1 = new WbsTreeContract();
|
|
|
+ BeanUtil.copy(wbsContract,wbsTreeContract1);
|
|
|
+ wbsTreeContract1.setPKeyId(SnowFlakeUtil.getId());
|
|
|
+ WbsTreeContract lastContract = resultList.get(resultList.size() - 1);
|
|
|
+ String nodeName1 = lastContract.getNodeName();
|
|
|
+ if(nodeName1.contains("PL")){
|
|
|
+ int i1 = Integer.parseInt(nodeName1.substring(nodeName1.lastIndexOf("_") + 1));
|
|
|
+ wbsTreeContract1.setNodeName(nodeName1.substring(0,nodeName1.lastIndexOf("_"))+"_"+(y+i1));
|
|
|
+ y++;
|
|
|
+ }else {
|
|
|
+ wbsTreeContract1.setNodeName(nodeName1+"_PL_"+y);
|
|
|
+ y++;
|
|
|
+ }
|
|
|
+ wbsTreeContract1.setIsCopeTab(3);
|
|
|
+ wbsTreeContract1.setIsTabPdf(1);
|
|
|
+ wbsTreeContract1.setPdfUrl(null);
|
|
|
+ wbsTreeContractService.save(wbsTreeContract1);
|
|
|
+ HashMap<String,String> map=new HashMap<>();
|
|
|
+ for (String key1 : keys) {
|
|
|
+ if(m<numbers2.size()){
|
|
|
+ map.put(key1, numbers2.get(m));
|
|
|
+ m++;
|
|
|
+ }else {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!map.isEmpty()){
|
|
|
+ reData.put(wbsTreeContract1,map);
|
|
|
+ }
|
|
|
+ }while (m<numbers2.size());
|
|
|
}
|
|
|
//保存数据入库并且生成pdf
|
|
|
saveDataAndGeneratePdf(reData,dto.getNodeId(),dto.getClassify(),wbsContract.getContractId(),wbsContract.getProjectId());
|
|
|
return R.status( true);
|
|
|
}
|
|
|
|
|
|
+ private static int removeUnderscoreAndCombine(String input) {
|
|
|
+ return Integer.parseInt(input.replace("_", ""));
|
|
|
+ }
|
|
|
+
|
|
|
private void saveDataAndGeneratePdf(Map<WbsTreeContract, Map<String, String>> reData,String nodeId,String classify,String contractId,String projectId) throws Exception {
|
|
|
for (Map.Entry<WbsTreeContract, Map<String, String>> entry : reData.entrySet()) {
|
|
|
Map<String, String> dataInfo2 = entry.getValue();
|