Răsfoiți Sursa

后端功能处理

oyq28 10 luni în urmă
părinte
comite
aca829c976
11 a modificat fișierele cu 795 adăugiri și 461 ștergeri
  1. 2 2
      imcs-admin-boot/imcs-authority-server/src/main/resources/application.yml
  2. 240 246
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/mq/TaskWorkNode.java
  3. 2 0
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/operationManagementCenter/dao/TaskNodeMapper.java
  4. 2 0
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/operationManagementCenter/service/TaskNodeService.java
  5. 4 1
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/operationManagementCenter/service/impl/OrderServiceImpl.java
  6. 5 0
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/operationManagementCenter/service/impl/TaskNodeServiceImpl.java
  7. 136 118
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/productionResourceCenter/service/impl/MachineNodeServiceImpl.java
  8. 60 0
      imcs-admin-boot/imcs-business-biz/src/main/resources/mapper_business/base/operationManagementCenter/TaskNodeMapper.xml
  9. 186 0
      imcs-admin-boot/imcs-business-controller/src/main/java/com/github/zuihou/business/controller/operationManagementCenter/ToolQueryController.java
  10. 135 93
      imcs-admin-boot/imcs-common/src/main/java/com/github/zuihou/common/util/SmbShareFileUtil.java
  11. 23 1
      imcs-admin-boot/imcs-file-biz/src/main/java/com/github/zuihou/file/strategy/impl/AbstractFileStrategy.java

+ 2 - 2
imcs-admin-boot/imcs-authority-server/src/main/resources/application.yml

@@ -19,7 +19,7 @@ zuihou:
 #    username: root
 #    password: adminoyq
     ip: 127.0.0.1
-    username: admin
+    username: root
     password: adminoyq
     port: 3306
     driverClassName: com.mysql.cj.jdbc.Driver
@@ -56,7 +56,7 @@ zuihou:
     order: -20
   file:
     type: LOCAL # FAST_DFS LOCAL
-    storage-path: C:/data/projects/uploadfile/file/     # 文件存储路径  ( 某些版本的 window 需要改成  D:\\data\\projects\\uploadfile\\file\\  )
+    storage-path: C:/data/projects/uploadfile/file/  # 文件存储路径  ( 某些版本的 window 需要改成  D:\\data\\projects\\uploadfile\\file\\  )
     uriPrefix:  http://${zuihou.nginx.ip}:${zuihou.nginx.port}/file/   # 文件访问 需要通过这个uri前缀进行访问
     inner-uri-prefix: null  #  内网的url前缀
     down-by-id: http://${zuihou.nginx.ip}:${zuihou.nginx.port}/api/file/attachment/download?ids[]=%s

Fișier diff suprimat deoarece este prea mare
+ 240 - 246
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/mq/TaskWorkNode.java


+ 2 - 0
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/operationManagementCenter/dao/TaskNodeMapper.java

@@ -35,4 +35,6 @@ public interface TaskNodeMapper extends SuperMapper<TaskNode> {
     int selectCurrentProduceSort(Map param);
 
     R<List<TaskNode>> getResourceStorge(Map map);
+
+    List<TaskNode> getWorkflowDetail(@Param("completeBatchNo") String completeBatchNo);
 }

+ 2 - 0
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/operationManagementCenter/service/TaskNodeService.java

@@ -174,4 +174,6 @@ public interface TaskNodeService extends SuperService<TaskNode> {
     R<List<TaskNode>> getResourceStorge(Map<String, Object> map);
 
     void test();
+
+    List<TaskNode> getWorkflowDetail(String completeBatchNo);
 }

+ 4 - 1
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/operationManagementCenter/service/impl/OrderServiceImpl.java

@@ -1220,6 +1220,7 @@ public class OrderServiceImpl extends SuperServiceImpl<OrderMapper, Order> imple
         meterialReceiveLogService.saveOrUpdateBatch(meterialReceiveLogList);
 
         PlanProduct planProduct = planProductMapper.selectOne(Wraps.<PlanProduct>lbQ().eq(PlanProduct::getPlanId,model.getId()));
+        Long orderId = planProduct.getOrderId();
         int count =  planMapper.delete(Wraps.<Plan>lbQ().eq(Plan::getId,model.getId()));
         planProductMapper.delete(Wraps.<PlanProduct>lbQ().eq(PlanProduct::getPlanId,model.getId()));
         // 删除订单
@@ -1227,13 +1228,15 @@ public class OrderServiceImpl extends SuperServiceImpl<OrderMapper, Order> imple
         int remindOrderCount = orderProductService.count(Wraps.<OrderProduct>lbQ().eq(OrderProduct::getOrderId,planProduct.getOrderId()));
         if(remindOrderCount  == 0){
             // 删除order表数据
-            baseMapper.deleteById(planProduct.getOrderId());
+            baseMapper.deleteById(orderId);
         }
 
         // 删除工件信息
         workpieceMapper.delete(Wraps.<TWorkpiece>lbQ().eq(TWorkpiece::getPlanId,model.getId()));
         // 删除任务信息
         taskService.remove(Wraps.<TTask>lbQ().eq(TTask::getPlanId,model.getId()));
+        // 删除节点信息
+        taskNodeMapper.delete(Wraps.<TaskNode>lbQ().eq(TaskNode::getOrderId, orderId));
         return true;
 
     }

+ 5 - 0
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/operationManagementCenter/service/impl/TaskNodeServiceImpl.java

@@ -3333,4 +3333,9 @@ planId));
         }
         return taskNodeList;
     }
+
+    @Override
+    public List<TaskNode> getWorkflowDetail(String completeBatchNo) {
+        return baseMapper.getWorkflowDetail(completeBatchNo);
+    }
 }

+ 136 - 118
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/productionResourceCenter/service/impl/MachineNodeServiceImpl.java

