Преглед на файлове

-- 添加event获取电量

star преди 1 година
родител
ревизия
a91ad3aefe

+ 15 - 1
ruoyi-admin/src/main/java/com/ruoyi/web/controller/warewms/test/ChargingMachineTestController.java

@@ -4,6 +4,7 @@ import cn.hutool.json.JSONUtil;
 import com.jwk.spring.boot.autoconfigure.ModbusTcpMasterTemplate;
 import com.jwk.spring.boot.modbus4j.ModbusMasterUtil;
 import com.ruoyi.ams.agv.ndc.service.FeedbackTS;
+import com.ruoyi.ams.agv.ndc.service.StatusUpdateService;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.hard.modbus.tcp.ChargingMachineClient;
 import com.ruoyi.hard.modbus.tcp.ModbusTcpWeigherClient;
@@ -37,6 +38,8 @@ public class ChargingMachineTestController {
     private ModbusTcpWeigherClient modbusTcpWeigherClient;
     @Autowired
     private FeedbackTS feedbackTS;
+    @Autowired
+    private StatusUpdateService statusUpdateService;
 
     /**
      * 充电机(三向车)
@@ -124,6 +127,18 @@ public class ChargingMachineTestController {
         return AjaxResult.success();
     }
 
+    /**
+     * 修改电量
+     */
+    @ApiOperation("查询充电机状态")
+    @PostMapping("/updCarBattery")
+    public AjaxResult updCarBattery(@RequestBody Map<String, String> map) {
+        Integer agvNo = Integer.valueOf(map.get("agvNo"));
+        Integer battery = Integer.valueOf(map.get("battery"));
+        statusUpdateService.addBattery(agvNo, battery);
+        return AjaxResult.success();
+    }
+
     @ApiOperation("道闸开门清除")
     @PostMapping("/clearOpenDZ")
     public Boolean clearOpenDZ() {
@@ -135,7 +150,6 @@ public class ChargingMachineTestController {
         return  modbusTcpWeigherClient.clearCloseState();
     }
 
-
     @ApiOperation("道闸开门")
     @PostMapping("/sendOpenDZ")
     public Boolean sendOpenDZ() {

+ 4 - 0
warewms-ams/src/main/java/com/ruoyi/ams/agv/car/mapper/CarInfoMapper.java

@@ -17,4 +17,8 @@ public interface CarInfoMapper extends BaseMapper<CarInfo> {
 
 
     List<CarInfo> queryCarInfos();
+
+    CarInfo queryInfoByCarNo(Integer carNo);
+
+    int updateCarInfo(CarInfo carInfo);
 }

+ 6 - 0
warewms-ams/src/main/java/com/ruoyi/ams/agv/car/service/ICarInfoService.java

@@ -1,6 +1,8 @@
 package com.ruoyi.ams.agv.car.service;
 
+import com.ruoyi.ams.agv.car.domain.CarInfo;
 import com.ruoyi.ams.agv.car.dto.CarInfoDTO;
+import com.ruoyi.base.domain.BaseLocationInfo;
 
 import java.util.List;
 
@@ -13,4 +15,8 @@ import java.util.List;
 public interface ICarInfoService {
 
     List<CarInfoDTO> queryCarInfo();
+
+    CarInfo queryInfoByCarNo(Integer carNo);
+
+    int updateCarInfo(CarInfo carInfo);
 }

+ 12 - 0
warewms-ams/src/main/java/com/ruoyi/ams/agv/car/service/impl/CarInfoServiceImpl.java

@@ -47,4 +47,16 @@ public class CarInfoServiceImpl implements ICarInfoService {
         }).collect(Collectors.toList());
     }
 
+    @Override
+    public CarInfo queryInfoByCarNo(Integer carNo) {
+        CarInfo carInfo = carInfoMapper.queryInfoByCarNo(carNo);
+        return carInfo;
+    }
+
+    @Override
+    public int updateCarInfo(CarInfo carInfo) {
+        return carInfoMapper.updateCarInfo(carInfo);
+    }
+
+
 }

+ 5 - 0
warewms-ams/src/main/java/com/ruoyi/ams/agv/ndc/service/StatusUpdateService.java

