Selaa lähdekoodia

Merge branch 'dev' of http://219.151.181.73:3000/zhuwei/bladex into lihb

LHB 2 kuukautta sitten
vanhempi
commit
5a1fb2c60e
16 muutettua tiedostoa jossa 452 lisäystä ja 57 poistoa
  1. 5 1
      blade-common/src/main/java/org/springblade/common/constant/LauncherConstant.java
  2. 46 2
      blade-common/src/main/java/org/springblade/common/utils/CommonUtil.java
  3. 15 0
      blade-service/blade-business/src/main/java/org/springblade/business/controller/MessageWarningController.java
  4. 3 3
      blade-service/blade-business/src/main/java/org/springblade/business/controller/NeiYeController.java
  5. 16 2
      blade-service/blade-business/src/main/java/org/springblade/business/controller/TaskController.java
  6. 1 1
      blade-service/blade-business/src/main/java/org/springblade/business/mapper/InformationQueryMapper.xml
  7. 49 1
      blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TaskServiceImpl.java
  8. 1 1
      blade-service/blade-business/src/main/java/org/springblade/business/utils/PDFUtil.java
  9. 3 3
      blade-service/blade-e-visa/src/main/java/org/springblade/evisa/utils/PDFUtils.java
  10. 9 5
      blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/WbsTreeContractServiceImpl.java
  11. 1 0
      blade-service/blade-meter/src/main/java/org/springblade/meter/controller/TaskController.java
  12. 11 0
      blade-service/blade-repair/pom.xml
  13. 1 1
      blade-service/blade-repair/src/main/java/org/springblade/RepairApplication.java
  14. 82 36
      blade-service/blade-repair/src/main/java/org/springblade/repair/controller/CheckAndRepairController.java
  15. 208 0
      blade-service/blade-repair/src/main/java/org/springblade/repair/util/ExcelInfoUtils.java
  16. 1 1
      blade-service/blade-repair/src/main/resources/application-dev.yml

+ 5 - 1
blade-common/src/main/java/org/springblade/common/constant/LauncherConstant.java