@@ -106,7 +106,6 @@ public class MachineNodeServiceImpl implements NodeOperationService {
     @Autowired
     private WorkpieceMapper workpieceMapper;
 
-    private Map<String, Object> map = Maps.newHashMap();
 
     private Map<String, Object> queryMap = Maps.newHashMap();
 
@@ -154,9 +153,9 @@ public class MachineNodeServiceImpl implements NodeOperationService {
     public void initResource(TaskNode taskNode, TTask task, Map dataMap) {
         //获取当前设备模型
         String moduleName = dataMap.get("moduleName") == null ? "" : dataMap.get("moduleName").toString();
-        if(StringUtil.isNotEmpty(moduleName)) {
+        if (StringUtil.isNotEmpty(moduleName)) {
             Module module = moduleService.getOne(new LbqWrapper<Module>().eq(Module::getName, moduleName).eq(Module::getStatus, 1));
-            if(null != module){
+            if (null != module) {
                 deviceArr = new String[]{module.getNo()};
                 deviceList = productionresourcePositionService.getFreeProductionresourcePositionByNos(deviceArr);
             }
@@ -178,17 +177,18 @@ public class MachineNodeServiceImpl implements NodeOperationService {
         bomzZone = zoneService.getById(bomZzoneId);
 
         String paramKey = zZone.getNo() + "_plc";
-        instructionUrl = (null == msgUtil.redis_get(ParameterKey.PARAMETERS)? "": ((Map<String,String>)msgUtil.redis_get(ParameterKey.PARAMETERS)).get(paramKey).toString());
+        instructionUrl = (null == msgUtil.redis_get(ParameterKey.PARAMETERS) ? "" : ((Map<String, String>) msgUtil.redis_get(ParameterKey.PARAMETERS)).get(paramKey).toString());
         // TODO 后续删除代码,目前条用模拟接口
 //        if("framework".equals(zZone.getNo())){
 //            instructionUrl = instructionUrl.replace("8086","8083");
 //        }else{
-            instructionUrl = instructionUrl.replace("8081","8083");
+        instructionUrl = instructionUrl.replace("8081", "8083");
 //        }
     }
 
     @Override
     public Map checkCondition(TaskNode taskNode, TTask task, Map<String, Object> dataMap) {
+        Map<String, Object> map = Maps.newHashMap();
 //        //业务类型
 //        String bizType = dataMap.get("bizType") == null ? "" : dataMap.get("bizType").toString();
 //        //具体的搬运类型
@@ -211,7 +211,7 @@ public class MachineNodeServiceImpl implements NodeOperationService {
         String moduleName = dataMap.get("moduleName") == null ? "" : dataMap.get("moduleName").toString();
 
         //采集接口判断当前设备是否在线
-        if(!taskNodeService.getRunStatus(task.getResourceId())){
+        if (!taskNodeService.getRunStatus(task.getResourceId())) {
             map.put("result", false);
             map.put("msg", DictionaryKey.NodeException.RUNNING_FALSE);
             return map;
@@ -236,20 +236,20 @@ public class MachineNodeServiceImpl implements NodeOperationService {
 //        }
 
         //获取设备指令集合
-        List<ModuleInstruction> moduleInstructions = (List<ModuleInstruction>)dataMap.get("instructions");
+        List<ModuleInstruction> moduleInstructions = (List<ModuleInstruction>) dataMap.get("instructions");
 
         switch (moduleName.toLowerCase()) {
             case "打标机":
                 //执行打标程序
-                if("2".equals(functionType) && moduleInstructions.size() == 1){
-                    instructionUrl = instructionUrl.replace("8083","8081");
+                if ("2".equals(functionType) && moduleInstructions.size() == 1) {
+                    instructionUrl = instructionUrl.replace("8083", "8081");
                     //打标
 //                    map.put("zkIp", ZK_ip_rxx);
 //                    map.put(DemoLineConstant.DEMOLINE_BIZ_TYPE, "print");
                     //获取打标指令编码imcs_t_workpiece
                     map.put("method", moduleInstructions.get(0).getCode());
-                    map.put("url",plcInfo.get("url"));
-                    map.put("port",plcInfo.get("port"));
+                    map.put("url", plcInfo.get("url"));
+                    map.put("port", plcInfo.get("port"));
                     //获取打标唯一码
                     String unionCode = workpieceService.getUnionCode(task.getCompleteBatchNo());
 
@@ -277,40 +277,48 @@ public class MachineNodeServiceImpl implements NodeOperationService {
                 }
                 break;
             case "机床":
-                Productionresource productionresource =  productionresourceBizMapper.selectOne(Wraps.<Productionresource>lbQ().eq(Productionresource::getId,taskNode.getTargetResourceId()));
-                map.put("url",productionresource.getIp());
-                map.put("port",productionresource.getPort());
-                if ("1".equals(functionType)) {
-                     //程序文件上传
-                     List<BomProcedureProgram>procedureProgramList = bomProcedureProgramMapper.selectList(Wraps.<BomProcedureProgram>lbQ().eq(BomProcedureProgram::getProcedureId,task.getProcedureId()));
-
-                     List<Map<String, String>> fileList = new ArrayList<Map<String, String>>();
+                Productionresource productionresource = productionresourceBizMapper.selectOne(Wraps.<Productionresource>lbQ().eq(Productionresource::getId, taskNode.getTargetResourceId()));
+                map.put("url", productionresource.getIp());
+                map.put("port", productionresource.getPort());
+                if ("1".equals(functionType)) {// 目前只有西门子机床需要文件上传,启动程序,西门子通过给plc信号来启动
+                    //程序文件上传
+                    List<BomProcedureProgram> procedureProgramList = bomProcedureProgramMapper.selectList(Wraps.<BomProcedureProgram>lbQ().eq(BomProcedureProgram::getProcedureId, task.getProcedureId()));
+
+                    List<Map<String, String>> fileList = new ArrayList<Map<String, String>>();
                     if (procedureProgramList != null && procedureProgramList.size() > 0) {
+
                         //文件上传只允许单个文件
                         procedureProgramList.forEach(i -> {
                             Map<String, String> m = new HashMap<>();
                             String filePath = i.getFilePath().replace(uriPath, storagePath);
+                            String submittedFileName = i.getSubmittedFileName();
                             //m.put("fileName", filePath.replace("/", "\\"));
                             m.put("fileName", filePath);
+                            m.put("submittedFileName", submittedFileName);
                             fileList.add(m);
                         });
                         //map.put(DemoLineConstant.DEMOLINE_BIZ_TYPE, "uploadProgram");
                         map.put("method", "UploadFile");
                         JSONObject data = new JSONObject();
-                        data.put("fileName", fileList.get(0).get("fileName"));
-                        msgUtil.redis_set("UploadFile_Path"+"_"+task.getId(), uriPath+","+storagePath+","+fileList.get(0).get("fileName"), 1, TimeUnit.DAYS);
+                        //   C:/data/projects/uploadfile/file/0000/2025/07/CNC01.MPF
+                        //         /data/projects/uploadfile/
+                        String filepath = fileList.get(0).get("fileName"); //  C:/data/projects/uploadfile/CNC01.MPF
+                        filepath = filepath.split("/file")[0] + "/" + fileList.get(0).get("submittedFileName");//      C:/data/projects/uploadfile/
+
+                        data.put("fileName", filepath);
+                        msgUtil.redis_set("UploadFile_Path" + "_" + task.getId(), uriPath + "," + storagePath + "," + fileList.get(0).get("fileName"), 1, TimeUnit.DAYS);
                         //Module module  = moduleService.getOne(new LbqWrapper<Module>().eq(Module::getId, productionresource.getModuleId()));
                         TWorkpiece workpiece = workpieceService.getOne(new LbqWrapper<TWorkpiece>().eq(TWorkpiece::getCompleteBatchNo, task.getCompleteBatchNo()).last("limit 1"));
                         BBom bom = bBomMapper.selectById(workpiece.getBomId());
-                        data.put("remotePath", bom.getDrawingNo()+"\\OP"+bom.getNo());
+                        data.put("remotePath", bom.getDrawingNo() + "\\OP" + bom.getNo());
                         //msgUtil.redis_set(DemoCacheKey.DEMOLINE_PROGRAME_NAMES + task.getCompleteBatchNo(), fileName, 1, TimeUnit.DAYS);
-                        if(StringUtil.isNotEmpty(productionresource.getModeSpecification()) && productionresource.getModeSpecification().contains("HEIDENHAIN")){
+                        if (StringUtil.isNotEmpty(productionresource.getModeSpecification()) && productionresource.getModeSpecification().contains("HEIDENHAIN")) {
                             //缓存程序编号信息
                             JSONObject uploadInfo = new JSONObject();
-                            uploadInfo.put("url",  productionresource.getIp());
+                            uploadInfo.put("url", productionresource.getIp());
                             uploadInfo.put("port", productionresource.getPort());
                             uploadInfo.put("data", data);
-                            msgUtil.redis_set(DemoLineConstant.DEMOLINE_HEIDENHAIN_FILE_URL+"_"+task.getId(), uploadInfo.toJSONString(), 30, TimeUnit.DAYS);
+                            msgUtil.redis_set(DemoLineConstant.DEMOLINE_HEIDENHAIN_FILE_URL + "_" + task.getId(), uploadInfo.toJSONString(), 30, TimeUnit.DAYS);
                             data.put("fileName", "");
                         }
 
@@ -318,54 +326,52 @@ public class MachineNodeServiceImpl implements NodeOperationService {
                         map.put("data", data);
                         map.put("result", true);
                     }
-                }
-                else if ("2".equals(functionType)) {
+                } else if ("2".equals(functionType)) {
                     //执行加工程序,分多次执行
                     //String zoneNo = msgUtil.redis_get(DemoCacheKey.DEMOLINE_WORKOP_ZONE + task.getCompleteBatchNo()) == null ? ""
-                     //       : msgUtil.redis_get(DemoCacheKey.DEMOLINE_WORKOP_ZONE + task.getCompleteBatchNo()).toString();
+                    //       : msgUtil.redis_get(DemoCacheKey.DEMOLINE_WORKOP_ZONE + task.getCompleteBatchNo()).toString();
                     //map.put(DemoLineConstant.DEMOLINE_BIZ_TYPE, "execProgram");
                     //当前执行数量
                     //String fileName = msgUtil.redis_get(DemoCacheKey.DEMOLINE_PROGRAME_NAMES + task.getCompleteBatchNo()) == null ? "" : msgUtil.redis_get(DemoCacheKey.DEMOLINE_PROGRAME_NAMES + task.getCompleteBatchNo()).toString();
-                     List<BomProcedureProgram> procedureProgramList = bomProcedureProgramMapper.selectList(Wraps.<BomProcedureProgram>lbQ().eq(BomProcedureProgram::getProcedureId,task.getProcedureId()));
+                    List<BomProcedureProgram> procedureProgramList = bomProcedureProgramMapper.selectList(Wraps.<BomProcedureProgram>lbQ().eq(BomProcedureProgram::getProcedureId, task.getProcedureId()));
                     //执行程序默认按单文件处理
                     //String fileName = "";
                     //String fileNames[] = fileName.split(",");
                     JSONObject data = new JSONObject();
                     TWorkpiece workpiece = workpieceService.getOne(new LbqWrapper<TWorkpiece>().eq(TWorkpiece::getCompleteBatchNo, task.getCompleteBatchNo()).last("limit 1"));
                     BBom bom = bBomMapper.selectById(workpiece.getBomId());
-                    String remotePath = bom.getDrawingNo()+"\\OP"+bom.getNo();
-                    data.put("remotePath", remotePath+ "\\" +procedureProgramList.get(0).getSubmittedFileName());
+                    String remotePath = bom.getDrawingNo() + "\\OP" + bom.getNo();
+                    data.put("remotePath", remotePath + "\\" + procedureProgramList.get(0).getSubmittedFileName());
 
                     map.put("data", data);
                     map.put("method", "StartNCProgram");
                     map.put("result", true);
 
+                } else if ("3".equals(functionType)) {
+                    // 加工前写入工件坐标系 根据taskid查找工件三坐标测量的工件坐标系,可能存在装夹一次未果的情况,所以取最后一条数据
+                    // TODO 工件坐标系根据机场不同系统,不同通讯协议调用不同的接口
+                    OrderQuality orderQuality = orderQualityMapper.selectOne(Wraps.<OrderQuality>lbQ().eq(OrderQuality::getProcedureId, task.getProcedureId()).eq(OrderQuality::getWorkpieceId, task.getCompleteBatchNo()));
+                    if (null == orderQuality) {
+                        // 简单处理的方式,直接将坐标偏移全部设置成0
+                        queryMap.put("x", "0");
+                        queryMap.put("y", "0");
+                        queryMap.put("z", "0");
+                        queryMap.put("a", "0");
+                        queryMap.put("b", "0");
+                        queryMap.put("c", "0");
+                    } else {
+                        queryMap.put("x", String.valueOf(orderQuality.getSketchyXaxisOffset()));
+                        queryMap.put("y", String.valueOf(orderQuality.getSketchyYaxisOffset()));
+                        queryMap.put("z", String.valueOf(orderQuality.getSketchyZaxisOffset()));
+                        queryMap.put("a", String.valueOf(orderQuality.getSketchyAaxisOffset()));
+                        queryMap.put("b", String.valueOf(orderQuality.getSketchyBaxisOffset()));
+                        queryMap.put("c", String.valueOf(orderQuality.getSketchyCaxisOffset()));
+                    }
+
+                    map.put("method", "SendLinShift");
+                    map.put("data", queryMap);
+                    map.put("result", true);
                 }
-                else if ("3".equals(functionType)){
-                     // 加工前写入工件坐标系 根据taskid查找工件三坐标测量的工件坐标系,可能存在装夹一次未果的情况,所以取最后一条数据
-                     // TODO 工件坐标系根据机场不同系统,不同通讯协议调用不同的接口
-                     OrderQuality orderQuality = orderQualityMapper.selectOne(Wraps.<OrderQuality>lbQ().eq(OrderQuality::getProcedureId,task.getProcedureId()).eq(OrderQuality::getWorkpieceId,task.getCompleteBatchNo()));
-                     if(null == orderQuality){
-                         // 简单处理的方式,直接将坐标偏移全部设置成0
-                         queryMap.put("x", "0");
-                         queryMap.put("y", "0");
-                         queryMap.put("z", "0");
-                         queryMap.put("a", "0");
-                         queryMap.put("b", "0");
-                         queryMap.put("c", "0");
-                     }else{
-                         queryMap.put("x", String.valueOf(orderQuality.getSketchyXaxisOffset()));
-                         queryMap.put("y", String.valueOf(orderQuality.getSketchyYaxisOffset()));
-                         queryMap.put("z", String.valueOf(orderQuality.getSketchyZaxisOffset()));
-                         queryMap.put("a", String.valueOf(orderQuality.getSketchyAaxisOffset()));
-                         queryMap.put("b", String.valueOf(orderQuality.getSketchyBaxisOffset()));
-                         queryMap.put("c", String.valueOf(orderQuality.getSketchyCaxisOffset()));
-                     }
-
-                     map.put("method", "SendLinShift");
-                     map.put("data", queryMap);
-                     map.put("result", true);
-                 }
 
                 break;
             case "清洗烘干机":
@@ -376,56 +382,56 @@ public class MachineNodeServiceImpl implements NodeOperationService {
                     //map.put(DemoLineConstant.DEMOLINE_BIZ_TYPE, "Clean");
                     //获取打标指令编码
                     map.put("method", moduleInstructions.get(0).getCode());
-                    map.put("url",plcInfo.get("url"));
-                    map.put("port",plcInfo.get("port"));
+                    map.put("url", plcInfo.get("url"));
+                    map.put("port", plcInfo.get("port"));
                     map.put("result", true);
                     map.remove("data");
 //                    map.put("data", new HashMap<>());
-                }else if("4".equals(functionType)){
+                } else if ("4".equals(functionType)) {
                     map.put("method", moduleInstructions.get(0).getCode());
-                    map.put("url",plcInfo.get("url"));
-                    map.put("port",plcInfo.get("port"));
+                    map.put("url", plcInfo.get("url"));
+                    map.put("port", plcInfo.get("port"));
                     map.put("result", true);
-                    map.put("specialCallBackMyselfFlag",true);
+                    map.put("specialCallBackMyselfFlag", true);
                     map.remove("data");
                 }
                 break;
             case "清洗吹干机":
                 if ("2".equals(functionType) && moduleInstructions.size() == 1) {
                     map.put("method", moduleInstructions.get(0).getCode());
-                    map.put("url",plcInfo.get("url"));
-                    map.put("port",plcInfo.get("port"));
+                    map.put("url", plcInfo.get("url"));
+                    map.put("port", plcInfo.get("port"));
                     map.put("result", true);
                     map.remove("data");
-                }else if("4".equals(functionType)){
+                } else if ("4".equals(functionType)) {
                     //无清洗业务
                     map.put("method", moduleInstructions.get(0).getCode());
-                    map.put("url",plcInfo.get("url"));
-                    map.put("port",plcInfo.get("port"));
+                    map.put("url", plcInfo.get("url"));
+                    map.put("port", plcInfo.get("port"));
                     map.put("result", true);
-                    map.put("specialCallBackMyselfFlag",true);
+                    map.put("specialCallBackMyselfFlag", true);
                     map.remove("data");
                 }
                 break;
             case "三坐标检测仪":
                 //坐标检测类型判断
-                if ("2".equals(functionType) && moduleInstructions.size()==1) {
+                if ("2".equals(functionType) && moduleInstructions.size() == 1) {
                     //map.put("zkIp", ZK_ip_zlzx);
                     //map.put(DemoLineConstant.DEMOLINE_BIZ_TYPE, "testwork");
                     //查出工序三坐标相关
                     BomProcedure procedure = bomProcedureService.getById(task.getProcedureId());
                     JSONObject data = new JSONObject();
                     // 判断是工件坐标系还是质量测量
-                    if("1".equals(procedure.getThreeDimensionalConf())){
+                    if ("1".equals(procedure.getThreeDimensionalConf())) {
                         /*data.put("workId", task.getCompleteBatchNo() + "-" + task.getProcedureNo());*/
                         //data.put("workId", task.getCompleteBatchNo() + "_" + taskNode.getId());
                         data.put("workId", taskNode.getCompleteBatchNo());
-                        data.put("procedureNo",task.getProcedureNo());
+                        data.put("procedureNo", task.getProcedureNo());
                         /*data.put("workType", procedure.getThreeDimensionalPrograme());*/
                         data.put("workProgramName", procedure.getThreeDimensionalPrograme());
                         String location = DictionaryKey.ZEISS_LOCATION.get("M");
                         //data.put("stationId","M");
-                        data.put("location",location);
+                        data.put("location", location);
                         // begin modify by yejian on 20220507 for 更新tasknode表中nodetype,方便三坐标测量完成后回调后快速查找测量结果
                         taskNode.setNodeType("3");
                         taskNodeService.updateById(taskNode);
@@ -433,6 +439,7 @@ public class MachineNodeServiceImpl implements NodeOperationService {
                         String programPath = filePath + "/ProgramName/name.txt";
                         List<String> content = SmbShareFileUtil.readShareFileContent(programPath, userName, password, fileIp);
                         //List<String> content = Stream.of("0").collect(Collectors.toList());
+
                         if(content.size()>0 && content.get(0).equals("0")){
                             String programName = procedure.getThreeDimensionalPrograme();
                             SmbShareFileUtil.writeShareFileContent(programPath, Stream.of(programName).collect(Collectors.toList()), userName, password, fileIp );
@@ -441,7 +448,7 @@ public class MachineNodeServiceImpl implements NodeOperationService {
                             return map;
                         }
                     }
-                    if("1".equals(procedure.getThreeDimensionalDeviationConf())){
+                    if ("1".equals(procedure.getThreeDimensionalDeviationConf())) {
                         data.put("workId", task.getCompleteBatchNo() + "-" + task.getProcedureNo());
                         data.put("workType", procedure.getThreeDimensionalDeviationPrograme());
                         // begin modify by yejian on 20220928 for 更新tasknode表中nodetype,方便三坐标工件坐标系测量后更新坐标系偏移量表
@@ -453,8 +460,8 @@ public class MachineNodeServiceImpl implements NodeOperationService {
 
                     //map.put("data", JSONObject.toJSONString(queryMap));
                     map.put("method", moduleInstructions.get(0).getCode());
-                    map.put("url",plcInfo.get("url"));
-                    map.put("port",plcInfo.get("port"));
+                    map.put("url", plcInfo.get("url"));
+                    map.put("port", plcInfo.get("port"));
                     map.put("data", data);
                     map.put("result", true);
                 }
@@ -467,19 +474,29 @@ public class MachineNodeServiceImpl implements NodeOperationService {
 
     @Override
     public Map operation(JSONObject jsonObject, JSONObject bizJsonObject, Map<String, Object> conMap) {
-            //获取节点指令操作名称
-            String method =  conMap.get("method").toString();
-            String hostSyetemUrl = "http://20.20.47.108:8090/";
-            switch(method){
-                case "execProgram": hostSyetemUrl = hostSyetemUrl + "/api/StartNCProgram"; break;
-                case "clean": hostSyetemUrl = hostSyetemUrl + "/api/StartCleanMachine"; break;
-                case "dry": hostSyetemUrl = hostSyetemUrl + "/api/StartDryMachine"; break;
-                case "print": hostSyetemUrl = hostSyetemUrl + "/api/StartLabelMachine"; break;
-                case "measuring":  hostSyetemUrl = hostSyetemUrl + "/api/StartCoordinateMeasuringMachine";break;
+        //获取节点指令操作名称
+        String method = conMap.get("method").toString();
+        String hostSyetemUrl = "http://20.20.47.108:8090/";
+        switch (method) {
+            case "execProgram":
+                hostSyetemUrl = hostSyetemUrl + "/api/StartNCProgram";
+                break;
+            case "clean":
+                hostSyetemUrl = hostSyetemUrl + "/api/StartCleanMachine";
+                break;
+            case "dry":
+                hostSyetemUrl = hostSyetemUrl + "/api/StartDryMachine";
+                break;
+            case "print":
+                hostSyetemUrl = hostSyetemUrl + "/api/StartLabelMachine";
+                break;
+            case "measuring":
+                hostSyetemUrl = hostSyetemUrl + "/api/StartCoordinateMeasuringMachine";
+                break;
 
-            }
-            conMap.put("instructionUrl", hostSyetemUrl);
-            return conMap;
+        }
+        conMap.put("instructionUrl", hostSyetemUrl);
+        return conMap;
     }
 
     @Override
@@ -488,42 +505,43 @@ public class MachineNodeServiceImpl implements NodeOperationService {
     }
 
     /**
-     *  设备动态逻辑判断处理
+     * 设备动态逻辑判断处理
      *
      * @param deviceList
      * @param useXbk
      * @return
      */
-    private ProductionresourcePosition logical(List<ProductionresourcePosition> deviceList, boolean useXbk){
-        //设备不存在
-        if(deviceList == null || deviceList.size() == 0){
-            map.put("msg", DictionaryKey.NodeException.NO_RESOURCE);
-            return null;
-        }
-        //资源临界判断
-        int current_running_num = storgeService.getstorgeByZone(zone_id.toString());
-        if(current_running_num == DictionaryKey.RESOURCE_MAX_NUM){
-            map.put("msg", DictionaryKey.NodeException.NO_RESOURCE);
-            return null;
-        }
-
-        deviceList = deviceList.stream().filter(position->position.getStatus()=="1" && position.getLockStatus()=="1").collect(Collectors.toList());
-        //设备被锁定
-        if(deviceList.size() == 0) {
-            if(useXbk){
-                if(xbkList.size() == 0){
-                    map.put("msg", DictionaryKey.NodeException.RESOURCE_LOCK);
-                    return null;
-                }
-                map.put("useXbk", true);
-                return xbkList.get(0);
-            }
-            map.put("msg", DictionaryKey.NodeException.RESOURCE_LOCK);
-            return null;
-        }
-        //设备托盘、夹具条件不满足  待定
-
-        return deviceList.get(0);
+    private ProductionresourcePosition logical(List<ProductionresourcePosition> deviceList, boolean useXbk) {
+//        //设备不存在
+//        if (deviceList == null || deviceList.size() == 0) {
+//            map.put("msg", DictionaryKey.NodeException.NO_RESOURCE);
+//            return null;
+//        }
+//        //资源临界判断
+//        int current_running_num = storgeService.getstorgeByZone(zone_id.toString());
+//        if (current_running_num == DictionaryKey.RESOURCE_MAX_NUM) {
+//            map.put("msg", DictionaryKey.NodeException.NO_RESOURCE);
+//            return null;
+//        }
+//
+//        deviceList = deviceList.stream().filter(position -> position.getStatus() == "1" && position.getLockStatus() == "1").collect(Collectors.toList());
+//        //设备被锁定
+//        if (deviceList.size() == 0) {
+//            if (useXbk) {
+//                if (xbkList.size() == 0) {
+//                    map.put("msg", DictionaryKey.NodeException.RESOURCE_LOCK);
+//                    return null;
+//                }
+//                map.put("useXbk", true);
+//                return xbkList.get(0);
+//            }
+//            map.put("msg", DictionaryKey.NodeException.RESOURCE_LOCK);
+//            return null;
+//        }
+//        //设备托盘、夹具条件不满足  待定
+//
+//        return deviceList.get(0);
+        return null ;
     }
 
 }

+ 60 - 0
imcs-admin-boot/imcs-business-biz/src/main/resources/mapper_business/base/operationManagementCenter/TaskNodeMapper.xml

@@ -115,4 +115,64 @@
              and n.resource_id = #{resourceId}
           </if>
     </select>
+
+    <select id="getWorkflowDetail" resultType="map">
+        SELECT
+        itw.part_prority,
+        itt.expect_start_time,
+        ittn.start_time,
+        itt.task_no,
+        itt.expect_end_time,
+        ittn.end_time,
+        (SELECT
+        ibb.name
+        FROM imcs_b_bom ibb
+        WHERE ibb.id = itt.bom_id) AS bomName,
+        ittn.procedure_id,
+        itt.procedure_no,
+        itt.resource_id,
+        ittn.task_id,
+        ittn.id,
+        ittn.interface_type,
+        ittn.exe_status,
+        ittn.exe_result,
+        ittn.resource_id,
+        (SELECT itp.name
+        FROM imcs_tenant_productionresource itp
+        WHERE itp.id = ittn.resource_id) AS ResourceName,
+        ittn.target_resource_id,
+        (SELECT
+        itp.name
+        FROM imcs_tenant_productionresource itp
+        WHERE itp.id = ittn.target_resource_id) AS targetResourceName,
+        ittn.node_name,
+        ittn.complete_batch_no,
+        ittn.complete_batch_sort,
+        ittn.find_agv_flag,
+        itt.resource_business_id,
+        (SELECT
+        ippp.point_id
+        FROM imcs_p_productionresource_position ippp
+        WHERE ippp.storge_id = itw.storge_id) AS point_id,
+        (SELECT
+        itp.name
+        FROM imcs_tenant_productionresource itp
+        WHERE itp.id = (SELECT
+        ippp.resource_id
+        FROM imcs_p_productionresource_position ippp
+        WHERE ippp.storge_id = itw.storge_id)),
+        (SELECT ira.command FROM imcs_resource_autocode ira WHERE ira.id = ittn.auto_node_id) AS command,
+        ittn.node_type
+        FROM imcs_t_task itt,
+        imcs_t_task_node ittn,
+        imcs_t_workpiece itw
+
+        WHERE itt.id = ittn.task_id
+        AND itt.complete_batch_no = itw.complete_batch_no
+        <if test="completeBatchNo != '' and completeBatchNo != null " >
+            AND ittn.complete_batch_no = #{completeBatchNo}
+        </if>
+        ORDER BY ittn.complete_batch_no, ittn.complete_batch_sort
+    </select>
+
 </mapper>

+ 186 - 0
imcs-admin-boot/imcs-business-controller/src/main/java/com/github/zuihou/business/controller/operationManagementCenter/ToolQueryController.java

@@ -0,0 +1,186 @@
+package com.github.zuihou.business.controller.operationManagementCenter;
+
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.date.DateUnit;
+import cn.hutool.core.util.ObjectUtil;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson.support.spring.GenericFastJsonRedisSerializer;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.github.zuihou.authority.service.common.ParameterService;
+import com.github.zuihou.base.R;
+import com.github.zuihou.base.request.PageParams;
+import com.github.zuihou.business.DemoLine.YunjianConstant;
+import com.github.zuihou.business.edgeLibrary.entity.StockInfo;
+import com.github.zuihou.business.edgeLibrary.entity.Storge;
+import com.github.zuihou.business.edgeLibrary.service.StockInfoService;
+import com.github.zuihou.business.edgeLibrary.service.StorgeService;
+import com.github.zuihou.business.externalApi.service.AgvHikOrderInfoService;
+import com.github.zuihou.business.operationManagementCenter.dto.PlanPageDTO;
+import com.github.zuihou.business.operationManagementCenter.dto.TTaskPageDTO;
+import com.github.zuihou.business.operationManagementCenter.entity.*;
+import com.github.zuihou.business.operationManagementCenter.service.TaskNodeService;
+import com.github.zuihou.business.operationManagementCenter.service.TaskService;
+import com.github.zuihou.business.operationManagementCenter.service.WorkpieceService;
+import com.github.zuihou.business.productionResourceCenter.dao.ProductionresourceBizMapper;
+import com.github.zuihou.business.productionResourceCenter.entity.Productionresource;
+import com.github.zuihou.business.productionResourceCenter.service.ProductionresourcePositionService;
+import com.github.zuihou.business.productionResourceCenter.service.ZZoneService;
+import com.github.zuihou.business.util.DynamicRabbitMq;
+import com.github.zuihou.business.util.MsgUtil;
+import com.github.zuihou.common.constant.ParameterKey;
+import com.github.zuihou.common.util.DateUtil;
+import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
+import com.github.zuihou.log.annotation.SysLog;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang.time.DateUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.ListOperations;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.client.RestTemplate;
+
+import javax.annotation.Resource;
+import java.util.*;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
+
+/**
+ * <p>
+ * 前端控制器
+ * 工具查询表
+ * </p>
+ *
+ * @author imcs
+ * @date 2023-12-29
+ */
+@Slf4j
+@Validated
+@RestController
+@RequestMapping("/toolQuery")
+@Api(value = "toolQuery", tags = "工具查询表盘")
+@SysLog(enabled = true)
+public class ToolQueryController {
+
+    @Autowired
+    private StockInfoService stockInfoService;
+    @Autowired
+    private StorgeService storgeService;
+    @Autowired
+    private MsgUtil msgUtil;
+    @Autowired
+    private TaskNodeService taskNodeService;
+    @Autowired
+    private ProductionresourceBizMapper productionresourceBizMapper;
+    @Autowired
+    private ZZoneService zoneService;
+    @Autowired
+    private ProductionresourcePositionService productionresourcePositionService;
+    @Autowired
+    private WorkpieceService workpieceService;
+    @Autowired
+    private TaskService taskService;
+    @Autowired
+    private DynamicRabbitMq dynamicRabbitMq;
+    @Resource
+    private RedisTemplate<String,String> redisTemplate;
+    @Autowired
+    private PlanController planController;
+
+    @ApiOperation(value = "查询业务节点状态", notes = "查询业务节点状态")
+    @PostMapping("/getBizStatusList")
+    public R getBizStatusList(@RequestBody Map<String, String> data) {
+        int timeSpan = data.containsKey("timeSpan")? Integer.parseInt(data.get("timeSpan")) : 2;
+        List<TaskNode> statusList = taskNodeService.list(new LambdaQueryWrapper<TaskNode>().eq(TaskNode::getNodeType, "0").in(TaskNode::getExeStatus, new String[]{"2","4","5"}).le(TaskNode::getStartTime, DateUtils.addDays(new Date(),(-1)*timeSpan)));
+        Map map = new HashMap();
+        map.put("data", statusList);
+        return R.success(map);
+    }
+
+    @ApiOperation(value = "查询节点回调数据", notes = "查询节点回调数据")
+    @PostMapping("/getCacheCallbackList")
+    public R getCacheCallbackList(@RequestBody Map<String, String> data) {
+        Map map = new HashMap();
+        String hostSystemUrl = (null == msgUtil.redis_get(ParameterKey.PARAMETERS) ? "" : ((Map<String, String>) msgUtil.redis_get(ParameterKey.PARAMETERS)).get(ParameterKey.HOSTSYSTEMURL).toString());
+        if (StringUtils.isEmpty(hostSystemUrl)) return R.fail("Redis缓存数据不存在");
+        String instructionUrl = "/api/GetCallbackList";
+        JSONObject jsonParam = new JSONObject();
+        jsonParam.put("state", "1");
+        String callbackTaskList = msgUtil.httpForPost(hostSystemUrl + instructionUrl, jsonParam.toJSONString());
+        if (null == callbackTaskList || callbackTaskList.contains("imcsTOccsEnable")) return R.fail("CCS数据调用失败");
+
+        JSONArray jsonArray = JSON.parseArray(callbackTaskList);
+        List<Map> mapList = JSONObject.parseArray(jsonArray.toJSONString(), Map.class);
+        map.put("data", mapList);
+        return R.success(map);
+    }
+
+    @ApiOperation(value = "查询点库位锁定状态", notes = "查询点库位锁定状态")
+    @PostMapping("/getStorgeLockList")
+    public R getStorgeLockList(@RequestBody Map<String, String> data) {
+        List<Storge> storgeList = storgeService.list(new LambdaQueryWrapper<Storge>().eq(Storge::getLockStatus, "0").eq(Storge::getStatus,"1"));
+        Map map = new HashMap();
+        map.put("data", storgeList);
+        return R.success(map);
+    }
+
+    @ApiOperation(value = "查询不在线设备", notes = "查询不在线设备")
+    @PostMapping("/getOfflineList")
+    public R getOfflineList(@RequestBody Map<String, String> data) {
+        List<Productionresource> productionresourcesList = productionresourceBizMapper.selectList(new LambdaQueryWrapper<Productionresource>().eq(Productionresource::getStatus, "0").or().eq(Productionresource::getOnlineStatus, "0").isNotNull(Productionresource::getIp));
+        Map map = new HashMap();
+        map.put("data", productionresourcesList);
+        return R.success(map);
+    }
+
+    @ApiOperation(value = "查询缓存关键字", notes = "查询缓存关键字")
+    @PostMapping("/getCacheKeyList")
+    public R getCacheKeyList(@RequestBody Map<String, String> data) {
+        Map map = new HashMap();
+        map.put(YunjianConstant.YUNJIAN_SHEDULE_FLAG, (null != msgUtil.redis_get(YunjianConstant.YUNJIAN_SHEDULE_FLAG)? 1:0));
+        map.put("PRIORITY_LOCK", (null != msgUtil.redis_get("PRIORITY_LOCK"))? 1:0);
+
+        return R.success(map);
+    }
+
+    @ApiOperation(value = "查询零件流程", notes = "查询零件流程")
+    @PostMapping("/getWorkflowList")
+    public R getWorkflowList(@RequestBody Map<String, String> data) {
+        Map map = new HashMap();
+        String completeBatchNo = data.containsKey("completeBatchNo")? data.get("completeBatchNo").toString() : null;
+        if(StringUtils.isEmpty(completeBatchNo)) return R.fail("传参为空");
+        IPage<TTask> page = taskService.pageList(new PageParams<TTaskPageDTO>().buildPage(),null, new LbqWrapper<TTask>().eq(TTask::getCompleteBatchNo, completeBatchNo).ne(TTask::getStatus,"3"));
+        TTask task = page.getRecords().size()>0? page.getRecords().get(0): null;
+        TaskNode taskNode = taskNodeService.getOne(new LambdaQueryWrapper<TaskNode>().eq(TaskNode::getCompleteBatchNo, completeBatchNo).ne(TaskNode::getExeStatus,"3").last("limit 1"));
+        if(null==task || null==taskNode) return R.fail("任务或任务节点已执行完成");
+        map.put("task", task);
+        map.put("taskNode", taskNode);
+        return R.success(map);
+    }
+
+    @ApiOperation(value = "查询零件流程详情", notes = "查询零件流程详情")
+    @PostMapping("/getWorkflowDetail")
+    public R getWorkflowDetail(@RequestBody Map<String, String> data) {
+        Map map = new HashMap();
+        String completeBatchNo = data.containsKey("completeBatchNo")? data.get("completeBatchNo").toString() : null;
+        if(StringUtils.isEmpty(completeBatchNo)) return R.fail("传参为空");
+        List<TaskNode> dataList = taskNodeService.getWorkflowDetail(completeBatchNo);
+        map.put("data", dataList);
+        return R.success(map);
+    }
+
+}

+ 135 - 93
imcs-admin-boot/imcs-common/src/main/java/com/github/zuihou/common/util/SmbShareFileUtil.java

@@ -15,70 +15,105 @@ import java.util.stream.Stream;
 public class SmbShareFileUtil {
     /**
      * 将文件内容写入远程共享文件目录
-     * @param shareFile 共享文件路径
+     *
+     * @param shareFile    共享文件路径
      * @param fileContents 写入内容
      */
-    public static boolean writeShareFileContent(String shareFile, List<String> fileContents,String userName,String password,String fileIp){
-        NtlmPasswordAuthentication auth =new NtlmPasswordAuthentication(fileIp, userName, password);
+    public static boolean writeShareFileContent(String shareFile, List<String> fileContents, String userName, String password, String fileIp) {
+        NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(fileIp, userName, password);
         Boolean writeFlag = false;
-        OutputStream out = null ;
+        OutputStream out = null;
         BufferedWriter bufferedWriter = null;
+
         try{
             SmbFile smbFile = new SmbFile(shareFile, auth);
             out = new BufferedOutputStream(new SmbFileOutputStream(smbFile));
             bufferedWriter = new BufferedWriter(new OutputStreamWriter(out));
             // 按行写入文件
-            for(int i = 0; i < fileContents.size(); i++){
+            for (int i = 0; i < fileContents.size(); i++) {
                 bufferedWriter.write(fileContents.get(i));
             }
             bufferedWriter.flush();
-            writeFlag =  true;
-        }catch (Exception e){
+            writeFlag = true;
+        } catch (Exception e) {
             e.printStackTrace();
-        }finally {
-            try{
-                if(null != bufferedWriter){
+        } finally {
+            try {
+                if (null != bufferedWriter) {
 
                     bufferedWriter.close();
                 }
-            }catch (Exception e){
+            } catch (Exception e) {
+            }
+        }
+        return writeFlag;
+    }
+
+
+    /**
+     * 将文件内容以字节数组形式写入远程共享文件目录
+     *
+     * @param shareFile
+     * @param content
+     * @param userName
+     * @param password
+     * @param fileIp
+     * @return
+     */
+    public static boolean writeShareFileContent(String shareFile, byte[] content, String userName, String password, String fileIp) {
+        NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(fileIp, userName, password);
+        Boolean writeFlag = false;
+        BufferedOutputStream bos = null;
+        try {
+            bos = new BufferedOutputStream(new SmbFileOutputStream(new SmbFile(shareFile, auth)));
+            bos.write(content);
+            writeFlag = true;
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                if (null != bos) {
+                    bos.close();
+                }
+            } catch (Exception e) {
             }
         }
         return writeFlag;
     }
 
+
     /**
      * 将远程文件内容读取到本都
+     *
      * @param shareFile 共享文件路径
      * @return
      */
-    public static List<String> readShareFileContent(String shareFile,String userName,String password,String fileIp){
+    public static List<String> readShareFileContent(String shareFile, String userName, String password, String fileIp) {
         List<String> shareFileContents = new ArrayList<String>();
-        InputStream in = null ;
+        InputStream in = null;
         BufferedReader bufferedReader = null;
-        NtlmPasswordAuthentication auth =new NtlmPasswordAuthentication(fileIp, userName, password);
-        try{
-            in = new BufferedInputStream(new SmbFileInputStream(new SmbFile(shareFile,auth )));
+        NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(fileIp, userName, password);
+        try {
+            in = new BufferedInputStream(new SmbFileInputStream(new SmbFile(shareFile, auth)));
             bufferedReader = new BufferedReader(new InputStreamReader(in));
             // 按行读取订单结果文件
             String str = null;
-            while((str = bufferedReader.readLine()) != null)
-            {
+            while ((str = bufferedReader.readLine()) != null) {
                 System.out.println(str);
                 shareFileContents.add(str);
             }
 
-        }catch(Exception e){
+        } catch (Exception e) {
             e.printStackTrace();
-        }finally {
-            try{
-                if(null != in){
+        } finally {
+            try {
+                if (null != in) {
                     in.close();
                 }
-                if(null != bufferedReader){
+                if (null != bufferedReader) {
                     bufferedReader.close();
                 }
-            }catch (Exception e){
+            } catch (Exception e) {
                 e.printStackTrace();
             }
 
@@ -89,36 +124,37 @@ public class SmbShareFileUtil {
 
     /**
      * 将远程文件内容读取到本都
+     *
      * @param shareFile 共享文件路径
      * @return
      */
-    public static boolean downLoadShareFileContent(String downLoadpath,SmbFile shareFile){
+    public static boolean downLoadShareFileContent(String downLoadpath, SmbFile shareFile) {
         boolean downloadFlag = false;
-        InputStream in = null ;
+        InputStream in = null;
         FileOutputStream os = null;
-        try{
+        try {
             File downLoadFile = new File(downLoadpath);
             int length = shareFile.getContentLength();// 得到文件的大小
             in = new SmbFileInputStream(shareFile);
             os = new FileOutputStream(downLoadFile);
-            int len =0;
+            int len = 0;
             byte[] bytes = new byte[1024];
-            while( (len=in.read(bytes)) > 0){
-                os.write(bytes,0,len);
+            while ((len = in.read(bytes)) > 0) {
+                os.write(bytes, 0, len);
             }
             os.flush();
             downloadFlag = true;
-        }catch(Exception e){
+        } catch (Exception e) {
             e.printStackTrace();
-        }finally {
-            try{
-                if(null != os){
+        } finally {
+            try {
+                if (null != os) {
                     os.close();
                 }
-                if(null != in){
+                if (null != in) {
                     in.close();
                 }
-            }catch (Exception e){
+            } catch (Exception e) {
                 e.printStackTrace();
             }
 
@@ -129,41 +165,42 @@ public class SmbShareFileUtil {
 
     /**
      * 将远程文件内容读取到本都
+     *
      * @param shareFile 共享文件路径
      * @return
      */
-    public static boolean downLoadShareFileContent(String downLoadpath,String shareFile,String userName,String password,String ip){
+    public static boolean downLoadShareFileContent(String downLoadpath, String shareFile, String userName, String password, String ip) {
         boolean downloadFlag = false;
-        InputStream in = null ;
+        InputStream in = null;
         FileOutputStream os = null;
-        try{
-            NtlmPasswordAuthentication auth =new NtlmPasswordAuthentication(ip, userName, password);
-            SmbFile smbFile = new SmbFile(shareFile,auth);
+        try {
+            NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(ip, userName, password);
+            SmbFile smbFile = new SmbFile(shareFile, auth);
             smbFile.connect();
-            if(smbFile.exists()){
+            if (smbFile.exists()) {
                 File downLoadFile = new File(downLoadpath);
                 int length = smbFile.getContentLength();// 得到文件的大小
                 in = new SmbFileInputStream(shareFile);
                 os = new FileOutputStream(downLoadFile);
-                int len =0;
+                int len = 0;
                 byte[] bytes = new byte[1024];
-                while( (len=in.read(bytes)) > 0){
-                    os.write(bytes,0,len);
+                while ((len = in.read(bytes)) > 0) {
+                    os.write(bytes, 0, len);
                 }
                 os.flush();
                 downloadFlag = true;
             }
-        }catch(Exception e){
+        } catch (Exception e) {
             e.printStackTrace();
-        }finally {
-            try{
-                if(null != os){
+        } finally {
+            try {
+                if (null != os) {
                     os.close();
                 }
-                if(null != in){
+                if (null != in) {
                     in.close();
                 }
-            }catch (Exception e){
+            } catch (Exception e) {
                 e.printStackTrace();
             }
 
@@ -174,25 +211,26 @@ public class SmbShareFileUtil {
 
     /**
      * 遍历远程访问文件夹
+     *
      * @param remotePath
      * @return 返回完整路径文件列表
      */
-    public static List<String> iteratorShareFolder(String remotePath){
+    public static List<String> iteratorShareFolder(String remotePath) {
         List<String> shareFiles = new ArrayList<String>();
         SmbFile shareRemoteFolder = null;
-        try{
+        try {
             // 验证连接远程共享文件夹
             shareRemoteFolder = new SmbFile(remotePath);
-            if(shareRemoteFolder.exists() && shareRemoteFolder.isDirectory()){
+            if (shareRemoteFolder.exists() && shareRemoteFolder.isDirectory()) {
                 String[] filelist = shareRemoteFolder.list();
 
-                for(int i=0;i<filelist.length;i++){//对这个案件目录下的文件进行遍历
+                for (int i = 0; i < filelist.length; i++) {//对这个案件目录下的文件进行遍历
                     String fileAddress = remotePath + filelist[i];
                     shareFiles.add(fileAddress);
                 }
             }
 
-        }catch (Exception e){
+        } catch (Exception e) {
             e.printStackTrace();
         }
 
@@ -201,42 +239,42 @@ public class SmbShareFileUtil {
 
     /**
      * 遍历远程访问文件夹
+     *
      * @param remotePath
      * @return map 文件名和后缀的map对象
      */
-    public static Map<String,String> iteratorShareFolderFiles(String remotePath){
+    public static Map<String, String> iteratorShareFolderFiles(String remotePath) {
 
-        Map<String,String> shareFiles = new HashMap<String,String>();
+        Map<String, String> shareFiles = new HashMap<String, String>();
         SmbFile shareRemoteFolder = null;
-        try{
+        try {
             shareRemoteFolder = new SmbFile(remotePath);
-            if(shareRemoteFolder.exists()){
+            if (shareRemoteFolder.exists()) {
                 String[] filelist = shareRemoteFolder.list();
 
-                for(int i=0;i<filelist.length;i++){//对这个案件目录下的文件进行遍历
+                for (int i = 0; i < filelist.length; i++) {//对这个案件目录下的文件进行遍历
                     String fileName = filelist[i];
                     String[] files = fileName.split("\\.");
-                    shareFiles.put(files[0],files[1]);
+                    shareFiles.put(files[0], files[1]);
                 }
             }
-        }catch (Exception e){
+        } catch (Exception e) {
             e.printStackTrace();
         }
         return shareFiles;
     }
 
     /**
-     *
      * @param shareFile
      * @return
      */
-    public static Boolean deleteShareFile(String shareFile){
+    public static Boolean deleteShareFile(String shareFile) {
         SmbFile file = null;
-        try{
+        try {
             file = new SmbFile(shareFile);
             file.delete();
             return true;
-        }catch (Exception e){
+        } catch (Exception e) {
             e.printStackTrace();
             return false;
         }
@@ -244,19 +282,20 @@ public class SmbShareFileUtil {
 
     /**
      * 查找遍历三坐标测量结果
+     *
      * @return
      */
-    public static String findMeasuringFiles(String ip, String userName, String password, String url, String findFileName){
-        NtlmPasswordAuthentication auth =new NtlmPasswordAuthentication(ip, userName, password);
+    public static String findMeasuringFiles(String ip, String userName, String password, String url, String findFileName) {
+        NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(ip, userName, password);
         String returnFileName = "";
         SmbFile file = null;
         try {
-            file = new SmbFile(url,auth);
+            file = new SmbFile(url, auth);
             file.connect();
-            if(file.exists()){
+            if (file.exists()) {
                 SmbFile[] files = file.listFiles();
-                for(SmbFile f : files){
-                    if(f.getName().contains(findFileName)){
+                for (SmbFile f : files) {
+                    if (f.getName().contains(findFileName)) {
                         returnFileName = f.getName();
                         break;
                     }
@@ -271,22 +310,23 @@ public class SmbShareFileUtil {
 
     /**
      * 查找遍历三坐标测量结果
+     *
      * @return
      */
-    public static String findMeasuringFilesAndDownload(String ip, String userName, String password, String url, String findFileName, String dowmLoadPath){
-        NtlmPasswordAuthentication auth =new NtlmPasswordAuthentication(ip, userName, password);
+    public static String findMeasuringFilesAndDownload(String ip, String userName, String password, String url, String findFileName, String dowmLoadPath) {
+        NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(ip, userName, password);
         SmbFile file = null;
         boolean downloadFlag = false;
         String downloadFileName = "";
         try {
-            file = new SmbFile(url,auth);
+            file = new SmbFile(url, auth);
             file.connect();
-            if(file.exists()){
+            if (file.exists()) {
                 SmbFile[] files = file.listFiles();
-                for(SmbFile f : files){
-                    if(f.getName().contains(findFileName)){
-                        downloadFlag = downLoadShareFileContent(dowmLoadPath+f.getName(),f);
-                        if(downloadFlag){
+                for (SmbFile f : files) {
+                    if (f.getName().contains(findFileName)) {
+                        downloadFlag = downLoadShareFileContent(dowmLoadPath + f.getName(), f);
+                        if (downloadFlag) {
                             downloadFileName = f.getName();
                         }
                         break;
@@ -301,18 +341,19 @@ public class SmbShareFileUtil {
 
     /**
      * 在共享文件夹下面创建目录
+     *
      * @param ip
      * @param name
      * @param password
      * @param url
      */
-    private void createFolder(String ip, String name, String password, String url, String folderName){
-        NtlmPasswordAuthentication auth =new NtlmPasswordAuthentication(ip, name, password);
+    private void createFolder(String ip, String name, String password, String url, String folderName) {
+        NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(ip, name, password);
         SmbFile file = null;
         try {
-            file = new SmbFile(url+folderName,auth);
+            file = new SmbFile(url + folderName, auth);
             file.connect();
-            if(!file.exists()){
+            if (!file.exists()) {
                 file.mkdir();
             }
         } catch (Exception e) {
@@ -322,26 +363,27 @@ public class SmbShareFileUtil {
 
     /**
      * 查找遍历三坐标测量最新检测结果
+     *
      * @return
      */
-    public static String findNewMeasuringFiles(String ip, String userName, String password, String url){
-        NtlmPasswordAuthentication auth =new NtlmPasswordAuthentication(ip, userName, password);
+    public static String findNewMeasuringFiles(String ip, String userName, String password, String url) {
+        NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(ip, userName, password);
         String returnFileName = "";
         SmbFile file = null;
         try {
-            file = new SmbFile(url,auth);
+            file = new SmbFile(url, auth);
             file.connect();
-            if(file.exists()){
+            if (file.exists()) {
                 List<SmbFile> files = Lists.newArrayList(file.listFiles());
 
-                if(CollectionUtil.isNotEmpty(files)){
+                if (CollectionUtil.isNotEmpty(files)) {
 
                     //筛选pdf文件,根据文件创建时间降序
                     SmbFile smbFile = files.stream().filter(s->s.getName().contains(".res")).sorted(((o1, o2) -> {
                         try {
-                            if(o1.createTime() < o2.createTime()){
+                            if (o1.createTime() < o2.createTime()) {
                                 return 1;
-                            }else{
+                            } else {
                                 return -1;
                             }
                         } catch (SmbException e) {
@@ -356,7 +398,7 @@ public class SmbShareFileUtil {
                     int length = split.length;
 
                     //2023-7-23/OP41__.pdf
-                    returnFileName = split[length-2] + "/" + split[length-1];
+                    returnFileName = split[length - 2] + "/" + split[length - 1];
                 }
             }
         } catch (Exception e) {

+ 23 - 1
imcs-admin-boot/imcs-file-biz/src/main/java/com/github/zuihou/file/strategy/impl/AbstractFileStrategy.java

@@ -1,6 +1,7 @@
 package com.github.zuihou.file.strategy.impl;
 
 import cn.hutool.core.util.StrUtil;
+import com.github.zuihou.common.util.SmbShareFileUtil;
 import com.github.zuihou.context.BaseContextHandler;
 import com.github.zuihou.exception.BizException;
 import com.github.zuihou.file.domain.FileDeleteDO;
@@ -14,6 +15,7 @@ import com.github.zuihou.utils.StrPool;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.io.FilenameUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.web.multipart.MultipartFile;
 
 import java.nio.file.Paths;
@@ -40,6 +42,21 @@ public abstract class AbstractFileStrategy implements FileStrategy {
     @Autowired
     protected FileServerProperties fileProperties;
 
+
+    /**
+     * 虚拟机 共享文件配置
+     */
+    @Value("${zuihou.smb.virtualMachine.username}")
+    private String userName;
+    @Value("${zuihou.smb.virtualMachine.password}")
+    private String password;
+    @Value("${zuihou.smb.virtualMachine.smbUrl}")
+    private String SMB_URL;
+    @Value("${zuihou.smb.virtualMachine.sharePath}")
+    private String SHARE_PATH;
+
+    String suffix = ".MPF";
+
     /**
      * 上传文件
      *
@@ -88,7 +105,6 @@ public abstract class AbstractFileStrategy implements FileStrategy {
             setDate(file);
 
 
-
             //根据原名
             String fileName = multipartFile.getOriginalFilename();
 
@@ -99,9 +115,15 @@ public abstract class AbstractFileStrategy implements FileStrategy {
             // web服务器存放的绝对路径
             String absolutePath = Paths.get(fileProperties.getStoragePath(), relativePath).toString();
 
+            //本地存储一份
             java.io.File outFile = new java.io.File(Paths.get(absolutePath, fileName).toString());
             org.apache.commons.io.FileUtils.writeByteArrayToFile(outFile, multipartFile.getBytes());
 
+            // 同步到虚拟机 供httpserver读取
+            String shareFile = SMB_URL + SHARE_PATH  + fileName ;
+            log.info("写入到虚拟机的文件路径:"+shareFile);
+            SmbShareFileUtil.writeShareFileContent(shareFile, multipartFile.getBytes(), userName, password, SMB_URL);
+
             String url = new StringBuilder(fileProperties.getUriPrefix())
                     .append(relativePath)
                     .append(StrPool.SLASH)

Unele fișiere nu au fost afișate deoarece prea multe fișiere au fost modificate în acest diff