瀏覽代碼

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

ysj 5 年之前
父節點
當前提交
9ed543fded
共有 28 個文件被更改,包括 1200 次插入44 次删除
  1. 10 0
      common/common-entity/src/main/java/com/yihu/jw/entity/iot/device/IotDeviceDO.java
  2. 70 0
      common/common-entity/src/main/java/com/yihu/jw/entity/iot/device/IotDeviceOverhaulDO.java
  3. 36 1
      common/common-entity/src/main/java/com/yihu/jw/entity/iot/device/IotDeviceQualityInspectionPlanDO.java
  4. 161 0
      common/common-entity/src/main/java/com/yihu/jw/entity/iot/device/IotDeviceSimDO.java
  5. 32 0
      common/common-entity/src/main/java/com/yihu/jw/entity/iot/device/IotQualityRecordDO.java
  6. 80 0
      common/common-entity/src/main/java/com/yihu/jw/entity/iot/message/IotMessageDO.java
  7. 23 0
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/iot/IotRequestMapping.java
  8. 1 1
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/iot/device/IotDeviceVO.java
  9. 7 0
      common/common-util/src/main/java/com/yihu/jw/util/date/DateUtil.java
  10. 31 0
      svr/svr-iot-job/src/main/java/com/yihu/jw/job/wlw/DeviceQualityPlanJob.java
  11. 51 0
      svr/svr-iot-job/src/main/java/com/yihu/jw/service/channel/DeviceQualityPlanService.java
  12. 2 6
      svr/svr-iot/src/main/java/com/yihu/iot/controller/device/IotDeviceController.java
  13. 94 0
      svr/svr-iot/src/main/java/com/yihu/iot/controller/device/IotDeviceOverhaulController.java
  14. 30 4
      svr/svr-iot/src/main/java/com/yihu/iot/controller/device/IotDeviceQualityController.java
  15. 142 0
      svr/svr-iot/src/main/java/com/yihu/iot/controller/device/IotDeviceSimController.java
  16. 16 0
      svr/svr-iot/src/main/java/com/yihu/iot/controller/device/IotPatientDeviceController.java
  17. 10 0
      svr/svr-iot/src/main/java/com/yihu/iot/dao/device/IotDeviceDao.java
  18. 19 0
      svr/svr-iot/src/main/java/com/yihu/iot/dao/device/IotDeviceOverhaulDao.java
  19. 3 0
      svr/svr-iot/src/main/java/com/yihu/iot/dao/device/IotDeviceQualityInspectionPlanDao.java
  20. 15 0
      svr/svr-iot/src/main/java/com/yihu/iot/dao/device/IotDeviceSimDao.java
  21. 7 0
      svr/svr-iot/src/main/java/com/yihu/iot/dao/device/IotPatientDeviceDao.java
  22. 17 0
      svr/svr-iot/src/main/java/com/yihu/iot/dao/message/IotMessageDao.java
  23. 1 1
      svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotDeviceInventoryService.java
  24. 40 0
      svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotDeviceOverhaulService.java
  25. 47 20
      svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotDeviceQualityInspectionPlanService.java
  26. 172 0
      svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotDeviceSimService.java
  27. 73 1
      svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotPatientDeviceService.java
  28. 10 10
      svr/svr-iot/src/main/java/com/yihu/iot/service/dict/IotSystemDictService.java

+ 10 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/iot/device/IotDeviceDO.java

@ -81,6 +81,8 @@ public class IotDeviceDO extends UuidIdentityEntityWithOperator implements Seria
    @Column(name = "del")
    private Integer del;//删除标志(1有效,0删除)
    @Column(name = "is_grant")
    private Integer isGrant;//是否发放(0否1是)
    @Column(name = "category_code")
    private String categoryCode;//设备类型标识
@ -346,4 +348,12 @@ public class IotDeviceDO extends UuidIdentityEntityWithOperator implements Seria
    public void setInventoryLogId(String inventoryLogId) {
        this.inventoryLogId = inventoryLogId;
    }
    public Integer getIsGrant() {
        return isGrant;
    }
    public void setIsGrant(Integer isGrant) {
        this.isGrant = isGrant;
    }
}

+ 70 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/iot/device/IotDeviceOverhaulDO.java

@ -0,0 +1,70 @@
package com.yihu.jw.entity.iot.device;
import com.yihu.jw.entity.UuidIdentityEntity;
import com.yihu.jw.entity.UuidIdentityEntityWithOperator;
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_overhaul")
public class IotDeviceOverhaulDO extends UuidIdentityEntityWithOperator implements Serializable {
    @Column(name = "saas_id")
    private String saasId;
    @Column(name = "patient_device_id")
    private String patientDeviceId;//居民设备表id
    @Column(name = "time")
    private String time;//计划检修时间
    @Column(name = "status")
    private Integer status;//检修状态(-1删除 0未检修 1已检修正常 2已检修回收)
    @Column(name = "remark")
    private String remark;//检修备注
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
    public String getPatientDeviceId() {
        return patientDeviceId;
    }
    public void setPatientDeviceId(String patientDeviceId) {
        this.patientDeviceId = patientDeviceId;
    }
    public String getTime() {
        return time;
    }
    public void setTime(String time) {
        this.time = time;
    }
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    public String getRemark() {
        return remark;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }
}

+ 36 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/iot/device/IotDeviceQualityInspectionPlanDO.java