@@ -49,6 +49,11 @@ public interface StatusUpdateService {
     void confirmAnalysisWeighing(String taskNo, Integer aciIndex, Integer carNo
             , String updateLocation, String updateValue);
 
+    /**
+     * 车辆当前电量
+     */
+    void addBattery(Integer carNo,Integer battery);
+
 
     /**
      * 回告ts门已经打开

+ 9 - 0
warewms-ams/src/main/java/com/ruoyi/ams/agv/ndc/service/impl/SocketBufferServiceImpl.java

@@ -1,6 +1,7 @@
 package com.ruoyi.ams.agv.ndc.service.impl;
 
 import com.alibaba.fastjson.JSON;
+import com.ruoyi.ams.agv.car.domain.CarInfo;
 import com.ruoyi.ams.agv.ndc.common.Aci;
 import com.ruoyi.ams.agv.ndc.common.ByteUtil;
 import com.ruoyi.ams.agv.ndc.domain.AmsNdcEvent;
@@ -277,6 +278,14 @@ public class SocketBufferServiceImpl implements SocketBufferService {
                         });
                     }
                     break;
+                case 125: // 595
+                    log.info("电量获取!" + "-" + JSON.toJSONString(event));
+                    Integer carNo = Integer.parseInt(event.getLp2()); //车号
+                    Integer battery = Integer.parseInt(event.getLp3()); //电量
+                    executorService.execute(() -> {
+                        statusUpdateService.addBattery(carNo,battery);
+                    });
+                    break;
                 case 126: //547 道闸开门
                     log.info("道闸-请求开启!" + "-" + JSON.toJSONString(event));
                     String lp1_126 = event.getLp3();

+ 17 - 2
warewms-ams/src/main/java/com/ruoyi/ams/agv/ndc/service/impl/StatusUpdateServiceImpl.java

@@ -1,6 +1,8 @@
 package com.ruoyi.ams.agv.ndc.service.impl;
 
 import cn.hutool.core.thread.ThreadUtil;
+import com.ruoyi.ams.agv.car.domain.CarInfo;
+import com.ruoyi.ams.agv.car.service.ICarInfoService;
 import com.ruoyi.ams.agv.ndc.domain.AmsTask;
 import com.ruoyi.ams.agv.ndc.entity.CallbackResult;
 import com.ruoyi.ams.agv.ndc.service.IAmsTaskService;
@@ -40,6 +42,8 @@ public class StatusUpdateServiceImpl implements StatusUpdateService {
     private IInvLotLocIdService invLotLocIdService;
     @Autowired
     private RedisCache redisCache;
+    @Autowired
+    private ICarInfoService iCarInfoService;
 
     public enum AGV_ACTION {
         /***
@@ -231,6 +235,19 @@ public class StatusUpdateServiceImpl implements StatusUpdateService {
         }
     }
 
+    @Override
+    public void addBattery(Integer carNo, Integer battery) {
+
+        CarInfo carInfo = iCarInfoService.queryInfoByCarNo(carNo);
+
+        if(carInfo != null){
+            carInfo.setBattery(battery/10+"");
+            iCarInfoService.updateCarInfo(carInfo);
+        }else{
+            log.info("StatusUpdateServiceImpl-addBattery-电量获取-未查询到车辆信息!");
+        }
+    }
+
     @Override
     public void feedbackTS(Integer doorNo) {
         AmsTask addTaskForm = new AmsTask();
@@ -292,8 +309,6 @@ public class StatusUpdateServiceImpl implements StatusUpdateService {
         }
     }
 
-
-
     @Override
     public void gateOpen(Integer doorNo){
 

+ 3 - 5
warewms-ams/src/main/java/com/ruoyi/ams/business/BusinessServiceImpl.java

@@ -151,7 +151,7 @@ public class BusinessServiceImpl implements IBusinessService {
 
                     List<BaseLocationInfo> locationFromList = new ArrayList<>();
                     //如果是中转入库
-                    if(agvCallDTO.getTheWeighing()){
+                    if(agvCallDTO.getAsnType()){
 
                         locationFromList = baseLocationInfoMapper.selectSortedLocationLotattListByZoneIdListOrderBy(zoneIdList
                                 , Constant.WAREHOUSE_ID, map, "", "inv.create_time");
@@ -334,8 +334,7 @@ public class BusinessServiceImpl implements IBusinessService {
             }
         }
         if (locationType.equals("locationFrom")) {
-            for (BaseLocationInfo b : locationInfoList) {
-            }
+
             locationInfo = checkTheSameColumnLocation(locationInfoList, token, false);
             if (locationInfo == null) {
                 if (type.equals("ASN")) { // 入库
@@ -348,8 +347,7 @@ public class BusinessServiceImpl implements IBusinessService {
                 throw new ServiceException(fromMsg, token);
             }
         } else {
-            for (BaseLocationInfo b : locationInfoList) {
-            }
+
             locationInfo = checkTheSameColumnLocation(locationInfoList, token, true);
             if (locationInfo == null) {
                 if (type.equals("ASN")) { // 入库

+ 1 - 0
warewms-ams/src/main/java/com/ruoyi/ams/config/domain/dto/AgvCallDTO.java

@@ -18,6 +18,7 @@ public class AgvCallDTO {
     private Long warehouseId;
     private String createUser;
     private Boolean theWeighing; // 是否复称
+    private Boolean asnType; // TRUE-中转入库  FALSE-中转入库
     private String ext3; //任务类型
     private List<AgvCallItemDTO> agvCallItemDTOList = new ArrayList<>();
 }

+ 5 - 0
warewms-ams/src/main/java/com/ruoyi/ams/nieyan/service/impl/AgvCallProxyService.java

@@ -388,6 +388,7 @@ public class AgvCallProxyService {
         agvCallDTO.setTheWeighing(theWeighing);
         agvCallDTO.setExt3(queryTaskType(theWrapped,theWeighing,bliList));
         agvCallDTO.setAgvCallItemDTOList(agvCallItemDTOList);
+        agvCallDTO.setAsnType(false);//下线入库
         // 增加硫酸镍标识
         for (AgvCallItemDTO agvCallItemDTO : agvCallItemDTOList) {
             agvCallItemDTO.getLotattDTO().setLotatt18("Y"); //是否硫酸镍,Y代表否
@@ -415,6 +416,7 @@ public class AgvCallProxyService {
         agvCallDTO.setCreateUser(createUser);
         agvCallDTO.setTheWeighing(theWeighing);
         agvCallDTO.setAgvCallItemDTOList(agvCallItemDTOList);
+        agvCallDTO.setAsnType(false);//下线入库
         createWmsDoc(createUser, agvCallItemDTOList);
         return iBusinessService.agvCall(Constant.FLOW_CONFIG_ID.NINE.getValue(), agvCallDTO);
     }
@@ -444,6 +446,7 @@ public class AgvCallProxyService {
         agvCallDTO.setCreateUser(createUser);
         agvCallDTO.setTheWeighing(theWeighing);
         agvCallDTO.setExt3(queryTaskType(theWrapped,theWeighing,bliList));
+        agvCallDTO.setAsnType(false);//下线入库
         agvCallDTO.setAgvCallItemDTOList(agvCallItemDTOList);
         // 增加氯化镍标识
         for (AgvCallItemDTO agvCallItemDTO : agvCallItemDTOList) {
@@ -473,6 +476,7 @@ public class AgvCallProxyService {
         agvCallDTO.setCreateUser(createUser);
         agvCallDTO.setTheWeighing(theWeighing);
         agvCallDTO.setAgvCallItemDTOList(agvCallItemDTOList);
+        agvCallDTO.setAsnType(false);//下线入库
         createWmsDoc(createUser, agvCallItemDTOList);
         return iBusinessService.agvCall(Constant.FLOW_CONFIG_ID.TWELVE.getValue(), agvCallDTO);
     }
@@ -534,6 +538,7 @@ public class AgvCallProxyService {
         if(theWrapped && bliList.size() < 1) return AjaxResult.error("裹膜库位被占用,无法下发任务,请确认库位状态!");
 
         AgvCallDTO agvCallDTO = new AgvCallDTO();
+        agvCallDTO.setAsnType(true);//中转入库
         agvCallDTO.setTheWeighing(true);
         agvCallDTO.setExt3(queryTaskType(theWrapped,theWeighing,bliList));
         agvCallDTO.setCreateUser(createUser);

+ 24 - 0
warewms-ams/src/main/resources/mapper/ams/CarInfoMapper.xml

@@ -25,4 +25,28 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         from car_info
         order by carNo
     </select>
+
+    <select id="queryInfoByCarNo" resultMap="CarInfoResult" parameterType="Object">
+        select *
+        from car_info
+        where carNo = #{carNo}
+    </select>
+
+    <update id="updateCarInfo">
+        update car_info
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="state != null">state = #{state},</if>
+            <if test="activeFlag != null">active_flag = #{activeFlag},</if>
+            <if test="userdefine1 != null">userdefine1 = #{userdefine1},</if>
+            <if test="userdefine2 != null">userdefine2 = #{userdefine2},</if>
+            <if test="userdefine3 != null">userdefine3 = #{userdefine3},</if>
+            <if test="userdefine4 != null">userdefine4 = #{userdefine4},</if>
+            <if test="userdefine5 != null">userdefine5 = #{userdefine5},</if>
+            <if test="battery != null">battery = #{battery},</if>
+            <if test="x != null">x = #{x},</if>
+            <if test="y != null">y = #{y},</if>
+        </trim>
+        where carNo = #{carNo}
+    </update>
+
 </mapper>