Pārlūkot izejas kodu

fix: 优化呼叫托盘夹具,锁定库位问题,优化检测结果解析问题

wang.sq@aliyun.com 4 mēneši atpakaļ
vecāks
revīzija
e3b1848752

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

@@ -482,11 +482,6 @@ public class MachineNodeServiceImpl implements NodeOperationService {
                     // 判断是工件坐标系还是质量测量
                     BBom bBom = bBomMapper.selectById(procedure.getBomId());
                     TWorkpiece tWorkpiece = workpieceMapper.selectOne(Wraps.<TWorkpiece>lbQ().eq(TWorkpiece::getCompleteBatchNo, task.getCompleteBatchNo()));
-                    // 根据库位id查询存储在此库位的信息工装夹具信息,查询工装所需要的检测程序名
-                    List<StockInfo> list = stockInfoService.list(Wraps.<StockInfo>lbQ().eq(StockInfo::getStorgeId, tWorkpiece.getStorgeId()));
-                    List<Long> getGoodsIds = list.stream().map(StockInfo::getGoodsId).collect(Collectors.toList());
-
-                    List<MToolClamp> mToolClamps = mToolClampService.listByIds(getGoodsIds);
 
                     if("1".equals(procedure.getThreeDimensionalConf())){
                         /*data.put("workId", task.getCompleteBatchNo() + "-" + task.getProcedureNo());*/
@@ -507,6 +502,11 @@ public class MachineNodeServiceImpl implements NodeOperationService {
                         // end modify by yejian on 20220507 for 更新tasknode表中nodetype,方便三坐标测量完成后回调后快速查找测量结果
                     }
                     if("1".equals(procedure.getThreeDimensionalDeviationConf())){
+                        // 根据库位id查询存储在此库位的信息工装夹具信息,查询工装所需要的检测程序名
+                        List<StockInfo> list = stockInfoService.list(Wraps.<StockInfo>lbQ().eq(StockInfo::getStorgeId, tWorkpiece.getStorgeId()));
+                        List<Long> getGoodsIds = list.stream().map(StockInfo::getGoodsId).collect(Collectors.toList());
+
+                        List<MToolClamp> mToolClamps = mToolClampService.listByIds(getGoodsIds);
                         // 拼接上传给plc的参数, 图号-零件号-源工序号-是否毛坯件-使用的检测程序
                         String toPlcPar = bBom.getDrawingNo()+"&"+tWorkpiece.getUniqueCode()+"&"+bBom.getNo()+"&"+"1"+"&"+mToolClamps.get(0).getDetectionProgram();
 

+ 2 - 2
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/productionResourceCenter/service/impl/RobotNodeServiceImpl2.java

@@ -1049,11 +1049,11 @@ public class RobotNodeServiceImpl2 implements NodeOperationService {
         List<BomProcedureTray>trayList = procedureTrayService.list(Wraps.<BomProcedureTray>lbQ().eq(BomProcedureTray::getProcedureId, task.getProcedureId()).orderByAsc(BomProcedureTray::getBizType));
         List<Long>trayIdList = trayList.stream().map(t->t.getTrayId()).collect(Collectors.toList());
 
-        // 查询出同类型,并且同一条产线的托盘信息
+        // 查询出同类型,并且同一条产线的托盘信息,并且没有可用没有锁的子盘信息
         List<Tray> newTrayList = trayService.selectUsersByIds(trayIdList);
 
         // 查询出同类型,并且同一条产线的工装信息
-        List<String> trayNoList = newTrayList.stream().map(t->t.getNo()).collect(Collectors.toList());
+        List<String> trayNoList = newTrayList.stream().map(t->t.getNo()).distinct().collect(Collectors.toList());
         QueryWrapper queryWrapper = new QueryWrapper();
         queryWrapper.in("no" , trayNoList);
         List<MToolClamp> mToolClamplist = toolClampService.list(queryWrapper);

+ 58 - 85
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/util/MsgUtil.java

@@ -8,6 +8,7 @@ import com.github.zuihou.authority.dto.priority.TaskNodePriorityDto;
 import com.github.zuihou.business.DemoLine.DemoCacheKey;
 import com.github.zuihou.business.DemoLine.DemoLineConstant;
 import com.github.zuihou.business.DemoLine.YunjianConstant;
+import com.github.zuihou.business.edgeLibrary.entity.StockInfo;
 import com.github.zuihou.business.edgeLibrary.service.StockInfoService;
 import com.github.zuihou.business.edgeLibrary.service.impl.StockInfoServiceImpl;
 import com.github.zuihou.business.operationManagementCenter.dao.*;
@@ -17,13 +18,11 @@ import com.github.zuihou.business.operationManagementCenter.service.TaskService;
 import com.github.zuihou.business.productionReadyCenter.dao.BBomMapper;
 import com.github.zuihou.business.productionReadyCenter.dao.BomProcedureMapper;
 import com.github.zuihou.business.productionReadyCenter.dao.BomProcedureProductionresourceMapper;
-import com.github.zuihou.business.productionReadyCenter.entity.AAutoNodeLog;
-import com.github.zuihou.business.productionReadyCenter.entity.BBom;
-import com.github.zuihou.business.productionReadyCenter.entity.BomProcedure;
-import com.github.zuihou.business.productionReadyCenter.entity.BomProcedureProductionresource;
+import com.github.zuihou.business.productionReadyCenter.entity.*;
 import com.github.zuihou.business.productionReadyCenter.service.AAutoNodeLogService;
 import com.github.zuihou.business.productionReadyCenter.service.AutoNodeLogService;
 import com.github.zuihou.business.productionReadyCenter.service.BomProcedureService;
+import com.github.zuihou.business.productionReadyCenter.service.MToolClampService;
 import com.github.zuihou.business.productionResourceCenter.dao.ProductionresourceBizMapper;
 import com.github.zuihou.business.productionResourceCenter.dao.ZZoneProductionresourceMapper;
 import com.github.zuihou.business.productionResourceCenter.entity.Productionresource;
@@ -67,6 +66,7 @@ import org.springframework.web.client.RestTemplate;
 import javax.annotation.Resource;
 import java.io.*;
 import java.math.BigDecimal;
+import java.security.Key;
 import java.util.*;
 import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
@@ -86,6 +86,9 @@ public class MsgUtil implements ApplicationContextAware {
     private String fileIp;
     @Value("${zuihou.smb.filePath}")
     private String filePath;
+    @Value("${zuihou.three_dimensiona.file_path}")
+    private String threeDimensionalResultAddress;
+
     @Value("${zuihou.file.storage-path}")
     private String uploadFolder;
 
@@ -135,6 +138,10 @@ public class MsgUtil implements ApplicationContextAware {
     private TTaskTestUnqualifiedBomMapper taskTestUnqualifiedBomMapper;
     @Autowired
     private TTaskMapper taskMapper;
+    @Autowired
+    private StockInfoService stockInfoService;
+    @Autowired
+    private MToolClampService mToolClampService;
 
     @Autowired
     private BomProcedureProductionresourceMapper bomProcedureProductionresourceMapper;
@@ -319,7 +326,6 @@ public class MsgUtil implements ApplicationContextAware {
                     String returnData = this.getCcsData(instructionUrl, jsonParam, taskNode);
                     //获取检测结果
                     int measuringResult = returnData.trim().equals("1") ? 0 : 1;
-                    //String measuringResultFile = filePath + bomProcedure.getThreeDimensionalPrograme() + "_" + taskNode.getProcedureNo() + "_" + task.getCompleteBatchNo() + "_" + taskNode.getId() +".pdf";
                     String date = DateUtil.dateToString0(new Date(), "yyyy-M-dd");
 
                     // todo wang.sq三坐标测量最终报告位置查询
@@ -393,88 +399,55 @@ public class MsgUtil implements ApplicationContextAware {
                         }
                     }
                 }else if ("5".equals(taskNode.getNodeType())){
-                    // 工件坐标系检测
-                    // todo wang.sq三坐标测量偏移量数据添加
-                    String nginxRemoteFilePath = "";
-                    String findFileName = taskNode.getCompleteBatchNo()+ "_" + task.getProcedureNo();
-                    List list = new ArrayList<>();
-                    if(StringUtils.isNotBlank(findFileName)){
-                        // 远程下载报告文件到本地
-/*                      String downloadFileName = SmbShareFileUtil.findMeasuringFilesAndDownload(fileIp,userName,password,filePath,findFileName,uploadFolder);
-
-
-                        if (StringUtils.isNotBlank(downloadFileName)) {
-                            nginxRemoteFilePath = uploadFolder + File.separator + downloadFileName;
-                            // 读取nginx远程本地测量报告解析
-                            InputStream in = null;
-                            try {
-                                in = new FileInputStream(nginxRemoteFilePath);
-                                Workbook work = this.getWorkbook(in, nginxRemoteFilePath);
-                                if (null == work) {
-                                    throw new Exception("创建Excel工作薄为空!");
-                                }
-                                Sheet sheet = null;
-                                Row row = null;
-                                Cell cell = null;
-
-                                for (int i = 0; i < work.getNumberOfSheets(); i++) {
-                                    sheet = work.getSheetAt(i);
-                                    if (sheet == null) {
-                                        continue;
-                                    }
-
-                                    for (int j = sheet.getFirstRowNum(); j <= sheet.getLastRowNum(); j++) {
-                                        row = sheet.getRow(j);
-                                        if (row == null || row.getFirstCellNum() == j) {
-                                            continue;
-                                        }
-
-                                        List<Object> li = new ArrayList<>();
-                                        for (int y = row.getFirstCellNum(); y < row.getLastCellNum(); y++) {
-                                            cell = row.getCell(y);
-                                            li.add(cell);
-                                        }
-                                        list.add(li);
-                                    }
-                                    in.close();
-                                }
-                                work.close();
-                            } catch (Exception e) {
-                                e.printStackTrace();
-                            }finally {
-                                if (null != in){
-                                    try {
-                                        in.close();
-                                    } catch (IOException e) {
-                                        e.printStackTrace();
-                                    }
-                                }
+                    // 工件坐标系检测 三坐标测量偏移量数据添加
+                    BomProcedure procedure = bomProcedureService.getById(task.getProcedureId());
+                    BBom bBom = bBomMapper.selectById(procedure.getBomId());
+                    TWorkpiece tWorkpiece = workpieceMapper.selectOne(Wraps.<TWorkpiece>lbQ().eq(TWorkpiece::getCompleteBatchNo, task.getCompleteBatchNo()));
+                    // 根据库位id查询存储在此库位的信息工装夹具信息,查询工装所需要的检测程序名
+                    List<StockInfo> list = stockInfoService.list(Wraps.<StockInfo>lbQ().eq(StockInfo::getStorgeId, tWorkpiece.getStorgeId()));
+                    List<Long> getGoodsIds = list.stream().map(StockInfo::getGoodsId).collect(Collectors.toList());
+
+                    List<MToolClamp> mToolClamps = mToolClampService.listByIds(getGoodsIds);
+                    // 拼接上传给plc的参数, 图号-零件号-源工序号-是否毛坯件-使用的检测程序
+                    String toPlcPar = bBom.getDrawingNo()+"&"+tWorkpiece.getUniqueCode()+"&"+bBom.getNo()+"&"+"1"+"&"+mToolClamps.get(0).getDetectionProgram();
+
+                    Map<String, List<String>> stringListMap = SmbShareFileUtil.processExcelFiles(threeDimensionalResultAddress, toPlcPar,"xlsx");
+
+                    if (!stringListMap.isEmpty()) {
+
+                        List<OrderQuality> list1 = new ArrayList<>();
+
+                        stringListMap.forEach((Key, stringsList) -> {
+                            List<OrderQuality> orderQualities = orderQualityMapper.selectList(Wraps.<OrderQuality>lbQ().eq(OrderQuality::getDetectionCommand, Key));
+                            if(orderQualities.isEmpty()){
+                                OrderQuality orderQuality = new OrderQuality();
+                                orderQuality.setOrderNo(order.getOrderNo());
+                                orderQuality.setOrderId(order.getId());
+                                orderQuality.setTaskId(task.getId());
+                                orderQuality.setWorkpieceId(task.getCompleteBatchNo());
+                                orderQuality.setWorkpieceName(bom.getName());
+                                orderQuality.setProcedureId(task.getProcedureId());
+                                orderQuality.setProcedureName(task.getProcedureName());
+                                // 读取三坐标工件坐标系每根轴偏移量
+                                BigDecimal xOffset = new BigDecimal(stringsList.size()>=6? stringsList.get(0):"");
+                                BigDecimal yOffset = new BigDecimal(stringsList.size()>=6? stringsList.get(1):"");
+                                BigDecimal zOffset = new BigDecimal(stringsList.size()>=6? stringsList.get(2):"");
+                                BigDecimal aOffset = new BigDecimal(stringsList.size()>=6? stringsList.get(3):"");
+                                BigDecimal bOffset = new BigDecimal(stringsList.size()>=6? stringsList.get(4):"");
+                                BigDecimal cOffset = new BigDecimal(stringsList.size()>=6? stringsList.get(5):"");
+                                orderQuality.setExactXaxisOffset(xOffset);
+                                orderQuality.setExactYaxisOffset(yOffset);
+                                orderQuality.setExactZaxisOffset(zOffset);
+                                orderQuality.setExactAaxisOffset(aOffset);
+                                orderQuality.setExactBaxisOffset(bOffset);
+                                orderQuality.setExactCaxisOffset(cOffset);
+
+                                list1.add(orderQuality);
                             }
-                        }*/
-                        // 与数据库比对是否已经有存在的数据,如果有则舍去,没有则新增
-                        if (list.size() == 18) {
-                            // 读取三坐标工件坐标系每根轴偏移量
-                            BigDecimal xOffset = new BigDecimal(list.get(13).toString());
-                            BigDecimal yOffset = new BigDecimal(list.get(14).toString());
-                            BigDecimal zOffset = new BigDecimal(list.get(15).toString());
-                            BigDecimal aOffset = new BigDecimal(list.get(16).toString());
-                            BigDecimal bOffset = new BigDecimal(list.get(17).toString());
-                            OrderQuality orderQuality = new OrderQuality();
-                            orderQuality.setOrderNo(order.getOrderNo());
-                            orderQuality.setOrderId(order.getId());
-                            orderQuality.setTaskId(task.getId());
-                            orderQuality.setWorkpieceId(task.getCompleteBatchNo());
-                            orderQuality.setWorkpieceName(bom.getName());
-                            orderQuality.setProcedureId(task.getProcedureId());
-                            orderQuality.setProcedureName(task.getProcedureName());
-                            orderQuality.setExactXaxisOffset(xOffset);
-                            orderQuality.setExactYaxisOffset(yOffset);
-                            orderQuality.setExactZaxisOffset(zOffset);
-                            orderQuality.setExactAaxisOffset(aOffset);
-                            orderQuality.setExactBaxisOffset(bOffset);
-                            orderQualityMapper.insert(orderQuality);
-                        }
+                        });
+                        orderQualityMapper.insertBatchSomeColumn(list1);
                     }
+
                 }
             }
 

+ 3 - 0
imcs-admin-boot/imcs-business-biz/src/main/resources/mapper_business/base/productionReadyCenter/TrayMapper.xml

@@ -45,12 +45,15 @@
     <select id="selectUsersByIds" resultMap="BaseResultMap">
 
         SELECT
+        distinct
         a.*,
         b.positionSort
         FROM
         `imcs_t_tray` a
         INNER JOIN imcs_t_tray b ON b.production_type = a.production_type
         LEFT JOIN ( SELECT tray_id, GROUP_CONCAT( position_sort ) AS positionSort FROM imcs_t_tray_position GROUP BY tray_id ) b ON a.id = b.tray_id
+        INNER JOIN imcs_s_stock_info isi ON isi.goods_id = a.id AND isi.lock_status =1
+        INNER JOIN imcs_s_storge iss ON iss.id = isi.storge_id AND iss.lock_status =1
         WHERE
             a.zone_id = b.zone_id
             AND a.category_type = b.category_type

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

@@ -78,6 +78,11 @@ public class OrderQuality extends Entity {
     @Excel(name = "工件ID)")
     private String workpieceId;
 
+    @ApiModelProperty(value = "下发给三坐标的唯一检测命令")
+    @TableField(value = "detection_command", condition = LIKE)
+    @Excel(name = "下发给三坐标的唯一检测命令)")
+    private String detectionCommand;
+
     /**
      * 工件名称
      */

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

@@ -371,12 +371,18 @@ public class SmbShareFileUtil {
      *
      * @param folderPath 文件夹
      * @param containsName 需要匹配的名字
+     * @param containsSuffix 需要拦截的后缀
      * @return
      */
-    public static Map<String, List<String>> processExcelFiles(String folderPath,String containsName) {
+    public static Map<String, List<String>> processExcelFiles(String folderPath,String containsName,String containsSuffix) {
         Map<String, List<String>> resultMap = new HashMap<>();
         File folder = new File(folderPath);
-        File[] files = folder.listFiles((dir, name) -> (name.endsWith(".xlsx") || name.endsWith(".xls")) && name.contains(containsName));
+        if(!folder.exists()){
+            logger.info("=====================没有找到文件夹=====================");
+          return   resultMap ;
+        }
+
+        File[] files = folder.listFiles((dir, name) -> (dir.isFile() && name.contains(containsName) && name.substring(0,name.lastIndexOf(".")).contains(containsSuffix)));
 
         if (files == null || files.length == 0) {
             logger.info("没有找到需要处理的 Excel 文件。");
@@ -388,7 +394,7 @@ public class SmbShareFileUtil {
                 Map.Entry<String, List<String>> result = parseExcelFile(file);
                 if (result != null) {
                     resultMap.put(result.getKey(), result.getValue());
-                    renameFile(file); // 修改文件名
+//                    renameFile(file); // 修改文件名
                 }
             } catch (Exception e) {
                 logger.error("处理文件时出错: " + file.getName(),e);
@@ -437,16 +443,16 @@ public class SmbShareFileUtil {
         }
     }
 
-    public static void main(String[] args) {
-        String folderPath = "D:\\CeShi"; // 替换为您的文件夹路径
-        Map<String, List<String>> resultMap = processExcelFiles(folderPath,"processed");
-
-        // 打印结果
-        resultMap.forEach((key, value) -> {
-            System.out.println("唯一标识: " + key);
-            System.out.println("数据: " + value);
-        });
-    }
+//    public static void main(String[] args) {
+//        String folderPath = "D:\\CeShi"; // 替换为您的文件夹路径
+//        Map<String, List<String>> resultMap = processExcelFiles(folderPath,"processed");
+//
+//        // 打印结果
+//        resultMap.forEach((key, value) -> {
+//            System.out.println("唯一标识: " + key);
+//            System.out.println("数据: " + value);
+//        });
+//    }