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

Merge branch 'dev' of http://192.168.1.220:10080/Amoy2/wlyy2.0 into dev

ysj преди 5 години
родител
ревизия
e40050ba59

+ 3 - 3
common/common-entity/src/main/java/com/yihu/jw/entity/iot/device/IotDeviceInventoryLogDO.java

@ -35,7 +35,7 @@ public class IotDeviceInventoryLogDO extends UuidIdentityEntityWithOperator impl
//    @Column(name = "num")
//    private Integer num;//数量
    @Column(name = "type")
    private String type;//调拨类型(1入库 2设备调拨出库 3核销出库)
    private Integer type;//调拨类型(1入库 2设备调拨出库 3核销出库)
    @Column(name = "remark")
    private String remark;//备注
@ -111,11 +111,11 @@ public class IotDeviceInventoryLogDO extends UuidIdentityEntityWithOperator impl
        this.hospitalName = hospitalName;
    }
    public String getType() {
    public Integer getType() {
        return type;
    }
    public void setType(String type) {
    public void setType(Integer type) {
        this.type = type;
    }

+ 149 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/iot/device/IotDeviceTransfersDO.java

@ -0,0 +1,149 @@
package com.yihu.jw.entity.iot.device;
import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;
/**
 * 设备调拨记录表
 *
 * @author humingfen on 2020.5.6.
 */
@Entity
@Table(name = "iot_device_transfers")
public class IotDeviceTransfersDO extends UuidIdentityEntity implements Serializable {
    @Column(name = "saas_id")
    private String saasId;
    @Column(name = "product_id")
    private String productId;//产品id
    @Column(name = "product_name")
    private String productName;//设备名称
    @Column(name = "category_code")
    private String categoryCode;//设备类型标识
    @Column(name = "category_name")
    private String categoryName;//设备类型名称
    @Column(name = "hospital")
    private String hospital;//归属社区
    @Column(name = "hospital_name")
    private String hospitalName;//归属社区名称
    @Column(name = "num")
    private String num;//数量
    @Column(name = "contacts_name")
    private String contactsName;//联系人
    @Column(name = "contacts_mobile")
    private String contactsMobile;//联系人
    @Column(name = "status")
    private Integer status;//调拨状态(-1已拒绝 0待调拨 1已调拨)
    @Column(name = "create_time")
    protected Date createTime;//创建时间
    @Column(name = "update_time")
    protected Date updateTime;//更新时间
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
    public String getProductId() {
        return productId;
    }
    public void setProductId(String productId) {
        this.productId = productId;
    }
    public String getProductName() {
        return productName;
    }
    public void setProductName(String productName) {
        this.productName = productName;
    }
    public String getCategoryCode() {
        return categoryCode;
    }
    public void setCategoryCode(String categoryCode) {
        this.categoryCode = categoryCode;
    }
    public String getCategoryName() {
        return categoryName;
    }
    public void setCategoryName(String categoryName) {
        this.categoryName = categoryName;
    }
    public String getHospital() {
        return hospital;
    }
    public void setHospital(String hospital) {
        this.hospital = hospital;
    }
    public String getHospitalName() {
        return hospitalName;
    }
    public void setHospitalName(String hospitalName) {
        this.hospitalName = hospitalName;
    }
    public String getNum() {
        return num;
    }
    public void setNum(String num) {
        this.num = num;
    }
    public String getContactsName() {
        return contactsName;
    }
    public void setContactsName(String contactsName) {
        this.contactsName = contactsName;
    }
    public String getContactsMobile() {
        return contactsMobile;
    }
    public void setContactsMobile(String contactsMobile) {
        this.contactsMobile = contactsMobile;
    }
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public Date getUpdateTime() {
        return updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
}

+ 8 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/iot/IotRequestMapping.java

@ -180,6 +180,14 @@ public class IotRequestMapping {
        //设备库存
        public static final String getDeviceInventoryList = "getDeviceInventoryList";
        public static final String updateInventory = "updateInventory";
        public static final String getDeviceInventoryLog = "getDeviceInventoryLog";
        public static final String getDeviceInventoryLogDetail = "getDeviceInventoryLogDetail";
        //设备调拨
        public static final String getDeviceTransfersList = "getDeviceTransfersList";
        public static final String createDeviceTransfers = "createDeviceTransfers";
        public static final String deleteDeviceTransfers = "deleteDeviceTransfers";
        public static final String updateTransfersStatusById = "updateTransfersStatusById";
        public static final String isSnExist = "isSnExist";
        public static final String isSimExist = "isSimExist";

+ 138 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/iot/device/IotDeviceInventoryLogVO.java

@ -0,0 +1,138 @@
package com.yihu.jw.restmodel.iot.device;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.yihu.jw.restmodel.iot.common.BaseVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import java.util.List;
/**
 * 设备出入库记录表
 * @author humingfen on 2020/5/6.
 */
@JsonInclude(JsonInclude.Include.ALWAYS)
@ApiModel(value = "设备出入库记录表", description = "设备出入库记录表")
public class IotDeviceInventoryLogVO extends BaseVO implements Serializable {
    @ApiModelProperty("产品id")
    private String productId;
    @ApiModelProperty("设备名称")
    private String name;
    @ApiModelProperty("设备类型")
    private String categoryCode;//设备类型标识
    @ApiModelProperty("设备类型名称")
    private String categoryName;//设备类型名称
    @ApiModelProperty("归属社区")
    private String hospital;
    @ApiModelProperty("归属社区名称")
    private String hospitalName;
    @ApiModelProperty("订单id")
    private String orderId;
    @ApiModelProperty("订单编号")
    private String orderNo;
    @ApiModelProperty("调拨类型(1入库 2设备调拨出库 3核销出库)")
    private Integer type;
    @ApiModelProperty("备注")
    private String remark;
    @ApiModelProperty("数量")
    private Integer num;
    @ApiModelProperty("设备列表")
    private List<IotDeviceVO> deviceVOList;
    public String getProductId() {
        return productId;
    }
    public void setProductId(String productId) {
        this.productId = productId;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getCategoryCode() {
        return categoryCode;
    }
    public void setCategoryCode(String categoryCode) {
        this.categoryCode = categoryCode;
    }
    public String getCategoryName() {
        return categoryName;
    }
    public void setCategoryName(String categoryName) {
        this.categoryName = categoryName;
    }
    public String getHospital() {
        return hospital;
    }
    public void setHospital(String hospital) {
        this.hospital = hospital;
    }
    public String getHospitalName() {
        return hospitalName;
    }
    public void setHospitalName(String hospitalName) {
        this.hospitalName = hospitalName;
    }
    public String getOrderId() {
        return orderId;
    }
    public void setOrderId(String orderId) {
        this.orderId = orderId;
    }
    public String getOrderNo() {
        return orderNo;
    }
    public void setOrderNo(String orderNo) {
        this.orderNo = orderNo;
    }
    public Integer getType() {
        return type;
    }
    public void setType(Integer type) {
        this.type = type;
    }
    public String getRemark() {
        return remark;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }
    public Integer getNum() {
        return num;
    }
    public void setNum(Integer num) {
        this.num = num;
    }
    public List<IotDeviceVO> getDeviceVOList() {
        return deviceVOList;
    }
    public void setDeviceVOList(List<IotDeviceVO> deviceVOList) {
        this.deviceVOList = deviceVOList;
    }
}

+ 9 - 1
svr/svr-iot/src/main/java/com/yihu/iot/controller/device/IotDeviceController.java

@ -173,6 +173,14 @@ public class IotDeviceController extends EnvelopRestEndpoint {
                                                           @RequestParam(value = "purcharseId", required = false) String purcharseId,
                                                              @ApiParam(name = "isBinding", value = "是否绑定(1已绑定,2未绑定)", defaultValue = "")
                                                           @RequestParam(value = "isBinding", required = false) Integer isBinding,
                                                                           @ApiParam(name = "productId", value = "产品id")
                                                                               @RequestParam(value = "productId", required = false) String productId,
                                                                           @ApiParam(name = "name", value = "设备名称")
                                                                               @RequestParam(value = "name", required = false) String name,
                                                                           @ApiParam(name = "categoryCode", value = "设备类型标识")
                                                                               @RequestParam(value = "categoryCode", required = false) String categoryCode,
                                                                           @ApiParam(name = "manufacturerId", value = "供应厂商id")
                                                                               @RequestParam(value = "manufacturerId", required = false) String manufacturerId,
                                                              @ApiParam(name = "page", value = "第几页", defaultValue = "")
                                                           @RequestParam(value = "page", required = false) Integer page,
                                                              @ApiParam(name = "size", value = "每页记录数", defaultValue = "")
@ -185,7 +193,7 @@ public class IotDeviceController extends EnvelopRestEndpoint {
                size = 10;
            }
            if(isBinding==null){
                return iotDeviceService.queryPage(sn, hospital, orderId, purcharseId, page, size);
                return iotDeviceService.queryPage(sn, hospital, orderId, purcharseId, productId, name, categoryCode, manufacturerId, page, size);
            }else {
                return iotDeviceService.queryPage(sn, hospital, orderId, purcharseId, isBinding, page, size);
            }

+ 40 - 7
svr/svr-iot/src/main/java/com/yihu/iot/controller/device/IotDeviceInventoryController.java

@ -1,6 +1,7 @@
package com.yihu.iot.controller.device;
import com.yihu.iot.service.device.IotDeviceInventoryService;
import com.yihu.jw.restmodel.iot.device.IotDeviceInventoryLogVO;
import com.yihu.jw.restmodel.iot.device.IotDeviceVO;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
@ -11,7 +12,6 @@ import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
 * @author humingfen on 2020.4.29
 */
@ -26,15 +26,15 @@ public class IotDeviceInventoryController extends EnvelopRestEndpoint {
    @GetMapping(value = IotRequestMapping.Device.getDeviceInventoryList)
    @ApiOperation(value = "获取设备库存列表", notes = "获取设备库存列表")
    public MixEnvelop<IotDeviceVO, IotDeviceVO> getDeviceInventoryList(@ApiParam(name = "name", value = "设备名称")
                                                           @RequestParam(value = "name", required = false) String name,
                                                                       @RequestParam(value = "name", required = false) String name,
                                                                       @ApiParam(name = "categoryCode", value = "设备类型标识")
                                                                       @RequestParam(value = "categoryCode", required = false) String categoryCode,
                                                                       @ApiParam(name = "hospitalName", value = "单位名称")
                                                                           @RequestParam(value = "hospitalName", required = false) String hospitalName,
                                                                       @RequestParam(value = "hospitalName", required = false) String hospitalName,
                                                                       @ApiParam(name = "page", value = "第几页", defaultValue = "1")
                                                                           @RequestParam(value = "page", required = false) Integer page,
                                                                       @RequestParam(value = "page", required = false) Integer page,
                                                                       @ApiParam(name = "pageSize", value = "每页记录数")
                                                                           @RequestParam(value = "pageSize", required = false) Integer pageSize) {
                                                                       @RequestParam(value = "pageSize", required = false) Integer pageSize) {
        try {
            return deviceInventoryService.getDeviceInventoryList(name, categoryCode, hospitalName, page, pageSize);
        } catch (Exception e) {
@ -45,8 +45,8 @@ public class IotDeviceInventoryController extends EnvelopRestEndpoint {
    @PostMapping(value = IotRequestMapping.Device.updateInventory)
    @ApiOperation(value = "设备库存出入库", notes = "设备库存出入库")
    public MixEnvelop<IotDeviceVO, IotDeviceVO> updateInventory(@ApiParam(name = "jsonData", value = "设备出入库json",defaultValue = "")
                                                                       @RequestParam(value = "jsonData", required = true) String jsonData) {
    public MixEnvelop<IotDeviceVO, IotDeviceVO> updateInventory(@ApiParam(name = "jsonData", value = "设备出入库json", defaultValue = "")
                                                                @RequestParam(value = "jsonData", required = true) String jsonData) {
        try {
            Integer count = deviceInventoryService.updateInventory(jsonData);
            return MixEnvelop.getSuccess(IotRequestMapping.Device.message_success_updateInventory, count);
@ -55,4 +55,37 @@ public class IotDeviceInventoryController extends EnvelopRestEndpoint {
            return MixEnvelop.getError(e.getMessage());
        }
    }
    @GetMapping(value = IotRequestMapping.Device.getDeviceInventoryLog)
    @ApiOperation(value = "获取设备出入库记录", notes = "获取设备出入库记录")
    public MixEnvelop<IotDeviceInventoryLogVO, IotDeviceInventoryLogVO> getDeviceInventoryLog(@ApiParam(name = "name", value = "设备名称")
                                                                                              @RequestParam(value = "name", required = false) String name,
                                                                                              @ApiParam(name = "categoryCode", value = "设备类型标识")
                                                                                              @RequestParam(value = "categoryCode", required = false) String categoryCode,
                                                                                              @ApiParam(name = "type", value = "调拨类型(1入库 2设备调拨出库 3核销出库)")
                                                                                              @RequestParam(value = "type", required = false) Integer type,
                                                                                              @ApiParam(name = "page", value = "第几页", defaultValue = "1")
                                                                                              @RequestParam(value = "page", required = false) Integer page,
                                                                                              @ApiParam(name = "pageSize", value = "每页记录数")
                                                                                              @RequestParam(value = "pageSize", required = false) Integer pageSize) {
        try {
            return deviceInventoryService.getDeviceInventoryLog(name, categoryCode, type, page, pageSize);
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
        }
    }
    @GetMapping(value = IotRequestMapping.Device.getDeviceInventoryLogDetail)
    @ApiOperation(value = "获取设备出入库记录详情", notes = "获取设备出入库记录详情")
    public MixEnvelop<IotDeviceInventoryLogVO, IotDeviceInventoryLogVO> getDeviceInventoryLogDetail(@ApiParam(name = "id", value = "出入库记录id")
                                                                                              @RequestParam(value = "id", required = true) String id) {
        try {
            IotDeviceInventoryLogVO deviceInventoryLogVO = deviceInventoryService.getDeviceInventoryLogDetail(id);
            return MixEnvelop.getSuccess(IotRequestMapping.Common.message_success_find, deviceInventoryLogVO);
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
        }
    }
}

+ 84 - 0
svr/svr-iot/src/main/java/com/yihu/iot/controller/device/IotDeviceTransfersController.java

@ -0,0 +1,84 @@
package com.yihu.iot.controller.device;
import com.yihu.iot.service.device.IotDeviceTransfersService;
import com.yihu.jw.entity.iot.device.IotDeviceTransfersDO;
import com.yihu.jw.restmodel.iot.device.IotDeviceVO;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.iot.IotRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
 * @author humingfen on 2020.4.29
 */
@RestController
@RequestMapping(IotRequestMapping.Common.device)
@Api(tags = "设备调拨管理相关操作", description = "设备调拨管理相关操作")
public class IotDeviceTransfersController extends EnvelopRestEndpoint {
    @Autowired
    private IotDeviceTransfersService deviceTransfersService;
    @GetMapping(value = IotRequestMapping.Device.getDeviceTransfersList)
    @ApiOperation(value = "获取设备调拨申请列表", notes = "获取设备调拨申请列表")
    public MixEnvelop<IotDeviceTransfersDO, IotDeviceTransfersDO> getDeviceTransfersList(@ApiParam(name = "name", value = "设备名称")
                                                                                         @RequestParam(value = "name", required = false) String name,
                                                                                         @ApiParam(name = "categoryCode", value = "设备类型标识")
                                                                                         @RequestParam(value = "categoryCode", required = false) String categoryCode,
                                                                                         @ApiParam(name = "page", value = "第几页", defaultValue = "1")
                                                                                         @RequestParam(value = "page", required = false) Integer page,
                                                                                         @ApiParam(name = "pageSize", value = "每页记录数")
                                                                                         @RequestParam(value = "pageSize", required = false) Integer pageSize) {
        try {
            return deviceTransfersService.getDeviceTransfersList(name, categoryCode, page, pageSize);
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
        }
    }
    @PostMapping(value = IotRequestMapping.Device.createDeviceTransfers)
    @ApiOperation(value = "新增编辑设备调拨申请记录", notes = "新增编辑设备调拨申请记录")
    public MixEnvelop<IotDeviceTransfersDO, IotDeviceTransfersDO> createDeviceTransfers(@ApiParam(name = "jsonData", value = "设备调拨申请json", defaultValue = "")
                                                                                        @RequestParam(value = "jsonData", required = true) String jsonData) {
        try {
            IotDeviceTransfersDO deviceTransfersDO = deviceTransfersService.createDeviceTransfers(jsonData);
            return MixEnvelop.getSuccess(IotRequestMapping.Common.message_success_update, deviceTransfersDO);
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
        }
    }
    @PostMapping(value = IotRequestMapping.Device.deleteDeviceTransfers)
    @ApiOperation(value = "删除设备调拨申请记录", notes = "删除编辑设备调拨申请记录")
    public MixEnvelop<IotDeviceTransfersDO, IotDeviceTransfersDO> deleteDeviceTransfers(@ApiParam(name = "id", value = "设备调拨申请记录id")
                                                                                        @RequestParam(value = "id", required = true) String id) {
        try {
            deviceTransfersService.deleteDeviceTransfers(id);
            return MixEnvelop.getSuccess(IotRequestMapping.Common.message_success_delete);
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
        }
    }
    @PostMapping(value = IotRequestMapping.Device.updateTransfersStatusById)
    @ApiOperation(value = "根据id更新设备调拨申请记录状态", notes = "根据id更新设备调拨申请记录状态")
    public MixEnvelop<IotDeviceTransfersDO, IotDeviceTransfersDO> updateTransfersStatusById(@ApiParam(name = "id", value = "设备调拨申请记录id")
                                                                                            @RequestParam(value = "id", required = true) String id,
                                                                                            @ApiParam(name = "status", value = "设备调拨状态(-1已拒绝 0待调拨 1已调拨)")
                                                                                            @RequestParam(value = "status", required = true) Integer status) {
        try {
            IotDeviceTransfersDO deviceTransfersDO = deviceTransfersService.updateTransfersStatusById(id, status);
            return MixEnvelop.getSuccess(IotRequestMapping.Common.message_success_update, deviceTransfersDO);
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
        }
    }
}

+ 2 - 0
svr/svr-iot/src/main/java/com/yihu/iot/dao/device/IotDeviceDao.java

@ -41,4 +41,6 @@ public interface IotDeviceDao extends PagingAndSortingRepository<IotDeviceDO, St
    @Query("from IotDeviceDO w where w.orderId =?1 and w.del=1")
    List<IotDeviceDO> findListByOrderId(String orderId);
    List<IotDeviceDO> findListByInventoryLogId(String id);
}

+ 8 - 0
svr/svr-iot/src/main/java/com/yihu/iot/dao/device/IotDeviceTransfersDao.java

@ -0,0 +1,8 @@
package com.yihu.iot.dao.device;
import com.yihu.jw.entity.iot.device.IotDeviceTransfersDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
public interface IotDeviceTransfersDao extends PagingAndSortingRepository<IotDeviceTransfersDO, String>, JpaSpecificationExecutor<IotDeviceTransfersDO> {
}

+ 42 - 6
svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotDeviceInventoryService.java

@ -4,14 +4,13 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.JsonObject;
import com.yihu.iot.dao.device.IotDeviceDao;
import com.yihu.iot.dao.device.IotDeviceInventoryLogDao;
import com.yihu.iot.dao.device.IotDeviceOrderDao;
import com.yihu.jw.entity.iot.device.IotDeviceDO;
import com.yihu.jw.entity.iot.device.IotDeviceInventoryLogDO;
import com.yihu.jw.entity.iot.device.IotDeviceOrderDO;
import com.yihu.jw.entity.specialist.rehabilitation.RehabilitationTemplateDetailDO;
import com.yihu.jw.restmodel.iot.device.IotDeviceInventoryLogVO;
import com.yihu.jw.restmodel.iot.device.IotDeviceVO;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.rm.iot.IotRequestMapping;
@ -109,13 +108,13 @@ public class IotDeviceInventoryService extends BaseJpaService<IotDeviceInventory
            //根据类型处理出入库
            for (IotDeviceDO deviceDO : deviceDOS) {
                String deviceSn = deviceDO.getDeviceSn();
                String type = deviceInventoryLogDO.getType();//调拨类型(1入库 2设备调拨出库 3核销出库)
                Integer type = deviceInventoryLogDO.getType();//调拨类型(1入库 2设备调拨出库 3核销出库)
                //设备出库,更换相关信息
                if(type.equals("1")){
                if (type.equals("1")) {
                    deviceDO.setSaasId(getCode());
                }else {
                } else {
                    deviceDO = iotDeviceDao.findByDeviceSn(deviceSn);
                    if(type.equals("3")){
                    if (type.equals("3")) {
                        deviceDO.setDel(0);
                        deviceDO.setStatus("2");
                        deviceDO.setInventoryLogId(deviceInventoryLogDO.getId());
@ -149,4 +148,41 @@ public class IotDeviceInventoryService extends BaseJpaService<IotDeviceInventory
        iotDeviceDao.save(deviceDOList);
        return deviceDOList.size();
    }
    public MixEnvelop<IotDeviceInventoryLogVO, IotDeviceInventoryLogVO> getDeviceInventoryLog(String name, String categoryCode, Integer type, Integer page, Integer pageSize) {
        String sql = "SELECT l.*, count(d.id) num FROM `iot_device_inventory_log` l LEFT JOIN iot_device d on l.id = d.inventory_log_id where 1=1 ";
        if (StringUtils.isNotBlank(name)) {
            sql += "and l.name like '%" + name + "%' ";
        }
        if (StringUtils.isNotBlank(categoryCode)) {
            sql += "and l.category_code = '" + categoryCode + "' ";
        }
        if (type != null) {
            sql += "and l.type = '" + type + "' ";
        }
        sql += "GROUP BY l.id order BY l.create_time desc ";
        //判断是否需要分页
        if (page != null && pageSize != null) {
            Long count = Long.valueOf(jdbcTempalte.queryForList(sql).size());
            sql += "limit " + (page - 1) * pageSize + "," + pageSize;
            List<IotDeviceInventoryLogVO> inventoryLogVOList = jdbcTempalte.query(sql, new BeanPropertyRowMapper<>(IotDeviceInventoryLogVO.class));
            return MixEnvelop.getSuccessListWithPage(IotRequestMapping.Common.message_success_find, inventoryLogVOList, page, pageSize, count);
        } else {
            List<IotDeviceInventoryLogVO> inventoryLogVOList = jdbcTempalte.query(sql, new BeanPropertyRowMapper<>(IotDeviceInventoryLogVO.class));
            return MixEnvelop.getSuccessList(IotRequestMapping.Common.message_success_find, inventoryLogVOList);
        }
    }
    public IotDeviceInventoryLogVO getDeviceInventoryLogDetail(String id) {
        IotDeviceInventoryLogDO deviceInventoryLogDO = deviceInventoryLogDao.findOne(id);
        //获取出入库详情设备列表
        List<IotDeviceDO> deviceDOS = iotDeviceDao.findListByInventoryLogId(id);
        IotDeviceInventoryLogVO deviceInventoryLogVO = convertToModel(deviceInventoryLogDO, IotDeviceInventoryLogVO.class);
        if (deviceDOS != null && deviceDOS.size() > 0) {
            List<IotDeviceVO> deviceVOS = new ArrayList<>();
            deviceInventoryLogVO.setDeviceVOList(convertToModels(deviceDOS, deviceVOS, IotDeviceVO.class));
        }
        deviceInventoryLogVO.setNum(deviceDOS.size());
        return deviceInventoryLogVO;
    }
}

+ 21 - 2
svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotDeviceService.java

@ -184,11 +184,14 @@ public class IotDeviceService extends BaseJpaService<IotDeviceDO,IotDeviceDao> {
     * @param hospital
     * @param orderId
     * @param purcharseId
     * @param name
     * @param categoryCode
     * @param manufacturerId
     * @param page
     * @param size
     * @return
     */
    public MixEnvelop<IotDeviceVO, IotDeviceVO> queryPage(String sn, String hospital, String orderId, String purcharseId, Integer page, Integer size) throws Exception{
    public MixEnvelop<IotDeviceVO, IotDeviceVO> queryPage(String sn, String hospital, String orderId, String purcharseId, String productId, String name, String categoryCode, String manufacturerId, Integer page, Integer size) throws Exception{
        String filters = "del=1;";
        String semicolon = "";
        if(StringUtils.isNotBlank(orderId)){
@ -204,7 +207,23 @@ public class IotDeviceService extends BaseJpaService<IotDeviceDO,IotDeviceDao> {
            semicolon = ";";
        }
        if(StringUtils.isNotBlank(sn)){
            filters += semicolon + "deviceSn?"+sn+" g1;name?"+sn+" g1";
            filters += semicolon + "deviceSn?"+sn+" g1;simNo?" + sn + " g1";
            semicolon = ";";
        }
        if(StringUtils.isNotBlank(productId)){
            filters += semicolon +"productId="+productId;
            semicolon = ";";
        }
        if(StringUtils.isNotBlank(name)){
            filters += semicolon + "name?"+name+"";
            semicolon = ";";
        }
        if(StringUtils.isNotBlank(categoryCode)){
            filters += semicolon +"categoryCode="+categoryCode;
            semicolon = ";";
        }
        if(StringUtils.isNotBlank(manufacturerId)){
            filters += semicolon +"manufacturerId="+manufacturerId;
            semicolon = ";";
        }
        String sorts = "-updateTime";

+ 103 - 0
svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotDeviceTransfersService.java

@ -0,0 +1,103 @@
package com.yihu.iot.service.device;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.iot.dao.device.IotDeviceTransfersDao;
import com.yihu.jw.entity.iot.device.IotDeviceTransfersDO;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.rm.iot.IotRequestMapping;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.io.IOException;
import java.util.Date;
import java.util.List;
import static com.yihu.jw.util.common.BeanUtils.getNullPropertyNames;
@Service
public class IotDeviceTransfersService extends BaseJpaService<IotDeviceTransfersDO, IotDeviceTransfersDao> {
    @Autowired
    private JdbcTemplate jdbcTempalte;
    @Autowired
    private ObjectMapper objectMapper;
    @Autowired
    private IotDeviceTransfersDao deviceTransfersDao;
    /**
     * 获取调拨申请列表
     *
     * @param name
     * @param categoryCode
     * @param page
     * @param pageSize
     * @return
     */
    public MixEnvelop<IotDeviceTransfersDO, IotDeviceTransfersDO> getDeviceTransfersList(String name, String categoryCode, Integer page, Integer pageSize) {
        String sql = "SELECT * FROM `iot_device_transfers` t where t.`status` != -1 ";
        if (StringUtils.isNotBlank(name)) {
            sql += "and t.product_name like '%" + name + "%' ";
        }
        if (StringUtils.isNotBlank(categoryCode)) {
            sql += "and t.category_code = '" + categoryCode + "' ";
        }
        sql += "ORDER BY t.update_time desc ";
        //判断是否需要分页
        if (page != null && pageSize != null) {
            Long count = Long.valueOf(jdbcTempalte.queryForList(sql).size());
            sql += "limit " + (page - 1) * pageSize + "," + pageSize;
            List<IotDeviceTransfersDO> deviceTransfersDOList = jdbcTempalte.query(sql, new BeanPropertyRowMapper<>(IotDeviceTransfersDO.class));
            return MixEnvelop.getSuccessListWithPage(IotRequestMapping.Common.message_success_find, deviceTransfersDOList, page, pageSize, count);
        } else {
            List<IotDeviceTransfersDO> deviceTransfersDOList = jdbcTempalte.query(sql, new BeanPropertyRowMapper<>(IotDeviceTransfersDO.class));
            return MixEnvelop.getSuccessList(IotRequestMapping.Common.message_success_find, deviceTransfersDOList);
        }
    }
    public IotDeviceTransfersDO createDeviceTransfers(String jsonData) {
        IotDeviceTransfersDO deviceTransfersDO = new IotDeviceTransfersDO();
        try {
            deviceTransfersDO = objectMapper.readValue(jsonData, IotDeviceTransfersDO.class);
        } catch (IOException e) {
            e.printStackTrace();
        }
        //判断新增或者编辑
        if (StringUtils.isBlank(deviceTransfersDO.getId())) {
            deviceTransfersDO.setSaasId(getCode());
            deviceTransfersDO.setStatus(0);
            deviceTransfersDO.setCreateTime(new Date());
            deviceTransfersDO.setUpdateTime(new Date());
            deviceTransfersDao.save(deviceTransfersDO);
            return deviceTransfersDO;
        }else {
            IotDeviceTransfersDO oldDeviceTransfers = deviceTransfersDao.findOne(deviceTransfersDO.getId());
            BeanUtils.copyProperties(deviceTransfersDO, oldDeviceTransfers, getNullPropertyNames(deviceTransfersDO));
            oldDeviceTransfers.setUpdateTime(new Date());
            deviceTransfersDao.save(oldDeviceTransfers);
            return oldDeviceTransfers;
        }
    }
    public void deleteDeviceTransfers(String id) {
        deviceTransfersDao.delete(id);
    }
    /**
     * 根据申请记录id更新调拨状态
     *
     * @param id
     * @param status
     * @return
     */
    public IotDeviceTransfersDO updateTransfersStatusById(String id, Integer status) {
        IotDeviceTransfersDO deviceTransfersDO = deviceTransfersDao.findOne(id);
        deviceTransfersDO.setStatus(status);
        deviceTransfersDao.save(deviceTransfersDO);
        return deviceTransfersDO;
    }
}