Jelajahi Sumber

agv动态节点问题修改,统计报表根据最新表修改

yejian 3 tahun lalu
induk
melakukan
56218898cb
11 mengubah file dengan 92 tambahan dan 69 penghapusan
  1. 1 1
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/edgeLibrary/service/impl/StorgeServiceImpl.java
  2. 1 1
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/externalApi/dao/AgvHikOrderDetailInfoMapper.java
  3. 1 1
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/externalApi/service/AgvHikOrderDetailInfoService.java
  4. 9 8
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/externalApi/service/impl/AgvHikOrderDetailInfoServiceImpl.java
  5. 1 1
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/mq/TaskWorkNode.java
  6. 5 3
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/operationManagementCenter/service/impl/TaskNodeServiceImpl.java
  7. 1 1
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/productionResourceCenter/service/impl/RobotNodeServiceImpl.java
  8. 36 25
      imcs-admin-boot/imcs-business-biz/src/main/resources/mapper_business/base/externalApi/AgvHikOrderDetailInfoMapper.xml
  9. 29 21
      imcs-admin-boot/imcs-business-biz/src/main/resources/mapper_business/base/statisticalAnalysis/ProductLinePerformanceMapper.xml
  10. 7 7
      imcs-admin-boot/imcs-business-controller/src/main/java/com/github/zuihou/business/controller/externalApi/AgvHikOrderDetailInfoController.java
  11. 1 0
      imcs-admin-boot/imcs-business-controller/src/main/java/com/github/zuihou/business/controller/externalApi/HikAgvControl.java

+ 1 - 1
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/edgeLibrary/service/impl/StorgeServiceImpl.java

@@ -308,7 +308,7 @@ public class StorgeServiceImpl extends SuperCacheServiceImpl<StorgeMapper, Storg
                 ProductionresourcePosition position = null;
                 for(ProductionresourcePosition productionresourcePosition : tbList){
                     if(!occupyAgvStations.contains(productionresourcePosition.getResourceId())){
-                        position = tbList.get(0);
+                        position = productionresourcePosition;
                         break;
                     }
                 }

+ 1 - 1
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/externalApi/dao/AgvHikOrderDetailInfoMapper.java

@@ -26,6 +26,6 @@ public interface AgvHikOrderDetailInfoMapper extends SuperMapper<AgvHikOrderDeta
     /**
      * 分页
      */
-    IPage<AgvHikOrderDetailInfo> pageList(IPage page, @Param(Constants.WRAPPER) Wrapper<AgvHikOrderDetailInfo> queryWrapper);
+    IPage<AgvHikOrderDetailInfo> pageList(IPage page,@Param("statisticalBeginDate") String  statisticalBeginDate, @Param("statisticalEndDate") String statisticalEndDate, @Param(Constants.WRAPPER) Wrapper<AgvHikOrderDetailInfo> queryWrapper);
 
 }

+ 1 - 1
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/externalApi/service/AgvHikOrderDetailInfoService.java