@ -59,7 +59,17 @@ public class IotDeviceQualityInspectionPlanDO extends UuidIdentityEntityWithOper
    private String status;//质检状态(1未检,2已检)
    @Column(name = "del")
    private Integer del;//删除标志
    private Integer del;//删除标志 1:有效  0:无效
    //新增字段
    @Column(name = "img")
    private String img;//质检图像
    @Column(name = "summary")
    private String summary;//质检小结
    @Column(name = "remind_time")
    private Date remindTime;//质检提醒时间
    public enum QualityPlanStatus {
        create("未完成", "1"),
@ -153,6 +163,31 @@ public class IotDeviceQualityInspectionPlanDO extends UuidIdentityEntityWithOper
//        this.deviceType = deviceType;
//    }
    public String getImg() {
        return img;
    }
    public void setImg(String img) {
        this.img = img;
    }
    public String getSummary() {
        return summary;
    }
    public void setSummary(String summary) {
        this.summary = summary;
    }
    public Date getRemindTime() {
        return remindTime;
    }
    public void setRemindTime(Date remindTime) {
        this.remindTime = remindTime;
    }
    public Long getPurchaseNum() {
        return purchaseNum;
    }

+ 161 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/iot/device/IotDeviceSimDO.java

@ -0,0 +1,161 @@
package com.yihu.jw.entity.iot.device;
import com.yihu.jw.entity.UuidIdentityEntityWithOperator;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.io.Serializable;
/**
 * @author HZY
 * @vsrsion 1.0
 * Created at 2020/5/7
 */
@Entity
@Table(name = "iot_device_sim")
public class IotDeviceSimDO extends UuidIdentityEntityWithOperator implements Serializable {
    @Column(name = "saas_id")
    private String saasId;//
    @Column(name = "sim")
    private String sim;//'sim卡卡号'
    @Column(name = "advance_payment")
    private float advancePayment;//预缴金额
    @Column(name = "payment")
    private float payment;//套餐资费
    @Column(name = "remaining_balance")
    private float remainingBalance;//余额
    @Column(name = "status")
    private Integer status;//sim状态(-1 已停用 0欠费 1正常)',
    @Column(name = "contacts_name")
    private String contactsName;//
    @Column(name = "contacts_mobile")
    private String contactsMobile;//联系人手机号码
    //新增字段
    @Column(name = "remind_balance")
    private String remindBalance;//提醒金额
    @Column(name = "remind_time")
    private String remindTime;//每月的固定提醒日
    @Column(name = "remind_arrears")
    private String remindArrears;//欠费提醒  1:提醒  0:不提醒
    @Column(name = "device_name")
    private String deviceName;//设备名称
    @Column(name = "device_sn")
    private String deviceSn;//设备sn码
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
    public String getSim() {
        return sim;
    }
    public void setSim(String sim) {
        this.sim = sim;
    }
    public float getAdvancePayment() {
        return advancePayment;
    }
    public void setAdvancePayment(float advancePayment) {
        this.advancePayment = advancePayment;
    }
    public float getPayment() {
        return payment;
    }
    public void setPayment(float payment) {
        this.payment = payment;
    }
    public float getRemainingBalance() {
        return remainingBalance;
    }
    public void setRemainingBalance(float remainingBalance) {
        this.remainingBalance = remainingBalance;
    }
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    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 String getRemindBalance() {
        return remindBalance;
    }
    public void setRemindBalance(String remindBalance) {
        this.remindBalance = remindBalance;
    }
    public String getRemindTime() {
        return remindTime;
    }
    public void setRemindTime(String remindTime) {
        this.remindTime = remindTime;
    }
    public String getRemindArrears() {
        return remindArrears;
    }
    public void setRemindArrears(String remindArrears) {
        this.remindArrears = remindArrears;
    }
    public String getDeviceName() {
        return deviceName;
    }
    public void setDeviceName(String deviceName) {
        this.deviceName = deviceName;
    }
    public String getDeviceSn() {
        return deviceSn;
    }
    public void setDeviceSn(String deviceSn) {
        this.deviceSn = deviceSn;
    }
}

+ 32 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/iot/device/IotQualityRecordDO.java

@ -37,6 +37,14 @@ public class IotQualityRecordDO extends UuidIdentityEntityWithOperator implement
    @Column(name = "del")
    private Integer del;//删除标志
    //新增字段
    @Column(name = "img")
    private String img;//质检图像
    @Column(name = "summary")
    private String summary;//质检小结
    @Column(name = "remind_time")
    private Date remindTime;//质检提醒时间
    public String getSaasId() {
        return saasId;
    }
@ -116,4 +124,28 @@ public class IotQualityRecordDO extends UuidIdentityEntityWithOperator implement
    public void setDel(Integer del) {
        this.del = del;
    }
    public String getImg() {
        return img;
    }
    public void setImg(String img) {
        this.img = img;
    }
    public String getSummary() {
        return summary;
    }
    public void setSummary(String summary) {
        this.summary = summary;
    }
    public Date getRemindTime() {
        return remindTime;
    }
    public void setRemindTime(Date remindTime) {
        this.remindTime = remindTime;
    }
}

+ 80 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/iot/message/IotMessageDO.java

@ -0,0 +1,80 @@
package com.yihu.jw.entity.iot.message;
import com.yihu.jw.entity.UuidIdentityEntityWithOperator;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
/**
 * @author suhaiwen  消息列表
 * @vsrsion 1.0
 * Created at 2020/5/7
 */
@Entity
@Table(name = "iot_message")
public class IotMessageDO extends UuidIdentityEntityWithOperator implements Serializable {
    @Column(name = "title")
    private String title;//消息标题
    @Column(name = "content")
    private String content;//消息内容
    @Column(name = "type")
    private String type;//消息类型 1:SIM卡续费通知 2:库存预警提醒 3:定期检修提醒 4:设备质检提醒',
    @Column(name = "read")
    private String read;//消息状态,1:已读  0:未读',
    @Column(name = "del")
    private String del;//删除标志  1:删除  0:不删除',
    @Column(name = "relation_code")
    private String relationCode;//业务关联id
    public String getTitle() {
        return title;
    }
    public void setTitle(String title) {
        this.title = title;
    }
    public String getContent() {
        return content;
    }
    public void setContent(String content) {
        this.content = content;
    }
    public String getType() {
        return type;
    }
    public void setType(String type) {
        this.type = type;
    }
    public String getRead() {
        return read;
    }
    public void setRead(String read) {
        this.read = read;
    }
    public String getDel() {
        return del;
    }
    public void setDel(String del) {
        this.del = del;
    }
    public String getRelationCode() {
        return relationCode;
    }
    public void setRelationCode(String relationCode) {
        this.relationCode = relationCode;
    }
}

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

@ -26,6 +26,7 @@ public class IotRequestMapping {
        public static final String workType = api_iot_common + "/workType";
        public static final String hospital = api_iot_common + "/hospital";
        public static final String interfaceAudit = api_iot_common + "/interfaceAudit";
        public static final String sim = api_iot_common + "/sim";
        public static final String message_success_update = "update success";
@ -150,6 +151,12 @@ public class IotRequestMapping {
        public static final String getRepairDeviceList = "getRepairDeviceList";
        public static final String getDeviceInfoByDeviceSn = "getDeviceInfoByDeviceSn";
        public static final String deleteRepairDevice = "deleteRepairDevice";
        //设备检修
        public static final String getOverhaulDeviceList = "getOverhaulDeviceList";
        public static final String getOverhaulListByPatientDeviceId = "getOverhaulListByPatientDeviceId";
        public static final String delOverhaulByPatientDeviceId = "delOverhaulByPatientDeviceId";
        public static final String updateOverhaulStatusById = "updateOverhaulStatusById";
    }
@ -213,6 +220,21 @@ public class IotRequestMapping {
        public static final String message_success_updateInventory = "device inventory update success";
    }
    /**
     * SIM卡模块常量
     */
    public static class DeviceSim{
        public static final String addSIM = "addSIM";
        public static final String editSIM = "editSIM";
        public static final String conditionQueryPage = "conditionQueryPage";
        public static final String findAllSim = "findAllSim";
        public static final String remind = "remind";
        public static final String message_success_add = "sim add success";
        public static final String message_success_edit = "sim edit success";
        public static final String message_success_remind = "sim remind success";
        public static final String message_success_find= " sim find success";
    }
    /**
     * 设备订单模块常量
     */
@ -257,6 +279,7 @@ public class IotRequestMapping {
        public static final String completePlanByPurchaseId = "completePlanByPurchaseId";
        public static final String queryQualityPlanPage = "queryQualityPlanPage";
        public static final String findById = "findById";
        public static final String remindTimePlan = "remindTimePlan";
    }

+ 1 - 1
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/iot/device/IotDeviceVO.java

@ -19,6 +19,7 @@ import java.util.List;
@ApiModel(value = "设备表", description = "设备表")
public class IotDeviceVO extends BaseVO implements Serializable {
    @ApiModelProperty("产品id")
    private String productId;
    @ApiModelProperty("设备名称")
@ -74,7 +75,6 @@ public class IotDeviceVO extends BaseVO implements Serializable {
    private String categoryCode;//设备类型标识
    @ApiModelProperty("设备类型名称")
    private String categoryName;//设备类型名称
    public String getName() {
        return name;
    }

+ 7 - 0
common/common-util/src/main/java/com/yihu/jw/util/date/DateUtil.java

@ -429,6 +429,13 @@ public class DateUtil {
        return dateToStrShort(c.getTime());
    }
    public static Date getNextDay1(Date d, int days) {
        Calendar c = Calendar.getInstance();
        c.setTime(d);
        c.add(Calendar.DATE, days);
        return c.getTime();
    }
    public static String getNextMonth(Date d, int months) {
        Calendar c = Calendar.getInstance();
        c.setTime(d);

+ 31 - 0
svr/svr-iot-job/src/main/java/com/yihu/jw/job/wlw/DeviceQualityPlanJob.java

@ -0,0 +1,31 @@
package com.yihu.jw.job.wlw;
import com.yihu.jw.service.channel.DeviceQualityPlanService;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
/**
 * @author HZY
 * @vsrsion 1.0
 * Created at 2020/5/7
 */
public class DeviceQualityPlanJob implements Job {
    private static final Logger logger = LoggerFactory.getLogger(DeviceQualityPlanJob.class);
    @Autowired
    private DeviceQualityPlanService deviceQualityPlanService;
    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        logger.info("START========PrescriptionStatusUpdateJob========");
        try {
            deviceQualityPlanService.autoPush();
            logger.info("END========PrescriptionStatusUpdateJob========");
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("END===ERROE===PrescriptionStatusUpdateJob,message:"+e.getMessage());
        }
    }
}

+ 51 - 0
svr/svr-iot-job/src/main/java/com/yihu/jw/service/channel/DeviceQualityPlanService.java

@ -0,0 +1,51 @@
package com.yihu.jw.service.channel;
import com.yihu.iot.dao.device.IotDeviceQualityInspectionPlanDao;
import com.yihu.iot.dao.message.IotMessageDao;
import com.yihu.jw.entity.iot.device.IotDeviceQualityInspectionPlanDO;
import com.yihu.jw.entity.iot.message.IotMessageDO;
import com.yihu.jw.util.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import javax.xml.ws.Action;
import java.util.Date;
import java.util.List;
/**
 * @author HZY
 * @vsrsion 1.0
 * Created at 2020/5/7
 */
@Component
@Transactional
public class DeviceQualityPlanService {
    @Autowired
    private IotMessageDao iotMessageDao;
    @Autowired
    private IotDeviceQualityInspectionPlanDao iotDeviceQualityInspectionPlanDao;
    public void autoPush() {
        List<IotDeviceQualityInspectionPlanDO> listAll = iotDeviceQualityInspectionPlanDao.findListAll();
        listAll.forEach(one->{
            Date remindTime = one.getRemindTime();
            String system = DateUtil.dateToStrShort(DateUtil.getNowDate());
            String remind = DateUtil.dateToStrShort(remindTime);
            if (system.equalsIgnoreCase(remind)){
                IotMessageDO iotMessageDO = new IotMessageDO();
                iotMessageDO.setTitle("设备质检提醒");
                iotMessageDO.setContent("订单:"+one.getPurchaseId()+".将于"+remind+",进行质检,请及时维护");
                iotMessageDO.setRead("0");
                iotMessageDO.setDel("0");
                iotMessageDO.setTitle("4");
                iotMessageDao.save(iotMessageDO);
            }
        });
    }
}

+ 2 - 6
svr/svr-iot/src/main/java/com/yihu/iot/controller/device/IotDeviceController.java

@ -38,11 +38,7 @@ public class IotDeviceController extends EnvelopRestEndpoint {
    @Autowired
    private IotDeviceService iotDeviceService;
    /*@Autowired
    private FastDFSUtil fastDFSHelper;*/
    /*@Value("${fastDFS.fastdfs_file_url}")
    private String fastdfs_file_url;*/
    @Autowired
    private IotDeviceImportRecordDao iotDeviceImportRecordDao;
@ -102,8 +98,8 @@ public class IotDeviceController extends EnvelopRestEndpoint {
    }
    @GetMapping(value = IotRequestMapping.Device.api_getById)
    @ApiOperation(value = "根据code查找设备", notes = "根据code查找设备")
    public MixEnvelop<IotDeviceVO, IotDeviceVO> findByCode(@ApiParam(name = "id", value = "id")
    @ApiOperation(value = "根据ID查找设备", notes = "根据ID查找设备")
    public MixEnvelop<IotDeviceVO, IotDeviceVO> findByCode(@ApiParam(name = "id", value = "设备ID")
                              @RequestParam(value = "id", required = true) String id
    ) {
        try {

+ 94 - 0
svr/svr-iot/src/main/java/com/yihu/iot/controller/device/IotDeviceOverhaulController.java

@ -0,0 +1,94 @@
package com.yihu.iot.controller.device;
import com.yihu.iot.service.device.IotDeviceOverhaulService;
import com.yihu.iot.service.device.IotPatientDeviceService;
import com.yihu.jw.entity.iot.device.IotDeviceOverhaulDO;
import com.yihu.jw.restmodel.iot.device.IotPatientDeviceVO;
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.*;
import java.util.List;
/**
 * @author humingfen on 2020/5/7
 */
@RestController
@RequestMapping(IotRequestMapping.Common.patientDevice)
@Api(tags = "居民设备检修管理相关操作", description = "居民设备检修管理相关操作")
public class IotDeviceOverhaulController extends EnvelopRestEndpoint {
    @Autowired
    private IotPatientDeviceService patientDeviceService;
    @Autowired
    private IotDeviceOverhaulService deviceOverhaulService;
    @GetMapping(value = IotRequestMapping.PatientDevice.getOverhaulDeviceList)
    @ApiOperation(value = "获取检修管理列表", notes = "获取检修管理列表")
    public MixEnvelop<IotPatientDeviceVO, IotPatientDeviceVO> getOverhaulDeviceList(
            @ApiParam(name = "deviceSn", value = "sn码", defaultValue = "")
            @RequestParam(value = "deviceSn", required = false) String deviceSn,
            @ApiParam(name = "patientName", value = "领用人")
            @RequestParam(value = "patientName", required = false) String patientName,
            @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 patientDeviceService.getOverhaulDeviceList(deviceSn, patientName, page, pageSize);
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
        }
    }
    @GetMapping(value = IotRequestMapping.PatientDevice.getOverhaulListByPatientDeviceId)
    @ApiOperation(value = "根据居民设备id获取检修详情列表", notes = "根据居民设备id获取检修详情列表")
    public MixEnvelop<IotDeviceOverhaulDO, IotDeviceOverhaulDO> getOverhaulListByPatientDeviceId(
            @ApiParam(name = "patientDeviceId", value = "居民设备id", defaultValue = "")
            @RequestParam(value = "patientDeviceId", required = true) String patientDeviceId) {
        try {
            List<IotDeviceOverhaulDO> list = deviceOverhaulService.getOverhaulListByPatientDeviceId(patientDeviceId);
            return MixEnvelop.getSuccessList(IotRequestMapping.Common.message_success_find, list);
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
        }
    }
    @PostMapping(value = IotRequestMapping.PatientDevice.updateOverhaulStatusById)
    @ApiOperation(value = "删除或更新检修状态", notes = "删除或更新检修状态")
    public MixEnvelop<IotDeviceOverhaulDO, IotDeviceOverhaulDO> updateOverhaulStatusById(
            @ApiParam(name = "id", value = "检修记录id", defaultValue = "")
            @RequestParam(value = "id", required = true) String id,
            @ApiParam(name = "status", value = "检修状态(-1删除 0未检修 1已检修正常 2已检修回收)")
            @RequestParam(value = "status", required = true) Integer status,
            @ApiParam(name = "remark", value = "检修备注")
            @RequestParam(value = "remark", required = false) String  remark) {
        try {
            IotDeviceOverhaulDO deviceOverhaulDO = deviceOverhaulService.updateOverhaulStatusById(id, status, remark);
            return MixEnvelop.getSuccess(IotRequestMapping.Common.message_success_update, deviceOverhaulDO);
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
        }
    }
    @PostMapping(value = IotRequestMapping.PatientDevice.delOverhaulByPatientDeviceId)
    @ApiOperation(value = "根据居民设备id删除检修记录", notes = "根据居民设备id删除检修记录")
    public MixEnvelop<IotDeviceOverhaulDO, IotDeviceOverhaulDO> delOverhaulByPatientDeviceId(
            @ApiParam(name = "patientDeviceId", value = "居民设备id", defaultValue = "")
            @RequestParam(value = "patientDeviceId", required = true) String patientDeviceId) {
        try {
            deviceOverhaulService.delOverhaulByPatientDeviceId(patientDeviceId);
            return MixEnvelop.getSuccess(IotRequestMapping.Common.message_success_delete);
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
        }
    }
}

+ 30 - 4
svr/svr-iot/src/main/java/com/yihu/iot/controller/device/IotDeviceQualityController.java

@ -14,6 +14,8 @@ import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
 * @author yeshijie on 2017/12/8.
 */
@ -139,9 +141,13 @@ public class IotDeviceQualityController extends EnvelopRestEndpoint {
    public MixEnvelop<IotDeviceQualityInspectionPlanVO, IotDeviceQualityInspectionPlanVO> updCompany(@ApiParam(name = "actualTime", value = "完成时间", defaultValue = "")
                                            @RequestParam(value = "actualTime", required = true) String actualTime,
                                                                   @ApiParam(name = "id", value = "id")
                                            @RequestParam(value = "id", required = true) String id) {
                                            @RequestParam(value = "id", required = true) String id,
                                                                   @ApiParam(name = "summary", value = "质检总结")
                                            @RequestParam(value = "summary", required = true) String summary,
                                                                   @ApiParam(name = "imgs", value = "质检图像")
                                            @RequestBody List<String> imgs ) {
        try {
            iotDeviceQualityInspectionPlanService.completePlan(id,actualTime);
            iotDeviceQualityInspectionPlanService.completePlan(id,actualTime,summary,imgs);
            return MixEnvelop.getSuccess(IotRequestMapping.Common.message_success_find);
        } catch (Exception e) {
            e.printStackTrace();
@ -154,9 +160,28 @@ public class IotDeviceQualityController extends EnvelopRestEndpoint {
    public MixEnvelop<IotDeviceQualityInspectionPlanVO, IotDeviceQualityInspectionPlanVO> completePlanByPurchaseId(@ApiParam(name = "actualTime", value = "完成时间", defaultValue = "")
                                                                @RequestParam(value = "actualTime", required = true) String actualTime,
                                                                                 @ApiParam(name = "purchaseId", value = "purchaseId")
                                                                @RequestParam(value = "purchaseId", required = true) String purchaseId) {
                                                                @RequestParam(value = "purchaseId", required = true) String purchaseId,
                                                                                 @ApiParam(name = "summary", value = "质检总结")
                                                                @RequestParam(value = "summary", required = true) String summary,
                                                                                 @ApiParam(name = "imgs", value = "质检图像")
                                                                @RequestBody List<String> imgs ) {
        try{
            iotDeviceQualityInspectionPlanService.completePlanByPurchaseId(purchaseId,actualTime,summary,imgs);
            return MixEnvelop.getSuccess(IotRequestMapping.Common.message_success_find);
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
        }
    }
    @GetMapping(value = IotRequestMapping.DeviceQuality.remindTimePlan)
    @ApiOperation(value = "计划时间提醒", notes = "计划时间提醒")
    public MixEnvelop<IotDeviceQualityInspectionPlanVO, IotDeviceQualityInspectionPlanVO> remindTimePlan(@ApiParam(name = "time", value = "提醒时间")
                                                                                                     @RequestParam(value = "time", required = true) String time) {
        try {
            iotDeviceQualityInspectionPlanService.completePlanByPurchaseId(purchaseId,actualTime);
            iotDeviceQualityInspectionPlanService.remindTimePlan(time);
            return MixEnvelop.getSuccess(IotRequestMapping.Common.message_success_find);
        } catch (Exception e) {
            e.printStackTrace();
@ -164,4 +189,5 @@ public class IotDeviceQualityController extends EnvelopRestEndpoint {
        }
    }
}

+ 142 - 0
svr/svr-iot/src/main/java/com/yihu/iot/controller/device/IotDeviceSimController.java

@ -0,0 +1,142 @@
package com.yihu.iot.controller.device;
import com.yihu.iot.service.device.IotDeviceSimService;
import com.yihu.jw.entity.iot.device.IotDeviceOrderDO;
import com.yihu.jw.entity.iot.device.IotDeviceSimDO;
import com.yihu.jw.entity.iot.platform.IotInterfaceAuditDO;
import com.yihu.jw.restmodel.iot.company.IotCompanyVO;
import com.yihu.jw.restmodel.iot.device.IotOrderVO;
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.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
 * @author HZY
 * @vsrsion 1.0
 * Created at 2020/5/7
 */
@RestController
@RequestMapping(IotRequestMapping.Common.sim)
@Api(tags = "SIM卡管理相关操作", description = "SIM卡管理相关操作")
public class IotDeviceSimController extends EnvelopRestEndpoint {
    @Autowired
    private IotDeviceSimService iotDeviceSimService;
    @PostMapping(value = IotRequestMapping.DeviceSim.editSIM)
    @ApiOperation(value = "编辑SIM卡管理", notes = "编辑SIM卡管理")
    public MixEnvelop<IotOrderVO, IotOrderVO> editSIM(@ApiParam(name = "id", value = "ID", defaultValue = "")
                                                     @RequestParam(value = "id",required = true) String id,
                                                      @ApiParam(name = "advancePayment", value = "预缴金额", defaultValue = "")
                                                      @RequestParam(value = "advancePayment",required = true) String advancePayment,
                                                      @ApiParam(name = "payment", value = "套餐资费", defaultValue = "")
                                                          @RequestParam(value = "payment",required = true) String payment,
                                                      @ApiParam(name = "remainingBalance", value = "余额", defaultValue = "")
                                                          @RequestParam(value = "remainingBalance",required = true) String remainingBalance,
                                                      @ApiParam(name = "status", value = "状态", defaultValue = "1")
                                                          @RequestParam(value = "status",required = true) Integer status) {
        try {
           iotDeviceSimService.editSIM(id,advancePayment,payment,remainingBalance,status);
            return MixEnvelop.getSuccess(IotRequestMapping.DeviceSim.message_success_add);
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
        }
    }
    @PostMapping(value = IotRequestMapping.DeviceSim.addSIM)
    @ApiOperation(value = "添加SIM卡", notes = "添加SIM卡")
    public MixEnvelop<IotOrderVO, IotOrderVO> addSIM(@ApiParam(name = "json", value = "json", defaultValue = "")
                                                      @RequestParam(value = "json",required = true) String json) {
        try {
            return iotDeviceSimService.addSIM(json);
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
        }
    }
    @GetMapping(value = IotRequestMapping.DeviceSim.conditionQueryPage)
    @ApiOperation(value = "条件查找SIM卡", notes = "条件查找SIM卡")
    public MixEnvelop<IotDeviceSimDO, IotDeviceSimDO> conditionQueryPage(@ApiParam(name = "sim", value = "SIM卡", defaultValue = "")
                                                                     @RequestParam(value = "sim", required = false) String sim,
                                                                       @ApiParam(name = "sn", value = "SN码", defaultValue = "")
                                                                     @RequestParam(value = "sn", required = false) String sn,
                                                                       @ApiParam(name = "status", value = "状态", defaultValue = "")
                                                                     @RequestParam(value = "status", required = false) String status,
                                                                       @ApiParam(name = "page", value = "第几页", defaultValue = "")
                                                                     @RequestParam(value = "page", required = false) Integer page,
                                                                       @ApiParam(name = "size", value = "每页记录数", defaultValue = "")
                                                                     @RequestParam(value = "size", required = false) Integer size){
        try {
            if(page == null|| page < 0){
                page = 1;
            }
            if(size == null){
                size = 10;
            }
            return iotDeviceSimService.conditionQueryPage(page,size,status,sim,sn);
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
        }
    }
    @GetMapping(value = IotRequestMapping.DeviceSim.findAllSim)
    @ApiOperation(value = "分页查询所有SIM卡信息",notes = "分页查询所有SIM卡信息")
    public MixEnvelop<IotDeviceSimDO,IotDeviceSimDO> findAllSim(@ApiParam(name = "page", value = "第几页", defaultValue = "")
                                                                               @RequestParam(value = "page", required = false) Integer page,
                                                                               @ApiParam(name = "size", value = "每页记录数", defaultValue = "")
                                                                               @RequestParam(value = "size", required = false) Integer size){
        try {
            if(page == null|| page < 0){
                page = 1;
            }
            if(size == null){
                size = 10;
            }
            return iotDeviceSimService.findAllSim(page,size);
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
        }
    }
    @GetMapping(value = IotRequestMapping.DeviceSim.remind)
    @ApiOperation(value = "分页查询所有SIM卡信息",notes = "分页查询所有SIM卡信息")
    public MixEnvelop<IotDeviceSimDO,IotDeviceSimDO> remind(@ApiParam(name = "time", value = "提醒时间", defaultValue = "")
                                                                @RequestParam(value = "time", required = false) String time,
                                                                @ApiParam(name = "money", value = "提醒金额", defaultValue = "")
                                                                @RequestParam(value = "money", required = false) String money,
                                                            @ApiParam(name = "status", value = "是否欠费提醒", defaultValue = "0")
                                                                @RequestParam(value = "status", required = false) String status){
        try {
            iotDeviceSimService.remind(time,money,status);
            return MixEnvelop.getSuccess(IotRequestMapping.DeviceSim.message_success_remind);
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
        }
    }
}

+ 16 - 0
svr/svr-iot/src/main/java/com/yihu/iot/controller/device/IotPatientDeviceController.java

@ -305,6 +305,22 @@ public class IotPatientDeviceController extends EnvelopRestEndpoint {
        }
    }
    @PostMapping(value = IotRequestMapping.PatientDevice.delPatientDevice)
    @ApiOperation(value = "设备回收", notes = "设备回收")
    public MixEnvelop<IotPatientDeviceVO, IotPatientDeviceVO> delPatientDevice(@ApiParam(name = "id", value = "居民设备id", defaultValue = "")
                                                                                  @RequestParam String id,
                                                                               @ApiParam(name = "del", value = "删除标志(1正常 0回收纳入库存 -1回收核销)", defaultValue = "")
                                                                               @RequestParam Integer del) {
        try {
            //设备回收
            iotPatientDeviceService.delPatientDevice(id, del);
            return MixEnvelop.getSuccess(IotRequestMapping.Device.message_success_delete);
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
        }
    }
    @PostMapping(value = IotRequestMapping.PatientDevice.createRepairDevice)
    @ApiOperation(value = "新增编辑设备维修记录", notes = "新增编辑设备维修记录")
    public MixEnvelop<IotPatientDeviceVO, IotPatientDeviceVO> createRepairDevice(@ApiParam(name = "deviceSn", value = "设备sn码")

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

@ -43,4 +43,14 @@ public interface IotDeviceDao extends PagingAndSortingRepository<IotDeviceDO, St
    List<IotDeviceDO> findListByOrderId(String orderId);
    List<IotDeviceDO> findListByInventoryLogId(String id);
    @Modifying
    @Query("update IotDeviceDO w set w.isGrant = ?2 where w.id = ?1 ")
    void updateIsGrantById(String deviceId, Integer isGrant);
    @Modifying
    @Query("update IotDeviceDO w set w.del = ?2 where w.id = ?1 ")
    void updateDelById(String id, int del);
}

+ 19 - 0
svr/svr-iot/src/main/java/com/yihu/iot/dao/device/IotDeviceOverhaulDao.java

@ -0,0 +1,19 @@
package com.yihu.iot.dao.device;
import com.yihu.jw.entity.iot.device.IotDeviceOverhaulDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
public interface IotDeviceOverhaulDao extends PagingAndSortingRepository<IotDeviceOverhaulDO, String>, JpaSpecificationExecutor<IotDeviceOverhaulDO> {
    @Query("select o from  IotDeviceOverhaulDO o where o.patientDeviceId = ?1 and o.status <> -1 order by o.time ")
    List<IotDeviceOverhaulDO> findAllByPatientDeviceId(String patientDeviceId);
    @Modifying
    @Query("update IotDeviceOverhaulDO o set o.status = -1 where o.patientDeviceId = ?1 ")
    void delOverhaulByPatientDeviceId(String patientDeviceId);
}

+ 3 - 0
svr/svr-iot/src/main/java/com/yihu/iot/dao/device/IotDeviceQualityInspectionPlanDao.java

@ -30,4 +30,7 @@ public interface IotDeviceQualityInspectionPlanDao extends PagingAndSortingRepos
    @Query(value = "SELECT a.* from iot_device_quality_inspection_plan a WHERE a.purchase_id = ?1 and a.status=?2 and a.del=1 ORDER BY a.plan_time asc limit 1",nativeQuery = true)
    IotDeviceQualityInspectionPlanDO findFirstByPurchaseId(String purchaseId,String status);
    @Query("from IotDeviceQualityInspectionPlanDO w where  w.status=1 and w.del=1 ORDER BY w.planTime desc")
    List<IotDeviceQualityInspectionPlanDO> findListAll();
}

+ 15 - 0
svr/svr-iot/src/main/java/com/yihu/iot/dao/device/IotDeviceSimDao.java

@ -0,0 +1,15 @@
package com.yihu.iot.dao.device;
import com.yihu.jw.entity.iot.device.IotDeviceSimDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * @author HZY
 * @vsrsion 1.0
 * Created at 2020/5/7
 */
public interface IotDeviceSimDao extends PagingAndSortingRepository<IotDeviceSimDO,String>, JpaSpecificationExecutor<IotDeviceSimDO> {
    IotDeviceSimDO  findBySim(String sim);
}

+ 7 - 0
svr/svr-iot/src/main/java/com/yihu/iot/dao/device/IotPatientDeviceDao.java

@ -44,4 +44,11 @@ public interface IotPatientDeviceDao extends PagingAndSortingRepository<IotPatie
    @Modifying
    @Query("update IotPatientDeviceDO t set t.deviceSn = ?3 , t.userType = ?4,t.sim=?5 where t.patient = ?1 and t.deviceSn = ?2 and t.del=1 ")
    int updatePatientDevice(String patient, String deviceSN, String newDeviceSN,String userType,String sim);
    @Query("from IotPatientDeviceDO a where a.sim = ?1 and  a.del=1 ")
    IotPatientDeviceDO findBySim(String sim);
    @Modifying
    @Query("update IotPatientDeviceDO t set t.del = ?2 where t.id = ?1")
    void updateDelById(String id, int del);
}

+ 17 - 0
svr/svr-iot/src/main/java/com/yihu/iot/dao/message/IotMessageDao.java

@ -0,0 +1,17 @@
package com.yihu.iot.dao.message;
import com.yihu.jw.entity.iot.device.IotDeviceQualityInspectionPlanDO;
import com.yihu.jw.entity.iot.message.IotMessageDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * @author suhaiwen
 * @vsrsion 1.0
 * Created at 2020/5/7
 */
public interface IotMessageDao extends PagingAndSortingRepository<IotMessageDO,String>,
        JpaSpecificationExecutor<IotMessageDO> {
}

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

@ -52,7 +52,7 @@ public class IotDeviceInventoryService extends BaseJpaService<IotDeviceInventory
     * @return
     */
    public MixEnvelop<IotDeviceVO, IotDeviceVO> getDeviceInventoryList(String name, String categoryCode, String hospitalName, Integer page, Integer pageSize) {
        String sql = "select d.id,d.product_id,d.`name`,d.category_code,d.category_name,d.manufacturer_id,d.manufacturer_name,d.hospital,d.hospital_name,count(id) inventoryCount FROM `iot_device` d where del=1  ";
        String sql = "select d.id,d.product_id,d.`name`,d.category_code,d.category_name,d.manufacturer_id,d.manufacturer_name,d.hospital,d.hospital_name,count(id) inventoryCount FROM `iot_device` d where del=1 and is_grant=0 ";
        if (StringUtils.isNotBlank(name)) {
            sql += "and name like '%" + name + "%' ";
        }

+ 40 - 0
svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotDeviceOverhaulService.java

@ -0,0 +1,40 @@
package com.yihu.iot.service.device;
import com.yihu.iot.dao.device.IotDeviceOverhaulDao;
import com.yihu.jw.entity.iot.device.IotDeviceOverhaulDO;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
/**
 * 设备检修相关管理接口
 * create by hmf on 2020.5.7
 */
@Service
public class IotDeviceOverhaulService extends BaseJpaService<IotDeviceOverhaulDO, IotDeviceOverhaulDao> {
    @Autowired
    private IotDeviceOverhaulDao deviceOverhaulDao;
    public List<IotDeviceOverhaulDO> getOverhaulListByPatientDeviceId(String patientDeviceId) {
        return deviceOverhaulDao.findAllByPatientDeviceId(patientDeviceId);
    }
    public IotDeviceOverhaulDO updateOverhaulStatusById(String id, Integer status, String remark) {
        IotDeviceOverhaulDO deviceOverhaulDO = deviceOverhaulDao.findOne(id);
        deviceOverhaulDO.setStatus(status);
        if(StringUtils.isNotBlank(remark)){
            deviceOverhaulDO.setRemark(remark);
        }
        deviceOverhaulDO.setUpdateTime(new Date());
        deviceOverhaulDao.save(deviceOverhaulDO);
        return deviceOverhaulDO;
    }
    public void delOverhaulByPatientDeviceId(String patientDeviceId) {
        deviceOverhaulDao.delOverhaulByPatientDeviceId(patientDeviceId);
    }
}

+ 47 - 20
svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotDeviceQualityInspectionPlanService.java

@ -1,12 +1,15 @@
package com.yihu.iot.service.device;
import com.alibaba.fastjson.JSONObject;
import com.yihu.iot.dao.device.IotDeviceDao;
import com.yihu.iot.dao.device.IotDeviceOrderDao;
import com.yihu.iot.dao.device.IotDeviceQualityInspectionPlanDao;
import com.yihu.iot.dao.device.IotOrderPurchaseDao;
import com.yihu.iot.dao.message.IotMessageDao;
import com.yihu.iot.service.dict.IotSystemDictService;
import com.yihu.jw.entity.iot.device.IotDeviceQualityInspectionPlanDO;
import com.yihu.jw.entity.iot.device.IotOrderPurchaseDO;
import com.yihu.jw.entity.iot.message.IotMessageDO;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.iot.device.IotDeviceQualityInspectionPlanVO;
import com.yihu.jw.rm.iot.IotRequestMapping;
@ -19,9 +22,7 @@ import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
 * @author yeshijie on 2017/12/8.
@ -103,12 +104,14 @@ public class IotDeviceQualityInspectionPlanService extends BaseJpaService<IotDev
     * 完成质检计划
     * @param purchaseId
     */
    public void completePlanByPurchaseId(String purchaseId,String time){
    public void completePlanByPurchaseId(String purchaseId,String time,String summary,List<String> imgs){
        IotDeviceQualityInspectionPlanDO planDO = iotDeviceQualityInspectionPlanDao.findFirstByPurchaseId(purchaseId,IotDeviceQualityInspectionPlanDO.QualityPlanStatus.create.getValue());
        if(planDO!=null){
            planDO.setStatus(IotDeviceQualityInspectionPlanDO.QualityPlanStatus.complete.getValue());
            planDO.setActualTime(DateUtil.strToDate(time));
            //设置质检小结与质检图像
            String imgJson = JSONObject.toJSONString(imgs);
            planDO.setImg(imgJson);
            iotDeviceQualityInspectionPlanDao.save(planDO);
            updatePurchase(purchaseId);
@ -116,6 +119,26 @@ public class IotDeviceQualityInspectionPlanService extends BaseJpaService<IotDev
    }
    /**
     * 完成质检计划
     * @param id 质检id
     */
    public void completePlan(String id,String time,String summary,List<String> imgs){
        IotDeviceQualityInspectionPlanDO planDO = iotDeviceQualityInspectionPlanDao.findById(id);
        if(planDO!=null){
            planDO.setStatus(IotDeviceQualityInspectionPlanDO.QualityPlanStatus.complete.getValue());
            planDO.setActualTime(DateUtil.strToDate(time));
            planDO.setSummary(summary);
            //设置质检小结与质检图像
            String imgJson = JSONObject.toJSONString(imgs);
            planDO.setImg(imgJson);
            iotDeviceQualityInspectionPlanDao.save(planDO);
            updatePurchase(planDO.getPurchaseId());
        }
    }
    /**
     * 更新采购清单的质检信息
     * @param purchaseId
@ -148,21 +171,6 @@ public class IotDeviceQualityInspectionPlanService extends BaseJpaService<IotDev
        }
    }
    /**
     * 完成质检计划
     * @param id 质检id
     */
    public void completePlan(String id,String time){
        IotDeviceQualityInspectionPlanDO planDO = iotDeviceQualityInspectionPlanDao.findById(id);
        if(planDO!=null){
            planDO.setStatus(IotDeviceQualityInspectionPlanDO.QualityPlanStatus.complete.getValue());
            planDO.setActualTime(DateUtil.strToDate(time));
            iotDeviceQualityInspectionPlanDao.save(planDO);
            updatePurchase(planDO.getPurchaseId());
        }
    }
    /**
     * 字典翻译
@ -256,4 +264,23 @@ public class IotDeviceQualityInspectionPlanService extends BaseJpaService<IotDev
        return MixEnvelop.getSuccessListWithPage(IotRequestMapping.Common.message_success_find_functions,qualityInspectionPlanVOList, page, size,count);
    }
    /**
     * 质检计划时间提醒
     * @param time
     */
    public void remindTimePlan(String time) {
        int remindTime = Integer.valueOf(time);
        List<IotDeviceQualityInspectionPlanDO> list = iotDeviceQualityInspectionPlanDao.findListAll();
        list.forEach(one->{
            Date remind = DateUtil.getPreDays(one.getPlanTime(), -remindTime);
            one.setRemindTime(remind);
            iotDeviceQualityInspectionPlanDao.save(one);
        });
    }
}

+ 172 - 0
svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotDeviceSimService.java

@ -0,0 +1,172 @@
package com.yihu.iot.service.device;
import com.alibaba.fastjson.JSONObject;
import com.yihu.iot.dao.device.IotDeviceDao;
import com.yihu.iot.dao.device.IotDeviceSimDao;
import com.yihu.iot.dao.device.IotPatientDeviceDao;
import com.yihu.jw.entity.iot.company.IotCompanyDO;
import com.yihu.jw.entity.iot.device.IotDeviceDO;
import com.yihu.jw.entity.iot.device.IotDeviceSimDO;
import com.yihu.jw.entity.iot.device.IotPatientDeviceDO;
import com.yihu.jw.entity.iot.platform.IotInterfaceAuditDO;
import com.yihu.jw.restmodel.iot.company.IotCompanyVO;
import com.yihu.jw.restmodel.iot.device.IotOrderVO;
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.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
 * @author HZY
 * @vsrsion 1.0
 * Created at 2020/5/7
 */
@Service
@Transactional
public class IotDeviceSimService  extends BaseJpaService<IotDeviceSimDO, IotDeviceSimDao> {
    @Autowired
    private IotPatientDeviceDao iotPatientDeviceDao;
    @Autowired
    private IotDeviceSimDao iotDeviceSimDao;
    @Autowired
    private  IotDeviceDao iotDeviceDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    /**
     * 增加SIM卡管理
     * @param advancePayment
     * @param payment
     * @param remainingBalance
     * @param status
     */
    public void editSIM(String id,String advancePayment,String payment,String remainingBalance,Integer status ) {
        IotDeviceSimDO simDO = iotDeviceSimDao.findOne(id);
        simDO.setAdvancePayment(Float.parseFloat(advancePayment));
        simDO.setPayment(Float.parseFloat(payment));
        simDO.setRemainingBalance(Float.parseFloat(remainingBalance));
        simDO.setStatus(status);
        iotDeviceSimDao.save(simDO);
    }
    /**
     *
     * @param json
     */
    public MixEnvelop<IotOrderVO, IotOrderVO> addSIM(String json) {
        IotDeviceSimDO sim = JSONObject.parseObject(json, IotDeviceSimDO.class);
        IotDeviceSimDO deviceSimDaoBySim = iotDeviceSimDao.findBySim(sim.getSim());
        if(deviceSimDaoBySim!=null){
            return MixEnvelop.getError("SIM已存在");
        }
        IotPatientDeviceDO patientSim = iotPatientDeviceDao.findBySim(sim.getSim());
        if (patientSim!=null){
            sim.setDeviceName(patientSim.getDeviceName());
            sim.setDeviceSn(patientSim.getDeviceSn());
            sim.setContactsName(patientSim.getPatientName());
            sim.setContactsMobile(patientSim.getMobile());
        } else {
            IotDeviceDO deviceSim = iotDeviceDao.findBySimNo(sim.getSim());
            if (deviceSim!=null){
                sim.setDeviceName(deviceSim.getName());
                sim.setDeviceSn(deviceSim.getDeviceSn());
            }
        }
        sim.setRemainingBalance(sim.getAdvancePayment()-sim.getPayment());
        sim.setStatus(1);
        iotDeviceSimDao.save(sim);
        return MixEnvelop.getSuccess(IotRequestMapping.DeviceSim.message_success_add);
    }
    /**
     * 条件分页查找
     * @param page
     * @param size
     * @param status
     * @param sim
     * @param sn
     * @return
     */
    public MixEnvelop<IotDeviceSimDO, IotDeviceSimDO> conditionQueryPage(Integer page, Integer size, String status, String sim, String sn){
        StringBuffer sql = new StringBuffer("SELECT DISTINCT c.* from iot_device_sim c WHERE 1=1 ");
        StringBuffer sqlCount = new StringBuffer("SELECT COUNT(DISTINCT c.id) count from iot_device_sim c  WHERE 1=1 ");
        List<Object> args = new ArrayList<>();
        if(StringUtils.isNotBlank(status)){
            sql.append(" and c.status=? ");
            sqlCount.append("and c.status='").append(status).append("' ");
            args.add(status);
        }
        if(StringUtils.isNotBlank(sim)){
            sql.append(" and (c.sim like '%").append(sim).append("%')");
            sqlCount.append(" and (c.sim like '%").append(sim).append("%')");
        }
        if(StringUtils.isNotBlank(sn)){
            sql.append(" and (c.device_sn like '%").append(sn).append("%')");
            sqlCount.append(" and (c.device_sn like '%").append(sn).append("%')");
        }
        sql.append("order by c.update_time desc limit ").append((page-1)*size).append(",").append(size);
        List<IotDeviceSimDO> list = jdbcTemplate.query(sql.toString(),args.toArray(),new BeanPropertyRowMapper(IotDeviceSimDO.class));
        List<Map<String,Object>> countList = jdbcTemplate.queryForList(sqlCount.toString());
        long count = Long.valueOf(countList.get(0).get("count").toString());
        return MixEnvelop.getSuccessListWithPage(IotRequestMapping.DeviceSim.message_success_find,list, page, size,count);
    }
    /**
     * 分页查找所有应用申请信息
     * @param page
     * @param size
     * @return
     */
    public MixEnvelop<IotDeviceSimDO, IotDeviceSimDO> findAllSim(Integer page, Integer size) {
        String sql="SELECT DISTINCT * FROM iot_device_sim ;";
        List<IotDeviceSimDO> list = jdbcTemplate.query(sql,new BeanPropertyRowMapper(IotDeviceSimDO.class));
        //获取总数
        long count = list.size();
        return MixEnvelop.getSuccessListWithPage(IotRequestMapping.DeviceSim.message_success_find,list,page, size,count);
    }
    /**
     *
     * @param time
     * @param money
     * @param status
     */
    public void remind(String time, String money, String status) {
        Iterable<IotDeviceSimDO> list = iotDeviceSimDao.findAll();
        list.forEach(one->{
            one.setRemindTime(time);
            one.setRemindArrears(status);
            one.setRemindBalance(money);
            iotDeviceSimDao.save(one);
        });
    }
}

+ 73 - 1
svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotPatientDeviceService.java

@ -2,13 +2,19 @@ package com.yihu.iot.service.device;
import com.alibaba.fastjson.JSONObject;
import com.yihu.elasticsearch.ElasticSearchHelper;
import com.yihu.iot.dao.device.IotDeviceDao;
import com.yihu.iot.dao.device.IotDeviceOverhaulDao;
import com.yihu.iot.dao.device.IotPatientDeviceDao;
import com.yihu.iot.datainput.util.ConstantUtils;
import com.yihu.iot.service.common.ElasticSearchQueryGenerator;
import com.yihu.iot.service.dict.IotSystemDictService;
import com.yihu.jw.device.LocationDataDO;
import com.yihu.jw.entity.iot.device.IotDeviceOverhaulDO;
import com.yihu.jw.entity.iot.device.IotPatientDeviceDO;
import com.yihu.jw.entity.iot.dict.IotSystemDictDO;
import com.yihu.jw.restmodel.iot.device.IotPatientDeviceVO;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.jw.rm.iot.IotRequestMapping;
import com.yihu.jw.util.common.LatitudeUtils;
import com.yihu.jw.util.date.DateUtil;
@ -22,7 +28,9 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.io.IOException;
import java.util.*;
@ -40,17 +48,48 @@ public class IotPatientDeviceService extends BaseJpaService<IotPatientDeviceDO,
    private ElasticSearchHelper elasticSearchHelper;
    @Autowired
    private ElasticSearchQueryGenerator elasticSearchQueryGenerator;
    @Autowired
    private IotDeviceDao iotDeviceDao;
    @Autowired
    private JdbcTemplate jdbcTempalte;
    @Autowired
    private IotSystemDictService iotSystemDictService;
    @Autowired
    private IotDeviceOverhaulDao deviceOverhaulDao;
    /**
     * 新增
     * @param patientDevice
     * @return
     */
    @Transactional
    public IotPatientDeviceDO create(IotPatientDeviceDO patientDevice) {
        patientDevice.setSaasId(getCode());
        patientDevice.setDel(1);
        return iotPatientDeviceDao.save(patientDevice);
        IotPatientDeviceDO patientDeviceDO = iotPatientDeviceDao.save(patientDevice);
        //更新设备绑定状态,减库存
        iotDeviceDao.updateIsGrantById(patientDevice.getDeviceId(), 1);
        //生成一年检修记录
        List<IotSystemDictDO> systemDictDOS = iotSystemDictService.getListByDictName("OVERHAUL_FREQUENCY");//获取设备检修时间
        if(systemDictDOS.size() == 1){
            List<IotDeviceOverhaulDO> deviceOverhaulDOS = new ArrayList<>();
            int day = Integer.parseInt(systemDictDOS.get(0).getValue());//检修间隔天数
            int count = 365/day;
            for(int i = 0 ; i< count; i++){
                IotDeviceOverhaulDO deviceOverhaulDO = new IotDeviceOverhaulDO();
                deviceOverhaulDO.setSaasId(getCode());
                deviceOverhaulDO.setPatientDeviceId(patientDeviceDO.getId());
                deviceOverhaulDO.setStatus(0);
                deviceOverhaulDO.setTime(DateUtil.dateToStr(DateUtil.getNextDay1(new Date(), day*(i+1)), "yyyy年MM月dd日"));
                deviceOverhaulDO.setCreateTime(new Date());
                deviceOverhaulDO.setUpdateTime(new Date());
                deviceOverhaulDOS.add(deviceOverhaulDO);
            }
            deviceOverhaulDao.save(deviceOverhaulDOS);
        }
        return patientDeviceDO;
    }
    /**
@ -365,4 +404,37 @@ public class IotPatientDeviceService extends BaseJpaService<IotPatientDeviceDO,
        }
        iotPatientDeviceDao.save(patientDeviceDOList);
    }
    @Transactional
    public void delPatientDevice(String id, Integer del) {
        IotPatientDeviceDO patientDeviceDO = iotPatientDeviceDao.findOne(id);
        patientDeviceDO.setDel(del);
        iotPatientDeviceDao.save(patientDeviceDO);
        //更新设备绑定状态,加库存
        iotDeviceDao.updateIsGrantById(patientDeviceDO.getDeviceId(), 0);
        if(del == -1){
            //核销设备
            iotDeviceDao.updateDelById(patientDeviceDO.getDeviceId(), 0);
        }
    }
    public MixEnvelop<IotPatientDeviceVO,IotPatientDeviceVO> getOverhaulDeviceList(String deviceSn, String patientName, Integer page, Integer pageSize) {
        String sql = "SELECT DISTINCT d.* FROM `iot_patient_device` d , iot_device_overhaul o where d.del= 1 and  d.id = o.patient_device_id ";
        if(StringUtils.isNotBlank(deviceSn)){
            sql += "and d.device_sn like '%" + deviceSn + "'% ";
        }
        if(StringUtils.isNotBlank(patientName)){
            sql += "and d.patientName like '%" + patientName + "'% ";
        }
        //判断是否需要分页
        if (page != null && pageSize != null) {
            Long count = Long.valueOf(jdbcTempalte.queryForList(sql).size());
            sql += "limit " + (page - 1) * pageSize + "," + pageSize;
            List<IotPatientDeviceVO> deviceVOList = jdbcTempalte.query(sql, new BeanPropertyRowMapper<>(IotPatientDeviceVO.class));
            return MixEnvelop.getSuccessListWithPage(IotRequestMapping.Common.message_success_find, deviceVOList, page, pageSize, count);
        } else {
            List<IotPatientDeviceVO> deviceVOList = jdbcTempalte.query(sql, new BeanPropertyRowMapper<>(IotPatientDeviceVO.class));
            return MixEnvelop.getSuccessList(IotRequestMapping.Common.message_success_find, deviceVOList);
        }
    }
}

+ 10 - 10
svr/svr-iot/src/main/java/com/yihu/iot/service/dict/IotSystemDictService.java

@ -51,18 +51,18 @@ public class IotSystemDictService extends BaseJpaService<IotSystemDictDO,IotSyst
                dictDO.setValue(value);
                dictDO.setParentCode(parentCode);
                dictDO.setUpdateTime(new Date());
            }
        }else {
            //获取最近一条添加记录的code
            List<IotSystemDictDO> dictDOList = iotSystemDictDao.getAllByDictNameAndOrderByCodeDesc(dictDO.getDictName());
            if (dictDOList.size() > 0) {
                dictDO.setCode((Long.parseLong(dictDOList.get(0).getCode()) + 1) + "");
            } else {
                //获取最近一条添加记录的code
                List<IotSystemDictDO> dictDOList = iotSystemDictDao.getAllByDictNameAndOrderByCodeDesc(dictDO.getDictName());
                if (dictDOList.size() > 0) {
                    dictDO.setCode((Long.parseLong(dictDOList.get(0).getCode()) + 1) + "");
                } else {
                    dictDO.setCode("1");
                }
                dictDO.setSaasId(getCode());
                dictDO.setDel(1);
                dictDO.setCreateTime(new Date());
                dictDO.setCode("1");
            }
            dictDO.setSaasId(getCode());
            dictDO.setDel(1);
            dictDO.setCreateTime(new Date());
        }
        iotSystemDictDao.save(dictDO);
        return dictDO;