瀏覽代碼

任务定时调度

wudingsheng 11 月之前
父節點
當前提交
54c3df63f7

+ 2 - 0
src/main/java/com/imcs/admin/business/controller/WInventoryTransactionTaskController.java

@@ -84,5 +84,7 @@ public class WInventoryTransactionTaskController {
         return ResponseEntity.ok(this.wInventoryTransactionTaskService.deleteById(id));
     }
 
+
+
 }
 

+ 83 - 0
src/main/java/com/imcs/admin/business/dao/WDeviceDao.java

@@ -0,0 +1,83 @@
+package com.imcs.admin.business.dao;
+
+import com.imcs.admin.entity.WDevice;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.data.domain.Pageable;
+import java.util.List;
+
+/**
+ * 设备管理(WDevice)表数据库访问层
+ *
+ * @author makejava
+ * @since 2024-07-29 12:50:55
+ */
+public interface WDeviceDao {
+
+    /**
+     * 通过ID查询单条数据
+     *
+     * @param id 主键
+     * @return 实例对象
+     */
+    WDevice queryById(Long id);
+
+    /**
+     * 查询指定行数据
+     *
+     * @param wDevice 查询条件
+     * @param pageable         分页对象
+     * @return 对象列表
+     */
+    List<WDevice> queryAllByLimit(WDevice wDevice, @Param("pageable") Pageable pageable);
+
+    /**
+     * 统计总行数
+     *
+     * @param wDevice 查询条件
+     * @return 总行数
+     */
+    long count(WDevice wDevice);
+
+    /**
+     * 新增数据
+     *
+     * @param wDevice 实例对象
+     * @return 影响行数
+     */
+    int insert(WDevice wDevice);
+
+    /**
+     * 批量新增数据(MyBatis原生foreach方法)
+     *
+     * @param entities List<WDevice> 实例对象列表
+     * @return 影响行数
+     */
+    int insertBatch(@Param("entities") List<WDevice> entities);
+
+    /**
+     * 批量新增或按主键更新数据(MyBatis原生foreach方法)
+     *
+     * @param entities List<WDevice> 实例对象列表
+     * @return 影响行数
+     * @throws org.springframework.jdbc.BadSqlGrammarException 入参是空List的时候会抛SQL语句错误的异常,请自行校验入参
+     */
+    int insertOrUpdateBatch(@Param("entities") List<WDevice> entities);
+
+    /**
+     * 修改数据
+     *
+     * @param wDevice 实例对象
+     * @return 影响行数
+     */
+    int update(WDevice wDevice);
+
+    /**
+     * 通过主键删除数据
+     *
+     * @param id 主键
+     * @return 影响行数
+     */
+    int deleteById(Long id);
+
+}
+

+ 51 - 33
src/main/java/com/imcs/admin/business/job/ScheduledTask.java

@@ -1,38 +1,27 @@
 package com.imcs.admin.business.job;
 
-import cn.hutool.core.lang.Assert;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.google.gson.Gson;
-import com.google.gson.JsonElement;
 import com.google.gson.JsonObject;
 import com.google.gson.JsonParser;
 import com.imcs.admin.business.constants.Status;
-import com.imcs.admin.business.dao.WApiCallRecordsDao;
 import com.imcs.admin.business.service.impl.BaseServiceImpl;
 import com.imcs.admin.entity.WApiCallRecords;
+import com.imcs.admin.entity.WDevice;
 import com.imcs.admin.entity.WInventoryTransactionChildTask;
 import com.imcs.admin.entity.WInventoryTransactionTask;
-import com.imcs.admin.entity.WInventoryTransactionTaskDetail;
-import com.imcs.admin.util.CollectionUtil;
-import lombok.Data;
+import com.imcs.admin.vo.LocationData;
+import com.imcs.admin.vo.RequestData;
 import lombok.extern.slf4j.Slf4j;
-import okhttp3.OkHttpClient;
-import okhttp3.RequestBody;
+import okhttp3.*;
 import org.apache.commons.collections4.CollectionUtils;
-import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
-
-import okhttp3.Request;
-import okhttp3.Response;
-
-import java.io.IOException;
-
-import okhttp3.MediaType;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.io.IOException;
 import java.io.PrintWriter;
 import java.io.StringWriter;
 import java.util.Date;