@@ -20,7 +20,7 @@ import java.util.concurrent.Future;
  */
 public interface AgvHikOrderDetailInfoService extends SuperCacheService<AgvHikOrderDetailInfo> {
 
-    IPage<AgvHikOrderDetailInfo> pageList(IPage page, LbqWrapper<AgvHikOrderDetailInfo> wrapper);
+    IPage<AgvHikOrderDetailInfo> pageList(IPage page,String statisticalBeginDate,String statisticalEndDate, LbqWrapper<AgvHikOrderDetailInfo> wrapper);
 
     /**
      * 保存

+ 9 - 8
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/externalApi/service/impl/AgvHikOrderDetailInfoServiceImpl.java

@@ -51,8 +51,8 @@ public class AgvHikOrderDetailInfoServiceImpl extends SuperCacheServiceImpl<AgvH
 
     @Override
     @InjectionResult
-    public IPage<AgvHikOrderDetailInfo> pageList(IPage page, LbqWrapper<AgvHikOrderDetailInfo> wrapper) {
-        return baseMapper.pageList(page, wrapper);
+    public IPage<AgvHikOrderDetailInfo> pageList(IPage page,String statisticalBeginDate,String statisticalEndDate, LbqWrapper<AgvHikOrderDetailInfo> wrapper) {
+        return baseMapper.pageList(page, statisticalBeginDate, statisticalEndDate, wrapper);
     }
 
     @Override
@@ -81,15 +81,15 @@ public class AgvHikOrderDetailInfoServiceImpl extends SuperCacheServiceImpl<AgvH
             // 组装数据模拟agv任务完成返回
             JSONObject jsonObject = JSONObject.parseObject(data);
             String taskCode = jsonObject.getString("taskCode");
-            if(Long.valueOf(taskCode) % 10 == 1){
-                jsonObject.put("method","end");
-                jsonObject.put("code","999999");
-                jsonObject.put("msg","false");
-            }else{
+//            if(Long.valueOf(taskCode) % 10 == 1){
+//                jsonObject.put("method","end");
+//                jsonObject.put("code","999999");
+//                jsonObject.put("msg","false");
+//            }else{
                 jsonObject.put("method","end");
                 jsonObject.put("code","0");
                 jsonObject.put("msg","success");
-            }
+//            }
 
 
             // 组装参数发送至agv回调接口
@@ -97,6 +97,7 @@ public class AgvHikOrderDetailInfoServiceImpl extends SuperCacheServiceImpl<AgvH
             headers.setContentType(MediaType.parseMediaType("application/json;charset=UTF-8"));
 
             HttpEntity<String> formEntity = new HttpEntity<String>(jsonObject.toJSONString(),headers);
+            log.info("agv模拟回到参数:{}", jsonObject.toJSONString());
             String returnData = restTemplate.postForObject("http://localhost:8760/api/authority/agv/agvCallbackService/agvCallback",formEntity, String.class);
         } catch (InterruptedException e) {
             e.printStackTrace();

+ 1 - 1
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/mq/TaskWorkNode.java

@@ -844,7 +844,7 @@ public class TaskWorkNode {
                     ProductionresourcePosition position = null;
                     for(ProductionresourcePosition productionresourcePosition : jbwBList){
                         if(!occupyAgvStations.contains(productionresourcePosition.getResourceId())){
-                            position = jbwBList.get(0);
+                            position = productionresourcePosition;
                             break;
                         }
                     }

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

@@ -1430,7 +1430,9 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
 
             //更新节点任务
             taskNode.setExeStatus("3").setExeResult("1").setEndTime(new Date());
-
+            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());
@@ -1608,11 +1610,11 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
         // 如果前一节点时agv搬运节点,机器人将物料帮运走后释放预占redis里面的内容
 
         List<Long> occupyAgvStations = (null == msgUtil.redis_get(DemoCacheKey.DEMOLINE_AGV_STATION_OCCUPY) ? new ArrayList<>(): (List<Long>) msgUtil.redis_get(DemoCacheKey.DEMOLINE_AGV_STATION_OCCUPY));
+        TaskNode beforTaskNode = getNextNTaskNode(taskNode, -1);
         if("03".equals(taskNode.getInterfaceType())){
-            occupyAgvStations.remove(taskNode.getTargetResourceId());
+            occupyAgvStations.remove(beforTaskNode.getTargetResourceId());
         }
 
-        TaskNode beforTaskNode = getNextNTaskNode(taskNode, -1);
         if(null != beforTaskNode && "03".equals(beforTaskNode.getInterfaceType())){
             occupyAgvStations.remove(beforTaskNode.getTargetResourceId());
         }

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

@@ -538,7 +538,7 @@ public class RobotNodeServiceImpl implements NodeOperationService {
                     ProductionresourcePosition position = null;
                     for(ProductionresourcePosition productionresourcePosition : jbwBList){
                         if(!occupyAgvStations.contains(productionresourcePosition.getResourceId())){
-                            position = jbwBList.get(0);
+                            position = productionresourcePosition;
                             break;
                         }
                     }

+ 36 - 25
imcs-admin-boot/imcs-business-biz/src/main/resources/mapper_business/base/externalApi/AgvHikOrderDetailInfoMapper.xml

@@ -33,31 +33,42 @@
     <!-- 分页 -->
     <select id="pageList" resultMap="BaseResultMap">
         SELECT
-        tmp5.statisticalDate as statisticalDate,SUM(tmp5.statisticalHours) as statisticalHours
-        FROM (SELECT
-        tmp3.statisticalDate,
-        tmp3.task_code,
-        TIMESTAMPDIFF(MINUTE, tmp3.request_time, tmp4.request_time) / 60 AS statisticalHours
-        FROM (SELECT
-        tmp1.statisticalDate,
-        tmp1.task_code,
-        tmp1.request_time
-        FROM (SELECT
-        left( a.request_time,10) AS statisticalDate,
-        a.task_code,
-        a.request_time,
-        a.method
-        FROM imcs_hik_agv_detail_info a where a.method = 'start') tmp1 ${ew.customSqlSegment} ) tmp3
-        LEFT JOIN (SELECT
-        tmp2.task_code,
-        tmp2.request_time
-        FROM (SELECT
-        left( b.request_time,10) AS statisticalDate,
-        b.task_code,
-        b.request_time,
-        b.method
-        FROM imcs_hik_agv_detail_info b where b.method = 'end') tmp2 ${ew.customSqlSegment} ) tmp4
-        ON tmp3.task_code = tmp4.task_code) tmp5
+            LEFT(ihadi.request_time, 10) AS statisticalDate,
+            SUM(TIMESTAMPDIFF(MINUTE, STR_TO_DATE(ihadi.request_time, '%Y-%m-%d %H:%i:%s'), STR_TO_DATE(ihadi.callback_time, '%Y-%m-%d %H:%i:%s')) / 60) AS statisticalHours
+        FROM imcs_hik_agv_detail_info ihadi where 1=1
+        <if test="statisticalBeginDate != null and statisticalBeginDate != ''">
+            and ihadi.request_time <![CDATA[ >= ]]> #{statisticalBeginDate}
+        </if>
+        <if test="statisticalEndDate != null and statisticalEndDate != ''">
+            and ihadi.request_time <![CDATA[ <= ]]> #{statisticalEndDate}
+        </if>
+        group by LEFT(ihadi.request_time, 10)) tmp ${ew.customSqlSegment}
+--         SELECT
+--         tmp5.statisticalDate as statisticalDate,SUM(tmp5.statisticalHours) as statisticalHours
+--         FROM (SELECT
+--         tmp3.statisticalDate,
+--         tmp3.task_code,
+--         TIMESTAMPDIFF(MINUTE, tmp3.request_time, tmp4.request_time) / 60 AS statisticalHours
+--         FROM (SELECT
+--         tmp1.statisticalDate,
+--         tmp1.task_code,
+--         tmp1.request_time
+--         FROM (SELECT
+--         left( a.request_time,10) AS statisticalDate,
+--         a.task_code,
+--         a.request_time,
+--         a.method
+--         FROM imcs_hik_agv_detail_info a where a.method = 'start') tmp1 ${ew.customSqlSegment} ) tmp3
+--         LEFT JOIN (SELECT
+--         tmp2.task_code,
+--         tmp2.request_time
+--         FROM (SELECT
+--         left( b.request_time,10) AS statisticalDate,
+--         b.task_code,
+--         b.request_time,
+--         b.method
+--         FROM imcs_hik_agv_detail_info b where b.method = 'end') tmp2 ${ew.customSqlSegment} ) tmp4
+--         ON tmp3.task_code = tmp4.task_code) tmp5
     </select>
 
 

+ 29 - 21
imcs-admin-boot/imcs-business-biz/src/main/resources/mapper_business/base/statisticalAnalysis/ProductLinePerformanceMapper.xml

@@ -5,19 +5,19 @@
     <select id="pageList" resultType="com.github.zuihou.business.operationManagementCenter.entity.TaskNode">
         SELECT tmp1.productionlineId,tmp1.productionlineName,tmp1.statisticalDate,SUM(TIMESTAMPDIFF(MINUTE, tmp1.start_time, tmp1.end_time) / 60) AS statisticalHours FROM
         (SELECT
-          a.id AS productionlineId,
-          a.name AS productionlineName,
+          izz.id AS productionlineId,
+          izz.name AS productionlineName,
           date_format(d.start_time,'%Y-%m') AS statisticalDate,
           d.start_time,
           d.end_time,
           SUM(TIMESTAMPDIFF(MINUTE, d.start_time,d.end_time) / 60) AS statisticalHours
-        FROM zuihou_base_yj_0000.imcs_tenant_productionline a,
-             zuihou_base_yj_0000.imcs_tenant_productionresource b,
+        FROM zuihou_base_yj_0000.imcs_z_zone izz,
+             zuihou_base_yj_0000.imcs_o_order ioo,
              zuihou_base_yj_0000.imcs_t_task c,
              zuihou_base_yj_0000.imcs_t_task_node d,
              zuihou_base_yj_0000.c_auth_user e
-      WHERE a.id = b.productionline_id
-        AND b.id = c.resource_id
+      WHERE izz.id = ioo.zone_id
+        AND ioo.id = c.order_id
         AND c.id = d.task_id
         AND d.loading_user_id = e.id
         AND d.exe_status = '3'
@@ -31,17 +31,17 @@
           (select f.label from c_core_org f where e.org_id = f.id) as orgName,
           date_format(d.start_time,'%Y-%m') AS statisticalDate,
           SUM(TIMESTAMPDIFF(MINUTE, d.start_time,d.end_time) / 60) AS statisticalHours
-        FROM zuihou_base_yj_0000.imcs_tenant_productionline a,
-             zuihou_base_yj_0000.imcs_tenant_productionresource b,
+        FROM zuihou_base_yj_0000.imcs_z_zone izz,
+             zuihou_base_yj_0000.imcs_o_order ioo,
              zuihou_base_yj_0000.imcs_t_task c,
              zuihou_base_yj_0000.imcs_t_task_node d,
              zuihou_base_yj_0000.c_auth_user e
-      WHERE a.id = b.productionline_id
-        AND b.id = c.resource_id
+      WHERE izz.id = ioo.zone_id
+        AND ioo.id = c.order_id
         AND c.id = d.task_id
         AND d.loading_user_id = e.id
         AND d.exe_status = '3'
-        AND d.loading_user_id IS NOT NULL and a.id = #{productionlineId} and date_format(d.start_time,'%Y-%m') = #{statisticalDate} GROUP BY statisticalDate,d.loading_user_id order by e.name
+        AND d.loading_user_id IS NOT NULL and izz.id = #{productionlineId} and date_format(d.start_time,'%Y-%m') = #{statisticalDate} GROUP BY statisticalDate,d.loading_user_id order by e.name
     </select>
 
     <select id="queryOperatorDetailsPerformance" parameterType="com.github.zuihou.business.operationManagementCenter.entity.TaskNode" resultType="com.github.zuihou.business.operationManagementCenter.entity.TaskNode">
@@ -51,13 +51,13 @@
           (select f.label from c_core_org f where e.org_id = f.id) as orgName,
           date_format(d.start_time,'%Y-%m-%d') AS statisticalDate,
           SUM(TIMESTAMPDIFF(MINUTE, d.start_time,d.end_time) / 60) AS statisticalHours
-        FROM zuihou_base_yj_0000.imcs_tenant_productionline a,
-             zuihou_base_yj_0000.imcs_tenant_productionresource b,
+        FROM zuihou_base_yj_0000.imcs_z_zone izz,
+             zuihou_base_yj_0000.imcs_o_order ioo,
              zuihou_base_yj_0000.imcs_t_task c,
              zuihou_base_yj_0000.imcs_t_task_node d,
              zuihou_base_yj_0000.c_auth_user e
-      WHERE a.id = b.productionline_id
-        AND b.id = c.resource_id
+      WHERE izz.id = ioo.zone_id
+        AND ioo.id = c.order_id
         AND c.id = d.task_id
         AND d.loading_user_id = e.id
         AND d.exe_status = '3'
@@ -67,17 +67,25 @@
 
     <select id="queryProductionLineOee" resultType="com.github.zuihou.business.operationManagementCenter.entity.TaskNode">
         SELECT
-          b.name AS resourceName,
+          itp.name AS resourceName,
           SUM(TIMESTAMPDIFF(MINUTE, d.start_time,d.end_time) / 60) / ${monthHour}  AS resourceOee
-        FROM zuihou_base_yj_0000.imcs_tenant_productionline a,
-             zuihou_base_yj_0000.imcs_tenant_productionresource b,
+        FROM zuihou_base_yj_0000.imcs_z_zone a,
+             zuihou_base_yj_0000.imcs_z_zone_productionresource b,
+             zuihou_base_yj_0000.imcs_tenant_productionresource itp,
              zuihou_base_yj_0000.imcs_t_task c,
              zuihou_base_yj_0000.imcs_t_task_node d,
              zuihou_base_yj_0000.c_auth_user e
-      WHERE a.id = b.productionline_id
-        AND b.id = c.resource_id
+      WHERE a.id = b.zone_id
+        AND b.resource_id = c.resource_id
+        AND b.resource_id = itp.id
         AND c.id = d.task_id
         AND d.exe_status = '3'
-        and date_format(d.start_time,'%Y-%m') = #{statisticalDate} and  a.id = #{productionlineId} GROUP BY  b.id  order by b.id
+        <if test="statisticalDate != null and statisticalDate != ''">
+            and date_format(d.start_time,'%Y-%m') = #{statisticalDate}
+        </if>
+        <if test="productionlineId != null and productionlineId != '' and productionlineId != 0 ">
+            and a.id = #{productionlineId}
+        </if>
+        GROUP BY  itp.id  order by itp.id
     </select>
 </mapper>

+ 7 - 7
imcs-admin-boot/imcs-business-controller/src/main/java/com/github/zuihou/business/controller/externalApi/AgvHikOrderDetailInfoController.java

@@ -65,7 +65,6 @@ public class AgvHikOrderDetailInfoController extends SuperController<AgvHikOrder
         AgvHikOrderDetailInfoPageDTO data = params.getModel();
         QueryWrap<AgvHikOrderDetailInfo> wrap = handlerWrapper(null, params);
         LbqWrapper<AgvHikOrderDetailInfo> wrapper = wrap.lambda();
-        AgvHikOrderDetailInfo agvHikOrderDetailInfo = BeanUtil.toBean(data, AgvHikOrderDetailInfo.class);
         String statisticalBeginDate;
         String statisticalEndDate;
         if(null == data.getStatisticalDate()){
@@ -75,11 +74,12 @@ public class AgvHikOrderDetailInfoController extends SuperController<AgvHikOrder
             statisticalBeginDate = data.getStatisticalDate() + " 00:00:00";
             statisticalEndDate =  data.getStatisticalDate() + " 23:59:59";
         }
-        wrapper.between(AgvHikOrderDetailInfo::getRequestTime,statisticalBeginDate,statisticalEndDate);
-        OrderItem orderItem = new OrderItem();
-        orderItem.setColumn("statisticalDate").setAsc(false);
-        page.orders().remove(0);
-        page.orders().add(orderItem);
-        baseService.pageList(page, wrapper);
+//        wrapper.gt(AgvHikOrderDetailInfo::getRequestTime,statisticalBeginDate);
+//        wrapper.lt(AgvHikOrderDetailInfo::getRequestTime,statisticalEndDate);
+//        OrderItem orderItem = new OrderItem();
+//        orderItem.setColumn("statisticalDate").setAsc(false);
+//        page.orders().remove(0);
+//        page.orders().add(orderItem);
+        baseService.pageList(page,statisticalBeginDate,statisticalEndDate, wrapper);
     }
 }

+ 1 - 0
imcs-admin-boot/imcs-business-controller/src/main/java/com/github/zuihou/business/controller/externalApi/HikAgvControl.java

@@ -103,6 +103,7 @@ public class HikAgvControl extends SuperController<AgvHikOrderInfoService, Long,
         if(null != agvHikOrderDetailInfo){
             AgvHikOrderDetailInfo callbackInfo = JSONObject.parseObject(JSONObject.toJSONString(data),AgvHikOrderDetailInfo.class);
             BeanUtil.copyProperties(agvHikOrderDetailInfo,callbackInfo);
+            agvHikOrderDetailInfo.setCallbackTime(DateUtil.format(Calendar.getInstance().getTime(), DatePattern.NORM_DATETIME_MS_PATTERN));
             agvHikOrderDetailInfoService.updateAllById(agvHikOrderDetailInfo);
 //            return R.success();
         }else{