Browse Source

三坐标测量模拟

yejian 2 years ago
parent
commit
d8a61685a5

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

@@ -1363,7 +1363,6 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
 
         List<AAutoNodeLog> autoNodeLogList = autoNodeLogMapper.selectList(Wraps.<AAutoNodeLog>lbQ().eq(AAutoNodeLog::getTaskNodeId, taskNode.getId()));
         AAutoNodeLog lg = autoNodeLogList.get(0);
-
         if ("1".equals(code)) {
             //处理
             taskNodeCallbackBiz(taskNode, task, taskNodeList, lg, bizCallBackData);
@@ -1374,6 +1373,7 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
             lg.setStatus("0").setExeResult("0").setManual("1").setFeedback(msg);
             autoNodeLogMapper.updateAllById(lg);
         }
+
         return R.success();
     }
 
@@ -1436,43 +1436,6 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
             if(null != callBackJson.getString("updateUser")){
                 taskNode.setLoadingUserId(Long.valueOf(callBackJson.getString("updateUser")));
             }
-            // add by yejian on 20200212 for 判断是否是三坐标测量是否测量是否通过,不通过直接下料下线
-            // 判断当前工件是否是测量序,并且测量结果是否OK
-            BomProcedure bomProcedure = bomProcedureService.getById(task.getProcedureId());
-
-            // 三坐标测量
-            if(StringUtils.isNotBlank(bomProcedure.getProgramTestPrograme())){
-                // 测量NG
-                if("1".equals(callBackJson.getString("measuringResult"))){
-                    taskNode.setTestResult("0");
-                    // TODO 删除当前工件当前工序后的其他加工工序,直接下料,现在的都是最后工序是下料,删除到最后一个工序,后续根据新建单独下料需删除全部剩余结点在添加的方式
-                    // 查找该工件最后工序
-                    QueryWrapper<BomProcedure> queryBomProcedureWrapper = new QueryWrapper<BomProcedure>();
-                    queryBomProcedureWrapper.eq("bomId", task.getBomId());
-                    queryBomProcedureWrapper.orderByDesc("sort");
-                    queryBomProcedureWrapper.last("limit 1");
-                    BomProcedure bomLasProcedure = bomProcedureService.getOne(queryBomProcedureWrapper);
-
-                    // 查找该工件最后排序的task
-                    QueryWrapper<TTask> queryTTaskWrapper = new QueryWrapper<TTask>();
-                    queryTTaskWrapper.eq("completeBatchNo", task.getCompleteBatchNo());
-                    queryTTaskWrapper.eq("procedure_id",bomLasProcedure.getId());
-                    TTask tTask = taskMapper.selectOne(queryTTaskWrapper);
-
-                    // 删除tasknode表中除下料的未执行结点
-                    QueryWrapper<TaskNode> deleteTaskNodeWrapper = new QueryWrapper<TaskNode>();
-                    deleteTaskNodeWrapper.eq("completeBatchNo", task.getCompleteBatchNo());
-                    deleteTaskNodeWrapper.eq("exeStatus","0");
-                    deleteTaskNodeWrapper.ne("taskId",tTask.getId());
-                    baseMapper.delete(deleteTaskNodeWrapper);
-
-                    //设置workpiece表为NG
-                    currWorkpiece.setTestResult("1");
-                    workpieceService.updateById(currWorkpiece);
-                }
-            }
-
-            // end by yejian on 20200212 for 判断是否是三坐标测量是否测量是否通过,不通过直接下线
 
             updateAllById(taskNode);
 

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

@@ -1138,7 +1138,9 @@ public class TaskServiceImpl extends SuperServiceImpl<TTaskMapper, TTask> implem
                 }
 
             }
+            msgUtil.redis_del(id);
         }
+
         return  R.success();
     }
 

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

@@ -2,14 +2,13 @@ package com.github.zuihou.business.util;
 
 import cn.hutool.core.collection.CollectionUtil;
 import com.alibaba.fastjson.JSONObject;
-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.service.StockInfoService;
 import com.github.zuihou.business.edgeLibrary.service.impl.StockInfoServiceImpl;
-import com.github.zuihou.business.operationManagementCenter.entity.TTask;
-import com.github.zuihou.business.operationManagementCenter.entity.TWorkpiece;
-import com.github.zuihou.business.operationManagementCenter.entity.TaskNode;
+import com.github.zuihou.business.operationManagementCenter.dao.OrderMapper;
+import com.github.zuihou.business.operationManagementCenter.dao.OrderQualityMapper;
+import com.github.zuihou.business.operationManagementCenter.dao.PlanMapper;
+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.productionReadyCenter.dao.BBomMapper;
@@ -23,15 +22,15 @@ import com.github.zuihou.business.productionResourceCenter.service.ZZoneService;
 import com.github.zuihou.business.productionResourceCenter.service.impl.ZZoneServiceImpl;
 import com.github.zuihou.business.websocket.WebSocketServer;
 import com.github.zuihou.common.constant.BizConstant;
-import com.github.zuihou.common.constant.CacheKey;
 import com.github.zuihou.common.constant.DictionaryKey;
 import com.github.zuihou.common.constant.ParameterKey;
+import com.github.zuihou.common.util.SmbShareFileUtil;
 import com.github.zuihou.database.mybatis.conditions.Wraps;
-import com.qiniu.common.Zone;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.BeansException;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.ApplicationContextAware;
 import org.springframework.data.redis.core.RedisTemplate;
@@ -42,10 +41,7 @@ import org.springframework.stereotype.Component;
 import org.springframework.web.client.RestTemplate;
 
 import javax.annotation.Resource;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.concurrent.TimeUnit;
 
 @Component
@@ -55,6 +51,15 @@ public class MsgUtil implements ApplicationContextAware {
 
     private static ApplicationContext applicationContext;
 
+    @Value("${zuihou.smb.userName}")
+    private String userName;
+    @Value("${zuihou.smb.password}")
+    private String password;
+    @Value("${zuihou.smb.password}")
+    private String fileIp;
+    @Value("${zuihou.smb.filePath}")
+    private String filePath;
+
     @Resource
     private RedisTemplate<String,Object> redisTemplate;
 
@@ -87,6 +92,13 @@ public class MsgUtil implements ApplicationContextAware {
     @Autowired
     private MsgUtil msgUtil;
 
+    @Autowired
+    private OrderQualityMapper orderQualityMapper;
+    @Autowired
+    private OrderMapper orderMapper;
+    @Autowired
+    private PlanMapper planMapper;
+
     @Override
     public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
         MsgUtil.applicationContext = applicationContext;
@@ -141,19 +153,6 @@ public class MsgUtil implements ApplicationContextAware {
         if(n<taskNodeList.size()-1){//尚未执行到最后一个
             TaskNode nextTaskNode = taskNodeList.get(n+1);
 
-            //如果切换成了手动档,则只把当前工序走完
-//            if(currWorkpiece!=null&&"1".equals(currWorkpiece.getExchangeZoneFlag())){
-                BBom bom = bBomMapper.selectById(task.getBomId());
-                ZZone bomzZone = zoneService.getById(bom.getZoneId());
-                Long exchangeProcedureId = currWorkpiece.getExchangeProcedureId();
-
-                System.err.println("***************************");
-                //如果是手动模式,执行完当前工序就不往下走了
-                if("2".equals(bomzZone.getRunMode()) && taskNode.getProcedureId() != nextTaskNode.getProcedureId().longValue()){
-                    return;
-                }
-//            }
-
             //如果是三坐标检测
             if("3".equals(taskNode.getNodeType())){
                 // TODO 后续改成动态拼接
@@ -182,7 +181,36 @@ public class MsgUtil implements ApplicationContextAware {
                 System.out.println("instructionUrl=" + instructionUrl);
                 System.out.println("jsonParam=" + jsonParam);
                 String returnData = restTemplate.postForObject(instructionUrl, formEntity, String.class);
-                if("1".equals(returnData)){
+
+                // TODO modify by yejian on 20220525 for 添加三坐标模拟
+                Random random = new Random();
+                Boolean measuringFlag = random.nextBoolean();
+                int measuringResult = measuringFlag ? 0 : 1;
+                String measuringResultFile = filePath + taskNode.getCompleteBatchNo() + "_" + task.getProcedureNo();
+                List<String> fileContents = new ArrayList<>();
+//                if(measuringFlag){
+//                    fileContents.add("NG");
+//                }else{
+                    fileContents.add("OK");
+//                }
+                SmbShareFileUtil.writeShareFileContent(measuringResultFile,fileContents,userName,password,fileIp);
+                Order order = orderMapper.selectById(task.getOrderId());
+                Plan plan = planMapper.selectById(task.getPlanId());
+                BBom bom = bBomMapper.selectById(task.getBomId());
+                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.setMeasuringType(1);
+                orderQuality.setOkFlag("OK");
+                orderQuality.setMeasuringReport(measuringResultFile);
+                orderQualityMapper.insert(orderQuality);
+
+                if(1 == measuringResult){
                     //获取下料工序
                     List<BomProcedure> bomProcedureList = bomProcedureService.list(Wraps.<BomProcedure>lbQ().eq(BomProcedure::getBomId,task.getBomId()).eq(BomProcedure::getType,"下料").orderByAsc(BomProcedure::getSort));
                     if(CollectionUtil.isNotEmpty(bomProcedureList)){
@@ -199,6 +227,15 @@ public class MsgUtil implements ApplicationContextAware {
                 }
             }
 
+            //如果切换成了手动档,则只把当前工序走完
+            BBom bom = bBomMapper.selectById(task.getBomId());
+            ZZone bomzZone = zoneService.getById(bom.getZoneId());
+
+            //如果是手动模式,执行完当前工序就不往下走了
+            if("2".equals(bomzZone.getRunMode()) && taskNode.getProcedureId() != nextTaskNode.getProcedureId().longValue()){
+                System.err.println("手动模式下工序最后一个工步***************************");
+                return;
+            }
 
             if(callBackJson.containsKey(YunjianConstant.YUNJIAN_XBKFLAG)){//临时存放到了线边库,向虚拟线边库发一个MQ。
                     int count =  callBackJson.getString(taskNode.getId().toString()+"count")==null?-1:Integer.parseInt(callBackJson.getString(taskNode.getId().toString()+"count"));

+ 9 - 1
imcs-admin-boot/imcs-business-controller/src/main/java/com/github/zuihou/business/controller/operationManagementCenter/MeasuringController.java

@@ -5,8 +5,10 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.github.zuihou.base.R;
 import com.github.zuihou.base.controller.SuperController;
 import com.github.zuihou.base.request.PageParams;
+import com.github.zuihou.business.operationManagementCenter.dao.TTaskMapper;
 import com.github.zuihou.business.operationManagementCenter.dto.*;
 import com.github.zuihou.business.operationManagementCenter.entity.OrderQuality;
+import com.github.zuihou.business.operationManagementCenter.entity.TTask;
 import com.github.zuihou.business.operationManagementCenter.entity.TWorkpiece;
 import com.github.zuihou.business.operationManagementCenter.service.OrderQualityService;
 import com.github.zuihou.business.operationManagementCenter.service.WorkpieceService;
@@ -21,6 +23,7 @@ import jcifs.smb.NtlmPasswordAuthentication;
 import jcifs.smb.SmbFile;
 import jcifs.smb.SmbFileInputStream;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
@@ -60,6 +63,9 @@ public class MeasuringController extends SuperController<OrderQualityService, Lo
     @Value("${zuihou.smb.filePath}")
     private String filePath;
 
+    @Autowired
+    private TTaskMapper tTaskMapper;
+
     @Override
     public void query(PageParams<OrderQualityPageDTO> params, IPage<OrderQuality> page, Long defSize) {
         OrderQualityPageDTO data = params.getModel();
@@ -87,7 +93,9 @@ public class MeasuringController extends SuperController<OrderQualityService, Lo
     @SysLog("下载远程质检报告")
     public R<File> downloadFile(HttpServletResponse response, @RequestBody  Map<String, Object> map) throws IOException, FileNotFoundException {
         String id  = map.get("id").toString();
-        String fileName = id + ".csv";
+
+        TTask task = tTaskMapper.selectById(id);
+        String fileName = task.getCompleteBatchNo() + "_" + task.getProcedureNo() + ".csv";
         response.setHeader("content-type", "text/csv");
         response.setContentType("application/octet-stream");
         response.setHeader("Content-Disposition", "attachment; filename=" + fileName);

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

@@ -20,12 +20,13 @@ public class SmbShareFileUtil {
      * @param shareFile 共享文件路径
      * @param fileContents 写入内容
      */
-    public static boolean writeShareFileContent(String shareFile, List<String> fileContents){
+    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 ;
         BufferedWriter bufferedWriter = null;
         try{
-            out = new BufferedOutputStream(new SmbFileOutputStream(shareFile));
+            out = new BufferedOutputStream(new SmbFileOutputStream(new SmbFile(shareFile,auth )));
             bufferedWriter = new BufferedWriter(new OutputStreamWriter(out));
             // 按行写入文件
             for(int i = 0; i < fileContents.size(); i++){
@@ -218,10 +219,10 @@ public class SmbShareFileUtil {
     }
 
     public static void main(String[] args) {
-//        String ip="192.168.170.23";
-//        String url="smb://192.168.170.23/measuring/1111-1111-2021-09-12-10-36-32.csv";
-//        String name="measuring";
-//        String password="Imcs@123456";
+        String ip="192.168.170.23";
+        String url="smb://192.168.170.23/measuring/1111.csv";
+        String name="measuring";
+        String password="Imcs@123456";
 //        NtlmPasswordAuthentication auth =new NtlmPasswordAuthentication(ip, name, password);
 //        SmbFile file = null;
 //        try {
@@ -240,7 +241,10 @@ public class SmbShareFileUtil {
 ////        }
 //        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
 //        System.out.println(Date.parse("2021-12-23"));
-        System.out.println( DateUtil.beginOfMonth(new Date()).dayOfMonth());
-        System.out.println( DateUtil.endOfMonth(new Date()).dayOfMonth());
+//        System.out.println( DateUtil.beginOfMonth(new Date()).dayOfMonth());
+//        System.out.println( DateUtil.endOfMonth(new Date()).dayOfMonth());
+        List<String> content = new ArrayList<>();
+        content.add("OK");
+        writeShareFileContent(url,content,name,password,ip);
     }
 }