@@ -77,12 +77,16 @@ public interface LauncherConstant {
      */
     String APPLICATION_XXLJOB_ADMIN_NAME = APPLICATION_NAME_PREFIX + "xxljob-admin";
 
+
+    String  APPLICATION_REPAIR_NAME = APPLICATION_NAME_PREFIX + "repair";
+
+
     /**
      * nacos dev 地址 215==172.31.222.127   192.168.0.109     127.0.0.1  210-=-172.30.224.81
      * nacos dev 地址 172.31.222.127   192.168.0.109     127.0.0.1    172.30.224.81(39.108.216.210) 152.168.2.11
      */
     //更107服务器时打包的时候要改成192.168.0.109
-    //127.0.0.1
+    // 73用这个 127.0.0.1    113要用这个 10.0.0.6
     String NACOS_DEV_ADDR = "127.0.0.1:8848";
 
     /**

+ 46 - 2
blade-common/src/main/java/org/springblade/common/utils/CommonUtil.java

@@ -140,7 +140,7 @@ public class CommonUtil {
     /**
      * 根据OSS文件路径获取文件输入流
      */
-    public static synchronized InputStream getOSSInputStream(String urlStr) {
+    public static  InputStream getOSSInputStream(String urlStr) {
         try {
             System.out.println("----前-------"+urlStr);
             urlStr = replaceOssUrl(urlStr);
@@ -183,7 +183,7 @@ public class CommonUtil {
     /**
      * 获取字节数组
      */
-    public static synchronized byte[] InputStreamToBytes(InputStream is) {
+    public static  byte[] InputStreamToBytes(InputStream is) {
         BufferedInputStream bis = new BufferedInputStream(is);
         ByteArrayOutputStream os = new ByteArrayOutputStream();
         int date = -1;
@@ -512,6 +512,50 @@ public class CommonUtil {
         //返回响应报文头字段Content-Length的值
         return urlConnection.getContentLength();
     }
+    public static long getFileContentLength(String urlStr) {
+        try {
+            urlStr = replaceOssUrl(urlStr);
+            System.out.println("获取文件大小:"+urlStr);
+            URL url = new URL(urlStr);
+            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
+            // 设置 HEAD 请求(只获取头部信息,不下载文件)
+            conn.setRequestMethod("HEAD");
+            // 设置超时(避免线上卡死)
+            conn.setConnectTimeout(5000); // 5秒连接超时
+            conn.setReadTimeout(5000);    // 5秒读取超时
+            // 发起请求
+            conn.connect();
+            // 获取 Content-Length
+            long contentLength = conn.getContentLengthLong();
+            // 关闭连接
+            conn.disconnect();
+            return contentLength;
+        } catch (Exception e) {
+            return 0L;
+        }
+    }
+    public static long getFileSize(String fileUrl) throws IOException {
+        URL url = new URL(fileUrl);
+        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
+
+        // 使用 HEAD 请求(只获取文件信息,不下载内容)
+        conn.setRequestMethod("HEAD");
+
+        // 设置超时(避免卡死)
+        conn.setConnectTimeout(5000); // 5秒连接超时
+        conn.setReadTimeout(5000);    // 5秒读取超时
+
+        // 发起请求
+        conn.connect();
+
+        // 获取 Content-Length(文件大小)
+        long fileSize = conn.getContentLengthLong();
+
+        // 关闭连接
+        conn.disconnect();
+
+        return fileSize;
+    }
 
 
     /**

+ 15 - 0
blade-service/blade-business/src/main/java/org/springblade/business/controller/MessageWarningController.java

@@ -166,6 +166,13 @@ public class MessageWarningController extends BladeController {
         if (vo.getSmsType() != null && vo.getSmsType() > -1) {
             wrapper.lambda().eq(MessageWarning::getIsRead, new Integer("2").equals(vo.getSmsType()) ? 0 : 1);
         }
+        if (vo.getTypeValue() != null && !vo.getTypeValue().isEmpty()) {
+            if (vo.getTypeValue().equals("1")) {
+                wrapper.lambda().like(MessageWarning::getContent, "废除了");
+            } else {
+                wrapper.lambda().like(MessageWarning::getContent, "驳回了");
+            }
+        }
         //设置合同段ID
         wrapper.lambda().eq(MessageWarning::getProjectId, vo.getProjectId()).eq(MessageWarning::getContractId, vo.getContractId());
 
@@ -179,6 +186,14 @@ public class MessageWarningController extends BladeController {
             List<DictBiz> dictBizs = this.dictBizClient.getList("business_message_type", "notRoot").getData();
 
             iPage.getRecords().forEach(reVO -> {
+                if (reVO.getType() != null && reVO.getType() == 3) {
+                    if (reVO.getContent() != null && reVO.getContent().contains("驳回了")) {
+                        reVO.setTypeValue("驳回通知");
+                    } else if (reVO.getContent() != null && reVO.getContent().contains("废除了")) {
+                        reVO.setTypeValue("废除通知");
+                    }
+                    return;
+                }
                 if (dictBizs != null && dictBizs.size() > 0) {
                     for (DictBiz biz : dictBizs) {
                         if (biz.getDictKey().equals(reVO.getType().toString())) {

+ 3 - 3
blade-service/blade-business/src/main/java/org/springblade/business/controller/NeiYeController.java

@@ -369,7 +369,7 @@ public class NeiYeController {
                     if(info!=null){
                         if(info.indexOf("优良")>=0){
                             vo1.setGoodCount(1);
-                            vo1.setPassCount(0);
+                            vo1.setPassCount(1);
                             vo1.setGoodRate("100%");
                         }else {
                             vo1.setGoodCount(0);
@@ -427,7 +427,7 @@ public class NeiYeController {
                             if(info.indexOf("优良")>=0){
                                 if(type==2){
                                     vo2.setGoodCount(1);
-                                    vo2.setPassCount(0);
+                                    vo2.setPassCount(1);
                                     vo2.setGoodRate("100%");
                                 }else {
                                     goodCount++;
@@ -454,7 +454,7 @@ public class NeiYeController {
                 else if(type==1){
                     vo1.setUnitCount(unitCount);
                     vo1.setGoodCount(goodCount);
-                    vo1.setPassCount(passCount);
+                    vo1.setPassCount(passCount + goodCount);
                     vo1.setGoodRate(calculatePercentage(goodCount,unitCount));
                     vo1.setId(SnowFlakeUtil.getId());
                     voList.add(vo1);

+ 16 - 2
blade-service/blade-business/src/main/java/org/springblade/business/controller/TaskController.java

@@ -378,6 +378,7 @@ public class TaskController extends BladeController {
 
             //审批
             this.taskService.batchCompleteApprovalTask(taskApprovalVOS);
+            Map<String, TaskApprovalVO> taskApprovalVOMap = taskApprovalVOS.stream().collect(Collectors.toMap(TaskApprovalVO::getTaskId, taskApprovalVO -> taskApprovalVO, (o1, o2) -> o1));
             for (Task task : taskList) {
                 if (batchTaskVO.getFlag().equals("NO")) {
                     JSONObject json = new JSONObject();
@@ -385,8 +386,9 @@ public class TaskController extends BladeController {
                     json.put("operationObjName", "批量废除");
                     json.put("projectId", task.getProjectId());
                     json.put("contractId", task.getContractId());
+                    json.put("saveData", JSONObject.toJSONString(taskApprovalVOMap.get(task.getId() + "")));
                     //保存操作记录
-                    this.operationLogClient.saveUserOperationLog(61, "资料回废除", "工序资料", json);
+                    this.operationLogClient.saveUserOperationLog(61, "资料回废除", "工序资料", json);
                 }
             }
 
@@ -1235,6 +1237,7 @@ public class TaskController extends BladeController {
             json.put("operationObjName", "批量废除");
             json.put("projectId", task.getProjectId());
             json.put("contractId", task.getContractId());
+            json.put("saveData", JSONObject.toJSONString(taskApprovalVO));
             //保存操作记录
             this.operationLogClient.saveUserOperationLog(61, "资料驳回废除", "工序资料", json);
         }
@@ -1508,7 +1511,7 @@ public class TaskController extends BladeController {
                             task -> task));
         }
         //所有满足条件的日志 转map
-        String logQuery = "select business_id,create_user_name ,create_time, operation_type from u_operation_log where  operation_content like '%废除%'";
+        String logQuery = "select business_id,create_user_name ,create_time, operation_type, save_data from u_operation_log where  operation_content like '%废除%'";
         List<OperationLog> operationLogs = jdbcTemplate.query(logQuery, new BeanPropertyRowMapper<>(OperationLog.class));
         if(ObjectUtil.isNotEmpty(operationLogs)){
              operationLogMap = operationLogs.stream().collect(Collectors.groupingBy(OperationLog::getBusinessId));
@@ -1532,6 +1535,17 @@ public class TaskController extends BladeController {
                         OperationLog operationLog = min.get();
                         if (operationLog.getOperationType() != null && operationLog.getOperationType() == 61) {
                             businessTaskPageVO.setEVisaStatus("驳回成功:"+operationLog.getCreateUserName()+"-"+operationLog.getCreateTime());
+                            String saveData = operationLog.getSaveData();
+                            if (saveData != null && !saveData.isEmpty()) {
+                                try  {
+                                    JSONObject data = JSONObject.parseObject(saveData);
+                                    if (data != null && data.containsKey("comment")) {
+                                        businessTaskPageVO.setEVisaStatus("驳回成功:"+operationLog.getCreateUserName()+"-"+operationLog.getCreateTime() + ";驳回原因:"+data.getString("comment"));
+                                    }
+                                } catch (Exception e) {
+                                    e.printStackTrace();
+                                }
+                            }
                         } else if (operationLog.getOperationType() != null && operationLog.getOperationType() == 62) {
                             businessTaskPageVO.setEVisaStatus("撤回成功:"+operationLog.getCreateUserName()+"-"+operationLog.getCreateTime());
                         } else {

+ 1 - 1
blade-service/blade-business/src/main/java/org/springblade/business/mapper/InformationQueryMapper.xml

@@ -768,7 +768,7 @@
         <if test="query.taskStatus != null and query.taskStatus != ''">
           <choose>
               <when test="query.taskStatus == 0">
-                  and (iq.status = 0 or iq.status = 3)
+                  and iq.status = 0
               </when>
               <otherwise>
                   and iq.status = #{query.taskStatus}

+ 49 - 1
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TaskServiceImpl.java

@@ -668,11 +668,23 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, Task> implement
                 }
                 this.taskBatchService.saveBatch(taskList);
             }else if (taskAppr.getFlag().equals("NO")){ //废除
+                Set<String> taskIds = taskApprovalVOS.stream().map(TaskApprovalVO::getTaskId).collect(Collectors.toSet());
+                List<Task> tasks = this.listByIds(taskIds);
+                Map<String, Task> taskMap = tasks.stream().collect(Collectors.toMap(task -> task.getId() + "", task -> task));
+                List<String> projectIds = tasks.stream().map(Task::getProjectId).distinct().collect(Collectors.toList());
+                List<Long> contractIds = tasks.stream().map(task -> Long.valueOf(task.getContractId())).distinct().collect(Collectors.toList());
+                List<ProjectInfo> projects = this.projectClient.queryProjectList(projectIds);
+                List<ContractInfo> contracts = this.contractClient.getContractByIds(contractIds);
+                Map<String, ProjectInfo> projectMap = new HashMap<>();
+                Map<String, ContractInfo> contractMap = new HashMap<>();
+                projects.forEach(project -> projectMap.put(project.getId().toString(), project));
+                contracts.forEach(contract -> contractMap.put(contract.getId().toString(), contract));
+
                 for (TaskApprovalVO taskApp : taskApprovalVOS) {
                     // 废除信息
                     Integer appType = taskApp.getApprovalType();
                     //质检系统
-                    String up_task_par = "update u_task_parallel set status=3 , e_visa_content = '驳回成功', initiative=10,update_time=SYSDATE(),update_user="+userId+"  where parallel_process_instance_id='"+taskApp.getParallelProcessInstanceId()+"'";
+                    String up_task_par = "update u_task_parallel set status=3 , e_visa_content = '驳回成功,驳回原因:" + taskApp.getComment() + "', initiative=10,update_time=SYSDATE(),update_user="+userId+"  where parallel_process_instance_id='"+taskApp.getParallelProcessInstanceId()+"'";
                     String up_task = "update u_task set status=3, update_time=SYSDATE(),update_user="+userId+" where id='"+taskApp.getTaskId()+"'";
                     this.jdbcTemplate.execute("delete from u_task_batch where JSON_UNQUOTE(JSON_EXTRACT(json_data, '$.taskId'))="+taskApp.getTaskId()+"");
                     jdbcTemplate.execute(up_task_par);
@@ -708,6 +720,42 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, Task> implement
                             }
                         }
                     }
+                    String projectName = "", contractName = "";
+                    Task task = taskMap.get(taskApp.getTaskId());
+                    if (task != null) {
+                        if (projectMap.containsKey(task.getProjectId())) {
+                            ProjectInfo project = projectMap.get(task.getProjectId());
+                            projectName = StringUtils.isNotEmpty(project.getProjectAlias()) ? project.getProjectAlias() : project.getProjectName();
+                        }
+                        if (contractMap.containsKey(task.getContractId())) {
+                            ContractInfo contract = contractMap.get(task.getContractId());
+                            contractName = contract.getContractName();
+                        }
+                        List<TaskParallel> list = this.taskParallelService.list(Wrappers.<TaskParallel>lambdaQuery().select(TaskParallel::getTaskUser).eq(TaskParallel::getProcessInstanceId, task.getProcessInstanceId()));
+                        Set<String> userIds = list.stream().map(TaskParallel::getTaskUser).collect(Collectors.toSet());
+                        userIds.add(task.getReportUser());
+                        List<MessageWarningVO> messageWarningVOS = new ArrayList<>();
+                        //保存通知记录
+                        for (String id : userIds) {
+                            messageWarningVOS.add(new MessageWarningVO(
+                                    Long.valueOf(task.getProjectId()),
+                                    Long.valueOf(task.getContractId()),
+                                    //驳回通知
+                                    3,
+                                    //内容
+                                    projectName + contractName + "的用户【" + AuthUtil.getNickName() + "】驳回了【" + task.getTaskName() + "】" + ",驳回原因:" + taskApp.getComment(),
+                                    //推送的目标人
+                                    Long.parseLong(id),
+                                    //默认未读
+                                    0
+                            ));
+                        }
+                        try {
+                            this.messageWarningService.savePushUserMessageWarning(messageWarningVOS);
+                        } catch (Exception e) {
+                            e.printStackTrace();
+                        }
+                    }
                 }
             }
         }

+ 1 - 1
blade-service/blade-business/src/main/java/org/springblade/business/utils/PDFUtil.java

@@ -106,7 +106,7 @@ public class PDFUtil {
                     System.out.println(textStr);
                     String[] textS = Func.toStrArray("\\|\\|",textStr);
                     for(String txt : textS){
-                        if (txt.length() >= 15 && Func.isNumeric(txt)) {
+                        if (txt.length() >= 15 && Func.isNumeric(txt)||(Func.isNumeric(txt)&&txt.length()==8&&txt.startsWith("123"))) {
                             eVisaConfigList.add(txt);
                         }
                     }

+ 3 - 3
blade-service/blade-e-visa/src/main/java/org/springblade/evisa/utils/PDFUtils.java

@@ -40,7 +40,7 @@ public class PDFUtils {
                             txt=txt.substring(0,i);
                         }
                     }
-                    if (txt.length() >= 15 && Func.isNumeric(txt)) {
+                    if (txt.length() >= 15 && Func.isNumeric(txt)||(Func.isNumeric(txt)&&txt.length()==8&&txt.startsWith("123"))) {
                         eVisaConfigList.add(txt);
                     }
 
@@ -53,7 +53,7 @@ public class PDFUtils {
                 // 特殊处理
                 if(textStr.indexOf("1")>=0){
                     String txt = textStr.substring(textStr.indexOf("1"));
-                    if (txt.length() >= 15 && Func.isNumeric(txt)) {
+                    if (txt.length() >= 15 && Func.isNumeric(txt)||(Func.isNumeric(txt)&&txt.length()==8&&txt.startsWith("123"))) {
                         System.out.println(txt);
                         eVisaConfigList.add(txt);
                     }
@@ -125,4 +125,4 @@ public class PDFUtils {
         }
     }
 
-}
+}

+ 9 - 5
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/WbsTreeContractServiceImpl.java

@@ -2386,7 +2386,6 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
         //本次修改的节点
         List<String> updateList=new ArrayList<>();
 
-        //新增
         String sqlList="Select parent_id,node_name from m_wbs_tree_contract where contract_id="+wbsTreeContractRoot.getContractId()+" and wbs_id="+wbsTreeContractRoot.getWbsId()+" and is_deleted=0";
         List<WbsTreeContract> WbsTreeContractListupdate = jdbcTemplate.query(sqlList, new BeanPropertyRowMapper<>(WbsTreeContract.class));
         //导入节点与现有节点进行比较。进行修改编号
@@ -2481,7 +2480,7 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
         int i=0;
         for (ImportTreeDto dto : list) {
             //新增
-            String sqlList1="Select parent_id,node_name from m_wbs_tree_contract where contract_id="+wbsTreeContractRoot.getContractId()+" and wbs_id="+wbsTreeContractRoot.getWbsId()+" and is_deleted=0";
+            String sqlList1="Select parent_id,node_name,p_id from m_wbs_tree_contract where contract_id="+wbsTreeContractRoot.getContractId()+" and wbs_id="+wbsTreeContractRoot.getWbsId()+" and is_deleted=0";
             List<WbsTreeContract> WbsTreeContractList = jdbcTemplate.query(sqlList1, new BeanPropertyRowMapper<>(WbsTreeContract.class));
             i++;
             //单位工程:如果没有被处理过,说明需要新增
@@ -2557,6 +2556,7 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
                             String sql="Select node_name from m_wbs_tree_contract where p_key_id in("+String.join(",", ids)+")";
                             List<String> nodeNames = jdbcTemplate.query(sql, new SingleColumnRowMapper<>(String.class));
                             String result = String.join("",nodeNames);
+                            result=result+contract.getNodeName();
                             String ancestorsName= wbsTreeContractRoot.getNodeName()+StringUtils.defaultString(dto.getUnitName())
                                 + StringUtils.defaultString(dto.getSubUnitName());
                             if(result.equals(ancestorsName)){
@@ -2608,6 +2608,7 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
                             String sql="Select node_name from m_wbs_tree_contract where p_key_id in("+String.join(",", ids)+")";
                             List<String> nodeNames = jdbcTemplate.query(sql, new SingleColumnRowMapper<>(String.class));
                             String result = String.join("",nodeNames);
+                            result=result+contract.getNodeName();
                             String ancestorsName= wbsTreeContractRoot.getNodeName()+StringUtils.defaultString(dto.getUnitName())
                                 + StringUtils.defaultString(dto.getSubUnitName())
                                 +StringUtils.defaultString(dto.getDivisionName());
@@ -2663,6 +2664,7 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
                             String sql="Select node_name from m_wbs_tree_contract where p_key_id in("+String.join(",", ids)+")";
                             List<String> nodeNames = jdbcTemplate.query(sql, new SingleColumnRowMapper<>(String.class));
                             String result = String.join("",nodeNames);
+                            result=result+contract.getNodeName();
                             String ancestorsName= wbsTreeContractRoot.getNodeName()+StringUtils.defaultString(dto.getUnitName())
                                 + StringUtils.defaultString(dto.getSubUnitName())
                                 +StringUtils.defaultString(dto.getDivisionName())
@@ -2721,6 +2723,7 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
                             String sql="Select node_name from m_wbs_tree_contract where p_key_id in("+String.join(",", ids)+")";
                             List<String> nodeNames = jdbcTemplate.query(sql, new SingleColumnRowMapper<>(String.class));
                             String result = String.join("",nodeNames);
+                            result=result+contract.getNodeName();
                             String ancestorsName= wbsTreeContractRoot.getNodeName()+StringUtils.defaultString(dto.getUnitName())
                                 + StringUtils.defaultString(dto.getSubUnitName())
                                 +StringUtils.defaultString(dto.getDivisionName())
@@ -3081,7 +3084,7 @@ public static boolean hasConflictingCodes(List<ImportTreeDto> list) {
                 return true;
             }
             //如果数据库中存在名称相同的节点,查询该节点的祖级节点
-            String sql="select p_key_id,node_name from m_wbs_tree_contract where is_deleted=0 and contract_id="+contractId+" and p_key_id in ("+String.join(",", list.stream().map(String::valueOf).collect(Collectors.toList()))+")";
+            String sql="select p_key_id,node_name,contract_id from m_wbs_tree_contract where is_deleted=0 and contract_id="+contractId+" and p_key_id in ("+String.join(",", list.stream().map(String::valueOf).collect(Collectors.toList()))+")";
             List<WbsTreeContract> wbsContracts = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(WbsTreeContract.class));
             String  fatherNodeName="";
             if(type==2){
@@ -3105,11 +3108,12 @@ public static boolean hasConflictingCodes(List<ImportTreeDto> list) {
                         String ancestors = jdbcTemplate.queryForObject(Sql, new SingleColumnRowMapper<>(String.class));
                         String[] ids = ancestors.split(",");
                         ids=Arrays.stream(ids)
-                            .filter(id -> !id.equals("0")) // 过滤掉值为 "0" 的元素
+                            .filter(i->!i.equals("0"))
                             .toArray(String[]::new);
-                        String sql1="Select node_name from m_wbs_tree_contract where p_key_id in("+String.join(",", ids)+")";
+                        String sql1="Select node_name from m_wbs_tree_contract where p_key_id in("+String.join(",", ids)+") and contract_id="+wbsContract.getContractId()+" and is_deleted=0";
                         List<String> nodeNames = jdbcTemplate.query(sql1, new SingleColumnRowMapper<>(String.class));
                         String join = String.join("", nodeNames);
+                        join=join+wbsContract.getNodeName();
                         if(join.equals(fatherNodeName)){
                             return true;
                         }

+ 1 - 0
blade-service/blade-meter/src/main/java/org/springblade/meter/controller/TaskController.java

@@ -1090,6 +1090,7 @@ public class TaskController extends BladeController {
                     json.put("operationObjName", "任务废除");
                     json.put("projectId", task.getProjectId());
                     json.put("contractId", task.getContractId());
+                    json.put("saveData", JSONObject.toJSONString(taskRepealDTO));
                     //保存操作记录
                     this.operationLogClient.saveUserOperationLog(61, "资料驳回废除", "计量资料", json);
                     return R.data(200, aopParamsSet, "操作成功");

+ 11 - 0
blade-service/blade-repair/pom.xml

@@ -65,5 +65,16 @@
             <groupId>org.springframework</groupId>
             <artifactId>spring-test</artifactId>
         </dependency>
+        <dependency>
+            <groupId>e-iceblue</groupId>
+            <artifactId>spire.xls.free</artifactId>
+            <version>5.3.0</version>
+            <scope>system</scope>
+            <systemPath>${basedir}/../../doc/lib/eVisaLib/spire.xls.free-5.3.0.jar</systemPath>
+        </dependency>
+        <dependency>
+            <groupId>org.jsoup</groupId>
+            <artifactId>jsoup</artifactId>
+        </dependency>
     </dependencies>
 </project>

+ 1 - 1
blade-service/blade-repair/src/main/java/org/springblade/RepairApplication.java

@@ -13,6 +13,6 @@ import org.springframework.scheduling.annotation.EnableAsync;
 @EnableCaching
 public class RepairApplication {
     public static void main(String[] args) {
-        BladeApplication.run(LauncherConstant.APPLICATION_METER_NAME, RepairApplication.class, args);
+        BladeApplication.run(LauncherConstant.APPLICATION_REPAIR_NAME, RepairApplication.class, args);
     }
 }

+ 82 - 36
blade-service/blade-repair/src/main/java/org/springblade/repair/controller/CheckAndRepairController.java

@@ -9,6 +9,9 @@ import org.springblade.core.oss.model.BladeFile;
 import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.ObjectUtil;
 import org.springblade.manager.entity.ExcelTab;
+import org.springblade.manager.entity.WbsTreeContract;
+import org.springblade.manager.entity.WbsTreePrivate;
+import org.springblade.repair.util.ExcelInfoUtils;
 import org.springblade.repair.util.FileUtils;
 import org.springblade.resource.feign.NewIOSSClient;
 import org.springframework.jdbc.core.BeanPropertyRowMapper;
@@ -21,6 +24,7 @@ import org.springframework.web.bind.annotation.RestController;
 import org.springblade.manager.feign.ExcelTabClient;
 import org.springframework.web.multipart.MultipartFile;
 import java.io.File;
+import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.nio.file.Files;
@@ -41,10 +45,9 @@ public class CheckAndRepairController {
      */
     @RequestMapping("/checkAndRepairExcelHtml")
     @ApiOperation("定时检测修复ExcelHtml")
-    @Scheduled(cron = "0  15 16 * * ?")
+    @Scheduled(cron = "00 22 10 * * ?")
     public void checkAndRepairExcelHtml() {
-        StringBuilder result=new StringBuilder("");
-        StringBuilder result1=new StringBuilder("");
+        StringBuilder result=new StringBuilder("清表损坏:");
         String sql = "Select * from m_excel_tab where parent_id=0 and is_deleted=0";
         List<ExcelTab> query = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(ExcelTab.class));
         //String excelPath="E:\\excel\\";
@@ -57,27 +60,37 @@ public class CheckAndRepairController {
                     String sql2 = "Select * from m_excel_tab where parent_id=" + tab.getId() + " and is_deleted=0 and file_url is not null ";
                     List<ExcelTab> query2 = jdbcTemplate.query(sql2, new BeanPropertyRowMapper<>(ExcelTab.class));
                     for (ExcelTab excelTab1 : query2) {
+                        if(excelTab1.getId()==1800344270830305280L){
+                            continue;
+                        }
                         File html = new File(excelTab1.getHtmlUrl());
                         if(!html.exists()){
                             System.out.println(excelTab.getName() + "--" + tab.getName() + "--" + excelTab1.getName()+"html不存在 id:"+excelTab1.getId());
                             if(excelTab1.getFileUrl() != null&&excelTab1.getFileUrl().endsWith(".xlsx") || excelTab1.getFileUrl().endsWith(".xls")){
-                                long resourceLength = CommonUtil.getResourceLength(excelTab1.getFileUrl());
-                                if(resourceLength>=500){
+                                long resourceLength = CommonUtil.getFileContentLength(excelTab1.getFileUrl());
+                                System.out.println("文件大小:"+resourceLength);
+                                if(resourceLength!=415L&&resourceLength!=0L&&resourceLength!=234L){
                                     //先下载这个文件,再上传
                                     String fileUrl = excelTab1.getFileUrl();
                                     String localPath=excelPath+excelTab1.getId()+".xlsx";
-                                    InputStream inputStreamByUrl = FileUtils.getInputStreamByUrl(fileUrl);
-                                    FileUtils.saveFile(inputStreamByUrl,localPath);
-                                    File htmlFile = new File(localPath);
-                                    if(htmlFile.exists()){
-                                        try {
-                                            MultipartFile file = convert(htmlFile, excelTab1);
-                                            this.putFileAttach(file, excelTab1.getId());
-                                        }catch (Exception e){
-                                            e.printStackTrace();
+                                    System.out.println("开始下载:"+fileUrl);
+                                    try {
+                                        InputStream inputStreamByUrl = FileUtils.getInputStreamByUrl(fileUrl);
+                                        if(inputStreamByUrl!=null){
+                                            FileUtils.saveFile(inputStreamByUrl,localPath);
+                                            File htmlFile = new File(localPath);
+                                            if(htmlFile.exists()){
+                                                this.putFileAttach(new FileInputStream(htmlFile), excelTab1.getId(),excelTab1.getExtension());
+                                            }
+                                        }
+                                    }catch (Exception e){
+                                        System.out.println("下载失败:"+fileUrl);
+                                        if(resourceLength<500){
+                                            deletedExcel(excelTab1.getId());
                                         }
                                     }
                                 }else {
+                                    deletedExcel(excelTab1.getId());
                                     result.append(excelTab.getName() + "--" + tab.getName() + "--" + excelTab1.getName()+"\n");
                                 }
                             }
@@ -86,49 +99,82 @@ public class CheckAndRepairController {
                 }
             }
         } catch (Exception e) {
-            throw new RuntimeException(e);
+            e.printStackTrace();
         }
         System.out.println("完成");
         System.out.println(result);
-        System.out.println(result1);
     }
 
-    public static MultipartFile convert(File file,ExcelTab e) throws IOException {
-        String contentType = Files.probeContentType(file.toPath());
-        byte[] content = Files.readAllBytes(file.toPath());
-        return new MockMultipartFile(
-            "file",
-            e.getName(),
-            contentType,
-            content
-        );
+    public void deletedExcel(Long id){
+        String sql="update m_excel_tab set is_deleted=3 where id="+id;
+        jdbcTemplate.execute(sql);
+        System.out.println("删除成功:"+id);
     }
-    public R putFileAttach(@RequestParam("file") MultipartFile file, Long nodeId) throws Exception {
+
+    public void putFileAttach(InputStream inputStream, Long nodeId,String name) throws Exception {
+        System.out.println("开始上传");
         String file_path = FileUtils.getSysLocalFileUrl();
         String sql="Select * from m_excel_tab where id="+nodeId+" and is_deleted=0";
         ExcelTab detail = jdbcTemplate.queryForObject(sql, new BeanPropertyRowMapper<>(ExcelTab.class));
         String filecode = SnowFlakeUtil.getId() + "";
         String thmlUrl = file_path + filecode + ".html";
         String exceUrl = file_path + filecode + "123.xlsx";
-        excelTabClient.excelInfo(file.getInputStream(), exceUrl, thmlUrl, "1");
+        ExcelInfoUtils.excelInfo(inputStream, exceUrl, thmlUrl, "1");
         // 上传excel文件
-        BladeFile bladeFile = newIOSSClient.uploadFile(file.getOriginalFilename(), exceUrl);
-        if (bladeFile == null || ObjectUtil.isEmpty(bladeFile)) {
-            return R.fail("oss上传失败,请校验oss配置是否正确");
-        }
+        BladeFile bladeFile = newIOSSClient.uploadFile(name, exceUrl);
         // 解析原始excel
-        detail.setExtension(file.getOriginalFilename());
+        detail.setExtension(name);
         detail.setFileUrl(bladeFile.getLink());
         detail.setFileType(3); // 表示为清表信息  1 表示祖节点  2 表示为节点信息 3 表示清表
         detail.setHtmlUrl(thmlUrl);
-        excelTabClient.saveOrUpdate(detail);
+        String update="update m_excel_tab set file_url ="+"'"+bladeFile.getLink()+"' , html_url="+"'"+thmlUrl+"' where id="+nodeId;
+        System.out.println(update);
+        int i = jdbcTemplate.update(update);
         // 解析html
         excelTabClient.expailHtmlInfo(thmlUrl, detail.getId(), detail.getTabType() + "");
-        return R.success("上传成功");
+        if(i==1){
+            System.out.println("上传成功");
+        }else {
+            System.out.println("上传失败");
+        }
+
     }
 
     /**
-     * 每周天晚上2点定时更新private和contract的html,通过is_private_type_id;
+     * 定时更新private的htmUrl 保证url格式为 /mnt/sdc/Users/hongchuangyanfa/Desktop/privateUrlCopy/
      */
-    public void checkAndRepairPrivateAndContractHtml() {}
+    private void checkAndRepairPrivateAndContractPrivateCopyUrl() {
+
+    }
+
+    /**
+     * 定时更新private和contract的html,通过is_private_type_id;保证一样
+     */
+    @Scheduled(cron = "0 0 1 * * ?")
+    public void checkAndRepairPrivateAndContractHtml() {
+        System.out.println("开始扫描private和contract的html");
+        StringBuilder result=new StringBuilder("");
+        try {
+            String sql="SELECT a.p_key_id,a.is_type_private_pid FROM m_wbs_tree_contract a,m_wbs_tree_private b WHERE a.html_url != b.html_url AND a.is_type_private_pid=b.p_key_id AND a.type=2 AND a.is_deleted=0 AND b.type=2 AND b.html_url is not NULL";
+            List<WbsTreeContract> contractListlist = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(WbsTreeContract.class));
+            for (WbsTreeContract wbsTreeContract : contractListlist) {
+                String update=" update m_wbs_tree_contract set html_url=(select html_url from m_wbs_tree_private where p_key_id="+wbsTreeContract.getIsTypePrivatePid()+") where p_key_id="+wbsTreeContract.getPKeyId();
+                int i = jdbcTemplate.update(update);
+                if(i!=1){
+                    result.append(wbsTreeContract.getPKeyId()+"\n");
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        System.out.println("更新完毕private和contract的html");
+        System.out.println(result);
+    }
+
+    /**
+     * 定时更新private和contract的initTable 通过excelID,保证一样
+     */
+    public void checkAndRepairPrivateAndContractInitTable() {}
+
+
 }

+ 208 - 0
blade-service/blade-repair/src/main/java/org/springblade/repair/util/ExcelInfoUtils.java

@@ -0,0 +1,208 @@
+package org.springblade.repair.util;
+
+import com.spire.xls.CellRange;
+import com.spire.xls.FileFormat;
+import com.spire.xls.Workbook;
+import com.spire.xls.Worksheet;
+import com.spire.xls.core.spreadsheet.HTMLOptions;
+import org.apache.commons.lang.StringUtils;
+import org.jsoup.Jsoup;
+import org.jsoup.nodes.Document;
+import org.jsoup.nodes.Element;
+import org.jsoup.select.Elements;
+
+import org.springblade.common.utils.SnowFlakeUtil;
+import org.springblade.core.tool.utils.FileUtil;
+import org.springblade.core.tool.utils.Func;
+import org.springblade.core.tool.utils.IoUtil;
+import org.springblade.core.tool.utils.ResourceUtil;
+import org.springblade.manager.vo.DateFormat;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class ExcelInfoUtils {
+    public static void excelInfo(InputStream inputStream, String excelURL, String htmlUrl, String type) {
+        try {
+            String file_path = "/Users/hongchuangyanfa/Desktop//pdf/";
+            String filecode = SnowFlakeUtil.getId() + "";
+            String thmlUrl2 = file_path + filecode + "123.html";
+
+            // 解析原始excel
+            Workbook wb = new Workbook();
+            wb.loadFromMHtml(inputStream);
+            Worksheet sheet = wb.getWorksheets().get(0);
+            HTMLOptions options = new HTMLOptions();
+            options.setImageEmbedded(true);
+
+            // 校验excel 是否正常
+            sheet.saveToHtml(htmlUrl, options);
+            File file1 = ResourceUtil.getFile(htmlUrl);
+            String htmlString = IoUtil.readToString(new FileInputStream(file1));
+            Document doc = Jsoup.parse(htmlString);
+            Element table = doc.select("table").first();
+            Elements trs = table.select("tr");
+            Elements cols = table.select("Col");
+            sheet.deleteRow(trs.size()+1,sheet.getRows().length - trs.size());
+            sheet.deleteColumn(cols.size()+1,sheet.getColumns().length - cols.size());
+            file1.delete();
+            //复制一份
+            wb.saveToFile(excelURL, FileFormat.Version2013);
+            // 操作
+            Workbook wb2 = new Workbook();
+            wb2.loadFromMHtml(excelURL);
+            Worksheet sheet2 = wb2.getWorksheets().get(0);
+
+            // 坐标map
+            Map<String, Map<String, Integer>> xyList = new HashMap<>();
+            int j = 0;
+            int maxVal = 0;
+            if(type.equals("2")){
+                CellRange[] sheet2Cells = sheet2.getCells();
+                for (int i = 0; i < sheet2Cells.length; i++) {
+                    CellRange oldcell = sheet2Cells[i];
+                    String data = oldcell.getDataValidation().getErrorMessage();
+                    int k = 0;
+                    if(Func.isNumeric(data)){
+                        k = Func.toInt(data);
+                    }
+                    if (maxVal < k) {
+                        maxVal = k;
+                    }
+                }
+            }else if(type.equals("1")){
+                CellRange[] sheet2Cells = sheet.getCells();
+                for (int i = 0; i < sheet2Cells.length; i++) {
+                    CellRange oldcell = sheet2Cells[i];
+                    oldcell.getDataValidation().setErrorMessage("");
+                    sheet.get(oldcell.getRow(),oldcell.getColumn()).getDataValidation().setErrorMessage("");
+                }
+            }
+
+            //合并单元格操作
+            CellRange[] mergedCells = sheet.getMergedCells();
+            for (int i = 0; i < mergedCells.length; i++) {
+                Map<String, Integer> dataMap = new HashMap<>();
+                CellRange oldcell = mergedCells[i];
+                CellRange mergedCell = sheet.getCellRange(oldcell.getRow(), oldcell.getColumn());
+                if(type.equals("2")){
+                    String data = mergedCell.getDataValidation().getErrorMessage();
+                    if (StringUtils.isEmpty(data)) {
+                        if(maxVal<=0){
+                            j = j + 1;
+                        }else{
+                            maxVal = maxVal+1;
+                            j=maxVal;
+                        }
+                    } else {
+                        j = Func.toInt(data);
+                    }
+                }else{
+                    j = j + 1;
+                }
+                // 目标表添加备注信息
+                mergedCell.getDataValidation().setErrorMessage(j+"");
+                oldcell.getDataValidation().setErrorMessage(j+"");
+                sheet2.getMergedCells()[i].setText(j+"");
+                dataMap.put("y1", oldcell.getRow());
+                dataMap.put("y2", oldcell.getLastRow());
+                dataMap.put("x1", oldcell.getColumn());
+                dataMap.put("x2", oldcell.getLastColumn());
+                xyList.put(j + "", dataMap);
+            }
+
+            //变更最大值
+            if(maxVal<=0){
+                maxVal = j;
+            }
+
+            // 单个
+            CellRange[] onCell = sheet.getCells();
+            // 单个cell
+            for (int i = 0; i < onCell.length; i++) {
+                CellRange oldcell = onCell[i];
+                String data = oldcell.getDataValidation().getErrorMessage();
+                System.out.println(oldcell.getRow()+"---"+oldcell.getColumn()+"---="+oldcell.getText()+"---x="+data);
+                if (StringUtils.isEmpty(data)) {
+                    if(maxVal<=0){
+                        j = j + 1;
+                    }else{
+                        maxVal = maxVal+1;
+                        j=maxVal;
+                    }
+                } else {
+                    j = Func.toInt(data);
+                }
+
+              /*  if(StringUtils.isEmpty(data)){
+                    oldcell.getDataValidation().setErrorMessage(j+"");
+                    sheet2.getCells()[i].setText(j+"");
+                }*/
+
+                if(!xyList.containsKey(j+"")){
+                    Map<String, Integer> dataMap = new HashMap<>();
+                    dataMap.put("y1", oldcell.getRow());
+                    dataMap.put("y2", oldcell.getLastRow());
+                    dataMap.put("x1", oldcell.getColumn());
+                    dataMap.put("x2", oldcell.getLastColumn());
+                    xyList.put(j + "", dataMap);
+                }
+            }
+
+            // 保存上传的excel
+            wb.saveToFile(excelURL,FileFormat.Version2013);
+            sheet.saveToHtml(htmlUrl, options);
+            sheet2.saveToHtml(thmlUrl2);
+
+            // html 转换值
+
+            // 组装坐标
+            File html1 = new File(htmlUrl);  // 原始html
+            File html2 = new File(thmlUrl2); // 坐标html
+            InputStream inputStream1 = new FileInputStream(html1);
+            InputStream inputStream2 = new FileInputStream(html2);
+            String htmlString1 = IoUtil.readToString(inputStream1);
+            String htmlString2 = IoUtil.readToString(inputStream2);
+
+            Document doc1 = Jsoup.parse(htmlString1);
+            Element table1 = doc1.select("table").first();
+            Elements trs1 = table1.select("tr");
+            Document doc2 = Jsoup.parse(htmlString2);
+            Element table2 = doc2.select("table").first();
+            Elements trs2 = table2.select("tr");
+
+            for (int i = 0; i < trs1.size(); i++) {
+                Elements td1 = trs1.get(i).select("td");
+                Elements td2 = trs2.get(i).select("td");
+                for (int x = 0; x < td1.size(); x++) {
+                    Element cell1 = td1.get(x);
+                    Element cell2 = td2.get(x);
+                    String html = cell2.text();
+                    Map<String, Integer> xyMap = xyList.get(html);
+                    if (xyMap != null) {
+                        cell1.attr("x1", xyMap.get("x1") + "");
+                        cell1.attr("x2", xyMap.get("x2") + "");
+                        cell1.attr("y1", xyMap.get("y1") + "");
+                        cell1.attr("y2", xyMap.get("y2") + "");
+                        cell1.attr("exceVal",html);
+                    }
+                }
+            }
+
+            File writeFile = new File(htmlUrl);
+            FileUtil.writeToFile(writeFile, doc1.html(), Boolean.parseBoolean("UTF-8"));
+            if (html2.exists()) {
+                // html2.delete();
+            }
+            wb2.dispose();
+            wb.dispose();
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+    }
+}

+ 1 - 1
blade-service/blade-repair/src/main/resources/application-dev.yml

@@ -1,6 +1,6 @@
 #服务器端口
 server:
-  port: 9876
+  port: 9119
 
 #数据源配置
 spring: