yejian 3 gadi atpakaļ
vecāks
revīzija
885f9a5178

+ 3 - 1
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/productionReadyCenter/service/impl/MachineCuttingToolServiceImpl.java

@@ -115,7 +115,9 @@ public class MachineCuttingToolServiceImpl extends SuperCacheServiceImpl<Machine
             HttpEntity<String> request = new HttpEntity<>(jsonObject.toJSONString(), headers);
 
             String synMachineCuttingTolls = "";
-            String instructionUrl = DictionaryKey.INSTRUCTION_URL + "/api/GetTools";
+            String instructionUrl = (null == msgUtil.redis_get(ParameterKey.PARAMETERS)? "": ((Map<String,String>)msgUtil.redis_get(ParameterKey.PARAMETERS)).get("capsule_plc").toString()) + "/api/GetTool";
+
+//             instructionUrl = DictionaryKey.INSTRUCTION_URL + "/api/GetTools";
             System.out.println("instructionUrl=" + instructionUrl);
             System.out.println("jsonParam=" + jsonObject.toJSONString());
             ResponseEntity<String> postForEntity = restTemplate.postForEntity(instructionUrl, request, String.class);

+ 5 - 0
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/productionResourceCenter/service/ProgramService.java

@@ -57,6 +57,11 @@ public interface ProgramService extends SuperService<Program> {
      */
     Map getProgram(Program data);
 
+    /**
+     * 查看程序
+     */
+    Map getProgramContent(Program data);
+
     /**
      * 同步到设备
      */

+ 45 - 3
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/productionResourceCenter/service/impl/ProgramServiceImpl.java

@@ -45,7 +45,11 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.client.RestTemplate;
 
-import java.io.File;
+import java.io.*;
+import java.net.URL;
+import java.net.URLConnection;
+import java.nio.channels.Channels;
+import java.nio.channels.ReadableByteChannel;
 import java.nio.file.Paths;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
@@ -126,7 +130,7 @@ public class ProgramServiceImpl extends SuperServiceImpl<ProgramMapper, Program>
 //        String returnData = restTemplate.postForObject(UrlConfConstant.plcURL, formEntity, String.class);
         String localFolder = uploadFolder + "0000/cncFile/" + productionresource.getId();
         String fileName = data.getFilePath().substring(data.getFilePath().lastIndexOf("/") + 1);
-        String localFilePathName = localFolder + "/" + fileName;
+        String localFilePathName = uploadFolder + "/" + data.getFilePath().substring(data.getFilePath().indexOf("0000"));
         // TODO 西门子程序scp上传
         String ip = productionresource.getIp();
         String port = "22";
@@ -206,6 +210,43 @@ public class ProgramServiceImpl extends SuperServiceImpl<ProgramMapper, Program>
         return getFileContent(fileName,model);
     }
 
+    /**
+     * 查看程序
+     */
+    @Override
+    public Map getProgramContent(Program data){
+        StringBuilder sb = new StringBuilder();
+        Map map = new HashMap<>();
+        Program program = baseMapper.selectById(data.getId());
+        BufferedReader br = null;
+        try {
+            URL url = new URL(program.getFilePath());
+            URLConnection con = url.openConnection();
+
+            br = new BufferedReader(new InputStreamReader(con.getInputStream()));
+            String inputLine = null;
+            while((inputLine = br.readLine()) != null){
+                if (inputLine != null && inputLine.trim().length() > 0) {
+                    sb.append(inputLine);
+                    sb.append("\n\r");
+                }
+            }
+            map.put("content",sb.toString());
+        }catch (Exception e){
+            e.printStackTrace();
+        }finally {
+            if(null != br){
+                try{
+                    br.close();
+                }catch (Exception e){
+
+                }
+            }
+        }
+        return map;
+    }
+
+
     //文件内容
     public Map getFileContent(String fileName,Program model){
         Map map = new HashMap<>();
@@ -305,7 +346,7 @@ public class ProgramServiceImpl extends SuperServiceImpl<ProgramMapper, Program>
                         // 入库设备程序表
                         Program program = new Program();
                         program.setResourceId(productionresource.getId());
-                        program.setName(productionresource.getName());
+                        program.setName(fileName);
                         program.setNo(productionresource.getCode());
                         String programFilePath = "http://" + nginxIp + ":" + nginxPort + "/file/0000/cncFile/"+ productionresource.getId() + "/" + fileName;
                         program.setFilePath(programFilePath);
@@ -322,6 +363,7 @@ public class ProgramServiceImpl extends SuperServiceImpl<ProgramMapper, Program>
 
                     if(productionresource!=null){
                         productionresource.setProgramNum(programList.size());
+                        productionresource.setProgramSynTime(LocalDateTime.now());
                         productionresourceMapper.updateById(productionresource);
                     }
                 }

+ 3 - 1
imcs-admin-boot/imcs-business-controller/src/main/java/com/github/zuihou/business/controller/productionResourceCenter/ProgramController.java

@@ -101,9 +101,11 @@ public class ProgramController extends SuperController<ProgramService, Long, Pro
     @ApiOperation(value = "查看程序", notes = "查看程序")
     @PostMapping("/getProgram")
     public R<Map> getProgram(@RequestBody Program model) {
-        return success(baseService.getProgram(model));
+//        return success(baseService.getProgram(model));
+        return success(baseService.getProgramContent(model));
     }
 
+
     @ApiOperation(value = "同步到设备", notes = "同步到设备")
     @PostMapping("/synchronousProgram")
     public R<Boolean> synchronousProgram(@RequestBody Program model) {

+ 5 - 0
imcs-admin-boot/imcs-business-entity/src/main/java/com/github/zuihou/business/productionResourceCenter/entity/Productionresource.java

@@ -227,6 +227,11 @@ public class Productionresource extends Entity<Long> {
     @Excel(name = "程序数量")
     private Integer programNum;
 
+    @ApiModelProperty(value = "程序同步时间")
+    @TableField("program_syn_time")
+    @Excel(name = "程序同步时间")
+    private LocalDateTime programSynTime;
+
     /**
      * 生产资源种类(1-基础机器类 2-ARV搬运类 3-机器人操作类)
      */