@@ -50,13 +39,16 @@ public class ScheduledTask extends BaseServiceImpl {
 
     public static final MediaType JSON = MediaType.get("application/json; charset=utf-8");
 
+    public static final String redisStr="WMS:JOB_LOCK_";
 
+    @Value("${wcs.url}")
+    public String url;
     /**
      * 出入库任务定时调度
      *
      * @throws Exception
      */
-    //@Scheduled(cron = "*/10 * * * * *")
+    @Scheduled(cron = "*/10 * * * * *")
     @GetMapping("/startTask")
     public void startTask() throws Exception {
         //查出task表id最小的一条status= 0 1 的数据
@@ -64,53 +56,79 @@ public class ScheduledTask extends BaseServiceImpl {
         //如果任务状态是 未开始 或 异常,则调C#接口
 
         List<WInventoryTransactionTask> wInventoryTransactionTask = taskDao.selectOne();
-        Assert.notNull(wInventoryTransactionTask);
         wInventoryTransactionTask.stream().parallel().forEach(vo->{
-            Object jobLock = redisTemplate.opsForValue().get("JOB_LOCK_"+vo.getDeviceId());
+            Object jobLock = redisTemplate.opsForValue().get(redisStr+vo.getDeviceId());
             if (!Objects.isNull(jobLock)) {
                 return;
             }
             List<WInventoryTransactionChildTask> wInventoryTransactionTaskDetails = childTaskDao.selectListByTaskId(vo);
             if (CollectionUtils.isNotEmpty(wInventoryTransactionTaskDetails)) {
                 WInventoryTransactionChildTask wInventoryTransactionChildTask = wInventoryTransactionTaskDetails.get(0);
+                Object taskLock = redisTemplate.opsForValue().get(redisStr+wInventoryTransactionChildTask.getChildTaskCode());
+                if (!Objects.isNull(taskLock)) {
+                    return;
+                }
                 if (wInventoryTransactionChildTask.getStatus() == Status.NOT_STARTED.getCode() || wInventoryTransactionChildTask.getStatus() == Status.EXCEPTION.getCode()) {
-                    redisTemplate.opsForValue().set("JOB_LOCK_"+vo.getDeviceId(), true);
-                    httpHandler(wInventoryTransactionChildTask,vo.getDeviceId());
+                    redisTemplate.opsForValue().set(redisStr+vo.getDeviceId(), true);
+
+
+
+                    WDevice wDevice = wDeviceDao.queryById(vo.getDeviceId());
+
+                    httpHandler(wInventoryTransactionChildTask,vo,wDevice);
                 }
             }
         });
     }
 
-    private void httpHandler(WInventoryTransactionChildTask item,Long deviceId) {
+    private void httpHandler(WInventoryTransactionChildTask item,WInventoryTransactionTask task,WDevice wDevice) {
+        RequestData requestData=new RequestData();
+        requestData.setIp(wDevice.getIp());
+        requestData.setTaskId(task.getTaskCode());
+        requestData.setTaskNodeId(item.getChildTaskCode());
+
+        LocationData locationData=new LocationData();
+        locationData.setStartPosition(item.getStartPosition());
+        locationData.setEndPosition(item.getEndPosition());
+        if(item.getGetResult()==null){
+            locationData.setType(0);
+        }else{
+            locationData.setType(1);
+        }
+        locationData.setOperateType(locationData.getType()==0?"Get":"Send");
+        requestData.setLocationData(locationData);
         String responseBody = null;
         Date responseTime = null;
-        String url = "http://127.0.0.1:8081";
+        //String url = "http://127.0.0.1:8081";
         Date requestTime = new Date();
-        String json = "{\"title\":\"foo\",\"body\":\"bar\",\"userId\":1}";
+        Gson gson = new Gson();
+        String json = gson.toJson(requestData);
+        log.info("报文请求:{}",json);
+        //String json = "{\"title\":\"foo\",\"body\":\"bar\",\"userId\":1}";
         try {
             OkHttpClient okHttpClient = new OkHttpClient();
 
             RequestBody body = RequestBody.create(json, JSON);
-
-
             Request request = new Request.Builder()
                     .url(url)
                     .post(body)
                     .build();
 
-            //Response response = okHttpClient.newCall(request).execute();
+            Response response = okHttpClient.newCall(request).execute();
             responseTime = new Date();
-            //if (!response.isSuccessful()) throw new IOException("Unexpected code " + response);
+            if (!response.isSuccessful()) throw new IOException("Unexpected code " + response);
 
             // 获取响应体
-            //responseBody = response.body().string();
-            responseBody = "{\"success\":true,\"errmsg\":\"123\"}";
+            responseBody = response.body().string();
+            //responseBody = "{\"success\":true,\"errmsg\":\"123\"}";
 
 
             JsonObject jsonObject = JsonParser.parseString(responseBody).getAsJsonObject();
 
             // 修改任务状态
-            if (jsonObject.get("success").getAsBoolean()) {
+            if (jsonObject.get("IsSuccess").getAsBoolean()) {
+
+                redisTemplate.opsForValue().set(redisStr+item.getChildTaskCode(), true);
                 item.setStatus(Status.IN_PROGRESS_TASK.getCode());
                 childTaskDao.updateById(item);
 
@@ -143,7 +161,7 @@ public class ScheduledTask extends BaseServiceImpl {
             e.printStackTrace(pw);
             responseBody = sw.toString();
         } finally {
-            redisTemplate.opsForValue().getAndDelete("JOB_LOCK_"+deviceId);
+            redisTemplate.opsForValue().getAndDelete(redisStr+task.getDeviceId());
             log.error("释放定时任务调度锁");
             insertApiLog(json, responseBody, url, requestTime, responseTime, item);
         }

+ 3 - 0
src/main/java/com/imcs/admin/business/service/impl/BaseServiceImpl.java

@@ -98,6 +98,9 @@ public class BaseServiceImpl {
     @Resource
     public WDeviceShelfDao wDeviceShelfDao;
 
+    @Resource
+    public WDeviceDao wDeviceDao;
+
 
     /**
      * 获取登录人信息

+ 3 - 1
src/main/java/com/imcs/admin/business/service/impl/WStorageLocationManagementServiceImpl.java

@@ -71,9 +71,11 @@ public class WStorageLocationManagementServiceImpl extends BaseServiceImpl imple
         wInventoryTransactionTask.setStartPosition(startPosition);
 
         wInventoryTransactionTask.setEndPosition(endPosition);
-        wInventoryTransactionTask.setDeviceId(getDeviceByStorage(endPosition));
+
+        wInventoryTransactionTask.setDeviceId(getDeviceByStorage(startPosition));
         wInventoryTransactionTask.setVectorCode(palletCode);
         wInventoryTransactionTask.setStatus(0);
+        //出库
         wInventoryTransactionTask.setTaskType(1);
         wInventoryTransactionTask.setCreatedAt(new Date());
         wInventoryTransactionTask.setCreatedBy(getUserId());

+ 172 - 0
src/main/java/com/imcs/admin/entity/WDevice.java

@@ -0,0 +1,172 @@
+package com.imcs.admin.entity;
+
+import java.io.Serializable;
+
+/**
+ * 设备管理(WDevice)实体类
+ *
+ * @author makejava
+ * @since 2024-07-29 12:51:32
+ */
+public class WDevice implements Serializable {
+    private static final long serialVersionUID = -81029021388311293L;
+/**
+     * 主键
+     */
+    private Long id;
+/**
+     * 设备编号
+     */
+    private String deviceCode;
+/**
+     * 设备名称
+     */
+    private String deviceName;
+/**
+     * 设备型号
+     */
+    private String deviceModel;
+/**
+     * 出厂年份
+     */
+    private String factoryDate;
+/**
+     * 设备厂家
+     */
+    private String factory;
+/**
+     * 备注
+     */
+    private String remark;
+/**
+     * 设备系统
+     */
+    private String deviceSystem;
+/**
+     * 设备类型
+     */
+    private String deviceType;
+/**
+     * 设备图片
+     */
+    private String pic;
+/**
+     * ip
+     */
+    private String ip;
+/**
+     * 设备状态
+     */
+    private String factoryStatus;
+/**
+     * 归属位置
+     */
+    private String homePosition;
+
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getDeviceCode() {
+        return deviceCode;
+    }
+
+    public void setDeviceCode(String deviceCode) {
+        this.deviceCode = deviceCode;
+    }
+
+    public String getDeviceName() {
+        return deviceName;
+    }
+
+    public void setDeviceName(String deviceName) {
+        this.deviceName = deviceName;
+    }
+
+    public String getDeviceModel() {
+        return deviceModel;
+    }
+
+    public void setDeviceModel(String deviceModel) {
+        this.deviceModel = deviceModel;
+    }
+
+    public String getFactoryDate() {
+        return factoryDate;
+    }
+
+    public void setFactoryDate(String factoryDate) {
+        this.factoryDate = factoryDate;
+    }
+
+    public String getFactory() {
+        return factory;
+    }
+
+    public void setFactory(String factory) {
+        this.factory = factory;
+    }
+
+    public String getRemark() {
+        return remark;
+    }
+
+    public void setRemark(String remark) {
+        this.remark = remark;
+    }
+
+    public String getDeviceSystem() {
+        return deviceSystem;
+    }
+
+    public void setDeviceSystem(String deviceSystem) {
+        this.deviceSystem = deviceSystem;
+    }
+
+    public String getDeviceType() {
+        return deviceType;
+    }
+
+    public void setDeviceType(String deviceType) {
+        this.deviceType = deviceType;
+    }
+
+    public String getPic() {
+        return pic;
+    }
+
+    public void setPic(String pic) {
+        this.pic = pic;
+    }
+
+    public String getIp() {
+        return ip;
+    }
+
+    public void setIp(String ip) {
+        this.ip = ip;
+    }
+
+    public String getFactoryStatus() {
+        return factoryStatus;
+    }
+
+    public void setFactoryStatus(String factoryStatus) {
+        this.factoryStatus = factoryStatus;
+    }
+
+    public String getHomePosition() {
+        return homePosition;
+    }
+
+    public void setHomePosition(String homePosition) {
+        this.homePosition = homePosition;
+    }
+
+}
+

+ 9 - 0
src/main/java/com/imcs/admin/entity/WInventoryTransactionChildTask.java

@@ -88,6 +88,15 @@ public class WInventoryTransactionChildTask implements Serializable {
     //父任务的 子任务编码
     private String parentChildTaskCode;
 
+    /**
+     * 取结果
+     */
+    private Integer getResult;
+
+    /**
+     * 放结果
+     */
+    private Integer sendResult;
 
     @TableField(exist = false)
     List<WInventoryTransactionChildTask> suList;

+ 12 - 0
src/main/java/com/imcs/admin/vo/LocationData.java

@@ -0,0 +1,12 @@
+package com.imcs.admin.vo;
+
+import lombok.Data;
+
+@Data
+public class LocationData {
+    private String startPosition;//开始库位
+    private String endPosition;//目标库位
+    private Integer deviceId;
+    private Integer type;//0取 1放
+    private String operateType;//Get  Send
+}

+ 14 - 0
src/main/java/com/imcs/admin/vo/RequestData.java

@@ -0,0 +1,14 @@
+package com.imcs.admin.vo;
+
+import lombok.Data;
+
+@Data
+
+public class RequestData {
+    private String ip;
+    private String url;
+    private String port;
+    private String taskId;//任务编号
+    private String taskNodeId;//子任务编号
+    private LocationData locationData;
+}

+ 9 - 4
src/main/resources/application-dev.properties

@@ -1,8 +1,9 @@
-spring.datasource.url=jdbc:mysql://192.168.50.137:3306/zh_wms_platform?serverTimezone=GMT%2B8&useSSL=false
+#spring.datasource.url=jdbc:mysql://192.168.50.137:3306/zh_wms_platform?serverTimezone=GMT%2B8&useSSL=false
+spring.datasource.url=jdbc:mysql://localhost:3306/zh_wms_platform?serverTimezone=GMT%2B8&useSSL=false
 spring.datasource.username=root
-spring.datasource.password=root
+#spring.datasource.password=root
 #spring.datasource.password=123456789
-#spring.datasource.password=123456
+spring.datasource.password=123456
 
 #spring.datasource.driver-class-name=com.mysql.jdbc.Driver
 
@@ -34,7 +35,9 @@ index-page=/admin/index.html
 # Redis数据库索引(默认为0)  开启sa-token-redis的配置
 spring.redis.database=0
 # Redis服务器地址
-spring.redis.host=192.168.50.137
+#spring.redis.host=192.168.50.137
+spring.redis.host=127.0.0.1
+
 # Redis服务器连接端口
 spring.redis.port=6379
 # Redis服务器连接密码(默认为空)
@@ -49,3 +52,5 @@ spring.redis.lettuce.pool.max-wait=-1ms
 spring.redis.lettuce.pool.max-idle=10
 # 连接池中的最小空闲连接
 spring.redis.lettuce.pool.min-idle=0
+
+wcs.url=http://127.0.0.1:5196/api/Task

+ 199 - 0
src/main/resources/mapper/WDeviceDao.xml

@@ -0,0 +1,199 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.imcs.admin.business.dao.WDeviceDao">
+
+    <resultMap type="com.imcs.admin.entity.WDevice" id="WDeviceMap">
+        <result property="id" column="id" jdbcType="INTEGER"/>
+        <result property="deviceCode" column="device_code" jdbcType="VARCHAR"/>
+        <result property="deviceName" column="device_name" jdbcType="VARCHAR"/>
+        <result property="deviceModel" column="device_model" jdbcType="VARCHAR"/>
+        <result property="factoryDate" column="factory_date" jdbcType="VARCHAR"/>
+        <result property="factory" column="factory" jdbcType="VARCHAR"/>
+        <result property="remark" column="remark" jdbcType="VARCHAR"/>
+        <result property="deviceSystem" column="device_system" jdbcType="VARCHAR"/>
+        <result property="deviceType" column="device_type" jdbcType="VARCHAR"/>
+        <result property="pic" column="pic" jdbcType="VARCHAR"/>
+        <result property="ip" column="ip" jdbcType="VARCHAR"/>
+        <result property="factoryStatus" column="factory_status" jdbcType="VARCHAR"/>
+        <result property="homePosition" column="home_position" jdbcType="VARCHAR"/>
+    </resultMap>
+
+    <!--查询单个-->
+    <select id="queryById" resultMap="WDeviceMap">
+        select
+*
+        from w_device
+        where id = #{id}
+    </select>
+
+    <!--查询指定行数据-->
+    <select id="queryAllByLimit" resultMap="WDeviceMap">
+        select
+*
+        from w_device
+        <where>
+            <if test="id != null">
+                and id = #{id}
+            </if>
+            <if test="deviceCode != null and deviceCode != ''">
+                and device_code = #{deviceCode}
+            </if>
+            <if test="deviceName != null and deviceName != ''">
+                and device_name = #{deviceName}
+            </if>
+            <if test="deviceModel != null and deviceModel != ''">
+                and device_model = #{deviceModel}
+            </if>
+            <if test="factoryDate != null and factoryDate != ''">
+                and factory_date = #{factoryDate}
+            </if>
+            <if test="factory != null and factory != ''">
+                and factory = #{factory}
+            </if>
+            <if test="remark != null and remark != ''">
+                and remark = #{remark}
+            </if>
+            <if test="deviceSystem != null and deviceSystem != ''">
+                and device_system = #{deviceSystem}
+            </if>
+            <if test="deviceType != null and deviceType != ''">
+                and device_type = #{deviceType}
+            </if>
+            <if test="pic != null and pic != ''">
+                and pic = #{pic}
+            </if>
+            <if test="ip != null and ip != ''">
+                and ip = #{ip}
+            </if>
+            <if test="factoryStatus != null and factoryStatus != ''">
+                and factory_status = #{factoryStatus}
+            </if>
+            <if test="homePosition != null and homePosition != ''">
+                and home_position = #{homePosition}
+            </if>
+        </where>
+        limit #{pageable.offset}, #{pageable.pageSize}
+    </select>
+
+    <!--统计总行数-->
+    <select id="count" resultType="java.lang.Long">
+        select count(1)
+        from w_device
+        <where>
+            <if test="id != null">
+                and id = #{id}
+            </if>
+            <if test="deviceCode != null and deviceCode != ''">
+                and device_code = #{deviceCode}
+            </if>
+            <if test="deviceName != null and deviceName != ''">
+                and device_name = #{deviceName}
+            </if>
+            <if test="deviceModel != null and deviceModel != ''">
+                and device_model = #{deviceModel}
+            </if>
+            <if test="factoryDate != null and factoryDate != ''">
+                and factory_date = #{factoryDate}
+            </if>
+            <if test="factory != null and factory != ''">
+                and factory = #{factory}
+            </if>
+            <if test="remark != null and remark != ''">
+                and remark = #{remark}
+            </if>
+            <if test="deviceSystem != null and deviceSystem != ''">
+                and device_system = #{deviceSystem}
+            </if>
+            <if test="deviceType != null and deviceType != ''">
+                and device_type = #{deviceType}
+            </if>
+            <if test="pic != null and pic != ''">
+                and pic = #{pic}
+            </if>
+            <if test="ip != null and ip != ''">
+                and ip = #{ip}
+            </if>
+            <if test="factoryStatus != null and factoryStatus != ''">
+                and factory_status = #{factoryStatus}
+            </if>
+            <if test="homePosition != null and homePosition != ''">
+                and home_position = #{homePosition}
+            </if>
+        </where>
+    </select>
+
+    <!--新增所有列-->
+    <insert id="insert" keyProperty="id" useGeneratedKeys="true">
+        insert into w_device(device_code,device_name,device_model,factory_date,factory,remark,device_system,device_type,pic,ip,factory_status,home_position)
+        values (#{deviceCode}#{deviceName}#{deviceModel}#{factoryDate}#{factory}#{remark}#{deviceSystem}#{deviceType}#{pic}#{ip}#{factoryStatus}#{homePosition})
+    </insert>
+
+    <insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
+        insert into w_device(device_code,device_name,device_model,factory_date,factory,remark,device_system,device_type,pic,ip,factory_status,home_position)
+        values
+        <foreach collection="entities" item="entity" separator=",">
+        (#{entity.deviceCode},#{entity.deviceName},#{entity.deviceModel},#{entity.factoryDate},#{entity.factory},#{entity.remark},#{entity.deviceSystem},#{entity.deviceType},#{entity.pic},#{entity.ip},#{entity.factoryStatus},#{entity.homePosition})
+        </foreach>
+    </insert>
+
+    <insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
+        insert into w_device(device_code,device_name,device_model,factory_date,factory,remark,device_system,device_type,pic,ip,factory_status,home_position)
+        values
+        <foreach collection="entities" item="entity" separator=",">
+            (#{entity.deviceCode}#{entity.deviceName},#{entity.deviceModel},#{entity.factoryDate},#{entity.factory},#{entity.remark},#{entity.deviceSystem},#{entity.deviceType},#{entity.pic},#{entity.ip},#{entity.factoryStatus},#{entity.homePosition})
+        </foreach>
+        on duplicate key update
+device_code = values(device_code)device_name = values(device_name)device_model = values(device_model)factory_date = values(factory_date)factory = values(factory)remark = values(remark)device_system = values(device_system)device_type = values(device_type)pic = values(pic)ip = values(ip)factory_status = values(factory_status)home_position = values(home_position)
+    </insert>
+
+    <!--通过主键修改数据-->
+    <update id="update">
+        update w_device
+        <set>
+            <if test="deviceCode != null and deviceCode != ''">
+                device_code = #{deviceCode},
+            </if>
+            <if test="deviceName != null and deviceName != ''">
+                device_name = #{deviceName},
+            </if>
+            <if test="deviceModel != null and deviceModel != ''">
+                device_model = #{deviceModel},
+            </if>
+            <if test="factoryDate != null and factoryDate != ''">
+                factory_date = #{factoryDate},
+            </if>
+            <if test="factory != null and factory != ''">
+                factory = #{factory},
+            </if>
+            <if test="remark != null and remark != ''">
+                remark = #{remark},
+            </if>
+            <if test="deviceSystem != null and deviceSystem != ''">
+                device_system = #{deviceSystem},
+            </if>
+            <if test="deviceType != null and deviceType != ''">
+                device_type = #{deviceType},
+            </if>
+            <if test="pic != null and pic != ''">
+                pic = #{pic},
+            </if>
+            <if test="ip != null and ip != ''">
+                ip = #{ip},
+            </if>
+            <if test="factoryStatus != null and factoryStatus != ''">
+                factory_status = #{factoryStatus},
+            </if>
+            <if test="homePosition != null and homePosition != ''">
+                home_position = #{homePosition},
+            </if>
+        </set>
+        where id = #{id}
+    </update>
+
+    <!--通过主键删除-->
+    <delete id="deleteById">
+        delete from w_device where id = #{id}
+    </delete>
+
+</mapper>
+

+ 9 - 1
src/main/resources/mapper/WDeviceShelfDao.xml

@@ -3,7 +3,15 @@
 <mapper namespace="com.imcs.admin.business.dao.WDeviceShelfDao">
 
    <select id="getDeviceByStorage" resultType="java.lang.Long">
-       select device_id from w_device_shelf where shelf_id = (select shelf_management_id from w_storage_location_management where location_code=#{storage})
+       select device_id from w_device_shelf where
+        FIND_IN_SET((
+                        SELECT
+                            shelf_management_id
+                        FROM
+                            w_storage_location_management
+                        WHERE
+                            location_code = #{storage}
+                    ), shelf_id)
    </select>
 
 </mapper>