Forráskód Böngészése

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

wangzhinan 5 éve
szülő
commit
0c2884a2ea
27 módosított fájl, 739 hozzáadás és 89 törlés
  1. 1 1
      common/common-entity/src/main/java/com/yihu/jw/entity/iot/device/IotPatientDeviceDO.java
  2. 20 0
      common/common-entity/src/main/java/com/yihu/jw/entity/iot/dict/IotSystemDictDO.java
  3. 6 6
      common/common-entity/src/main/java/com/yihu/jw/entity/iot/message/IotMessageDO.java
  4. 22 0
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/iot/IotRequestMapping.java
  5. 24 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/iot/device/IotDeviceQualityInspectionPlanVO.java
  6. 30 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/iot/device/IotPatientDeviceVO.java
  7. 22 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/web/MixEnvelop.java
  8. 3 3
      svr/svr-iot-job/src/main/java/com/yihu/jw/job/wlw/DeviceQualityPlanJob.java
  9. 32 0
      svr/svr-iot-job/src/main/java/com/yihu/jw/job/wlw/SimBalanceJob.java
  10. 23 17
      svr/svr-iot-job/src/main/java/com/yihu/jw/service/channel/DeviceQualityPlanService.java
  11. 59 0
      svr/svr-iot-job/src/main/java/com/yihu/jw/service/channel/SimBalanceService.java
  12. 65 0
      svr/svr-iot/src/main/java/com/yihu/iot/controller/IotMessageService/IotMessageController.java
  13. 1 1
      svr/svr-iot/src/main/java/com/yihu/iot/controller/device/IotDeviceController.java
  14. 12 0
      svr/svr-iot/src/main/java/com/yihu/iot/controller/device/IotDeviceOrderController.java
  15. 33 6
      svr/svr-iot/src/main/java/com/yihu/iot/controller/device/IotDeviceQualityController.java
  16. 1 1
      svr/svr-iot/src/main/java/com/yihu/iot/controller/device/IotDeviceSimController.java
  17. 57 0
      svr/svr-iot/src/main/java/com/yihu/iot/controller/device/IotPatientDeviceController.java
  18. 3 1
      svr/svr-iot/src/main/java/com/yihu/iot/controller/dict/HospitalController.java
  19. 2 2
      svr/svr-iot/src/main/java/com/yihu/iot/dao/device/IotDeviceQualityInspectionPlanDao.java
  20. 4 0
      svr/svr-iot/src/main/java/com/yihu/iot/dao/device/IotOrderPurchaseDao.java
  21. 16 0
      svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotDeviceOrderService.java
  22. 61 25
      svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotDeviceQualityInspectionPlanService.java
  23. 47 8
      svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotDeviceSimService.java
  24. 66 2
      svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotPatientDeviceService.java
  25. 4 1
      svr/svr-iot/src/main/java/com/yihu/iot/service/dict/IotHospitalService.java
  26. 83 0
      svr/svr-iot/src/main/java/com/yihu/iot/service/message/IotMessageService.java
  27. 42 15
      svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/service/SpecialistScreenResultService.java

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

@ -44,7 +44,7 @@ public class IotPatientDeviceDO extends UuidIdentityEntityWithOperator implement
    @Column(name = "user_type")
    private String userType;//按键号
    @Column(name = "del")
    private Integer del;//删除标志
    private Integer del;//删除标志(1正常 0回收纳入库存 -1回收核销)
    @Column(name = "hospital")
    private String hospital;//归属社区

+ 20 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/iot/dict/IotSystemDictDO.java

@ -32,6 +32,10 @@ public class IotSystemDictDO extends UuidIdentityEntityWithOperator implements S
    private Integer del;//删除标志
    @Column(name = "parent_code")
    private String parentCode;
    @Column(name = "status")
    private Integer status;
    @Column(name = "time")
    private String time;
    @Transient
    private String parentName;//父类字典名称
@ -99,6 +103,22 @@ public class IotSystemDictDO extends UuidIdentityEntityWithOperator implements S
        this.parentCode = parentCode;
    }
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    public String getTime() {
        return time;
    }
    public void setTime(String time) {
        this.time = time;
    }
    @Transient
    public String getParentName() {
        return parentName;

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

@ -22,8 +22,8 @@ public class IotMessageDO extends UuidIdentityEntityWithOperator implements Seri
    private String content;//消息内容
    @Column(name = "type")
    private String type;//消息类型 1:SIM卡续费通知 2:库存预警提醒 3:定期检修提醒 4:设备质检提醒',
    @Column(name = "read")
    private String read;//消息状态,1:已读  0:未读',
    @Column(name = "read_msg")
    private String readMsg;//消息状态,1:已读  0:未读',
    @Column(name = "del")
    private String del;//删除标志  1:删除  0:不删除',
    @Column(name = "relation_code")
@ -54,12 +54,12 @@ public class IotMessageDO extends UuidIdentityEntityWithOperator implements Seri
        this.type = type;
    }
    public String getRead() {
        return read;
    public String getReadMsg() {
        return readMsg;
    }
    public void setRead(String read) {
        this.read = read;
    public void setReadMsg(String readMsg) {
        this.readMsg = readMsg;
    }
    public String getDel() {

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

@ -13,6 +13,7 @@ public class IotRequestMapping {
     */
    public static class Common{
        public static final String company = api_iot_common + "/company";
        public static final String message = api_iot_common + "/message";
        public static final String system_dict = api_iot_common + "/systemDict";
        public static final String file_upload = api_iot_common + "/fileUpload";
        public static final String product = api_iot_common + "/product";
@ -104,6 +105,22 @@ public class IotRequestMapping {
    }
    /**
     * 消息模块
     */
    public static class Message {
        public static final String findAll = "findAll";
        public static final String markRead = "markRead";
        public static final String message_success_find = "message find success";
        public static final String message_success_update = "message mark success";
    }
    /**
     * 产品模块常量
     */
@ -145,6 +162,9 @@ public class IotRequestMapping {
        public static final String updateLocation= "updateLocation";
        public static final String createPatientDevice = "createPatientDevice";
        public static final String changePatientDevice = "changePatientDevice";
        public static final String getPatientDeviceList = "getPatientDeviceList";
        public static final String deleteDelPatientDevice = "deleteDelPatientDevice";
        //设备维修
        public static final String createRepairDevice = "createRepairDevice";
@ -245,6 +265,7 @@ public class IotRequestMapping {
        public static final String delPurchase = "delPurchase";
        public static final String updOrder = "updOrder";
        public static final String createOrder = "createOrder";
        public static final String findAllOrderNo = "findAllOrderNo";
        public static final String findPurcharsePage = "findPurcharsePage";
        public static final String findPurcharseById = "findPurcharseById";
@ -279,6 +300,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 findPlanTimeByOrderNo = "findPlanTimeByOrderNo";
        public static final String remindTimePlan = "remindTimePlan";
    }

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

@ -6,6 +6,7 @@ import com.yihu.jw.restmodel.iot.common.BaseVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import javax.persistence.Column;
import java.io.Serializable;
/**
@ -43,6 +44,13 @@ public class IotDeviceQualityInspectionPlanVO extends BaseVO implements Serializ
    @ApiModelProperty("质检状态(1未检,2已检)")
    private String statusName;
    //新增字段
    @ApiModelProperty("质检图像")
    private String img;//质检图像
    @ApiModelProperty("质检小结")
    private String summary;//质检小结
    public String getPurchaseId() {
        return purchaseId;
    }
@ -138,4 +146,20 @@ public class IotDeviceQualityInspectionPlanVO extends BaseVO implements Serializ
    public void setStatusName(String statusName) {
        this.statusName = statusName;
    }
    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;
    }
}

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

@ -61,6 +61,12 @@ public class IotPatientDeviceVO extends BaseVO implements Serializable {
    private String damageImages;//申请维修附件图片,多个用逗号隔开
    @ApiModelProperty("维修说明")
    private String repairDescription;//维修说明
    @ApiModelProperty("删除标志(1正常 0回收纳入库存 -1回收核销)")
    private Integer del;
    @ApiModelProperty("sim卡")
    private String sim;
    @ApiModelProperty("领用协议,多个用逗号隔开")
    private String imgs;
    public String getPatient() {
@ -246,4 +252,28 @@ public class IotPatientDeviceVO extends BaseVO implements Serializable {
    public void setRepairDescription(String repairDescription) {
        this.repairDescription = repairDescription;
    }
    public Integer getDel() {
        return del;
    }
    public void setDel(Integer del) {
        this.del = del;
    }
    public String getSim() {
        return sim;
    }
    public void setSim(String sim) {
        this.sim = sim;
    }
    public String getImgs() {
        return imgs;
    }
    public void setImgs(String imgs) {
        this.imgs = imgs;
    }
}

+ 22 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/web/MixEnvelop.java

@ -7,6 +7,7 @@ import io.swagger.annotations.ApiModelProperty;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * 信封对象,封装REST接口的返回值内容。包括:
@ -43,9 +44,20 @@ public class MixEnvelop<T, J> extends Envelop {
    @ApiModelProperty(value = "列表内容")
    private List<T> detailModelList = new ArrayList<>(0);
    @ApiModelProperty(value = "列表内容")
    private Map<T,T> detailModelMap = new HashMap<>(0);
    @ApiModelProperty(value = "实体内容")
    private J obj = (J)new HashMap<>(0);
    public Map<T, T> getDetailModelMap() {
        return detailModelMap;
    }
    public void setDetailModelMap(Map<T, T> detailModelMap) {
        this.detailModelMap = detailModelMap;
    }
    public int getCurrPage() {
        return currPage;
    }
@ -133,6 +145,16 @@ public class MixEnvelop<T, J> extends Envelop {
        envelop.setTotalCount(count.intValue());
        return envelop;
    }
    public static MixEnvelop getSuccessMapWithPage(String message, Map detailModelMap, int page, int size, Long count) {
        MixEnvelop envelop = new MixEnvelop();
        envelop.setMessage(message);
        envelop.setPageSize(size);
        envelop.setDetailModelMap(detailModelMap);
        envelop.setCurrPage(page);
        envelop.setStatus(200);
        envelop.setTotalCount(count.intValue());
        return envelop;
    }
    public static MixEnvelop getError(String message, int errorCode) {
        MixEnvelop envelop = new MixEnvelop();

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

@ -19,13 +19,13 @@ public class DeviceQualityPlanJob implements Job {
    private DeviceQualityPlanService deviceQualityPlanService;
    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        logger.info("START========PrescriptionStatusUpdateJob========");
        logger.info("START========DeviceQualityPlanJob========");
        try {
            deviceQualityPlanService.autoPush();
            logger.info("END========PrescriptionStatusUpdateJob========");
            logger.info("END========DeviceQualityPlanJob========");
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("END===ERROE===PrescriptionStatusUpdateJob,message:"+e.getMessage());
            logger.error("END===ERROE===DeviceQualityPlanJob,message:"+e.getMessage());
        }
    }
}

+ 32 - 0
svr/svr-iot-job/src/main/java/com/yihu/jw/job/wlw/SimBalanceJob.java

@ -0,0 +1,32 @@
package com.yihu.jw.job.wlw;
import com.yihu.jw.service.channel.DeviceQualityPlanService;
import com.yihu.jw.service.channel.SimBalanceService;
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/9
 */
public class SimBalanceJob implements Job {
    private static final Logger logger = LoggerFactory.getLogger(SimBalanceJob.class);
    @Autowired
    private SimBalanceService simBalanceService;
    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        logger.info("START========SimBalanceJob========");
        try {
            simBalanceService.autoPush();
            logger.info("END========SimBalanceJob========");
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("END===ERROE===SimBalanceJob,message:"+e.getMessage());
        }
    }
}

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

@ -1,16 +1,17 @@
package com.yihu.jw.service.channel;
import com.yihu.iot.dao.device.IotDeviceQualityInspectionPlanDao;
import com.yihu.iot.dao.dict.IotSystemDictDao;
import com.yihu.iot.dao.message.IotMessageDao;
import com.yihu.iot.service.device.IotDeviceQualityInspectionPlanService;
import com.yihu.jw.entity.iot.device.IotDeviceQualityInspectionPlanDO;
import com.yihu.jw.entity.iot.dict.IotSystemDictDO;
import com.yihu.jw.entity.iot.message.IotMessageDO;
import com.yihu.jw.util.DateUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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;
/**
@ -22,30 +23,35 @@ import java.util.List;
@Transactional
public class DeviceQualityPlanService {
    private static Logger logger = LoggerFactory.getLogger(DeviceQualityPlanService.class);
    @Autowired
    private  IotMessageDao iotMessageDao;
    @Autowired
    private IotMessageDao iotMessageDao;
    private  IotDeviceQualityInspectionPlanService iotDeviceQualityInspectionPlanService;
    @Autowired
    private IotDeviceQualityInspectionPlanDao iotDeviceQualityInspectionPlanDao;
    private  IotSystemDictDao iotSystemDictDao;
    public void autoPush() {
    public  void autoPush() {
        List<IotDeviceQualityInspectionPlanDO> listAll = iotDeviceQualityInspectionPlanDao.findListAll();
        logger.info("autoPush start");
        IotSystemDictDO qualityRemind = iotSystemDictDao.findByDictName("DEVICE_QUALITY_REMIND").get(0);
        String time = qualityRemind.getTime();
        List<IotDeviceQualityInspectionPlanDO> listAll = iotDeviceQualityInspectionPlanService.findListAll(time);
        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.setContent("订单:"+one.getOrderNo()+"将于:"+one.getPlanTime()+"进行质检,请及时维护");
                iotMessageDO.setReadMsg("0");
                iotMessageDO.setDel("0");
                iotMessageDO.setTitle("4");
                iotMessageDO.setType("4");
                iotMessageDao.save(iotMessageDO);
            }
        });
        logger.info("autoPush end");
    }
}

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

@ -0,0 +1,59 @@
package com.yihu.jw.service.channel;
import com.yihu.iot.dao.dict.IotSystemDictDao;
import com.yihu.iot.dao.message.IotMessageDao;
import com.yihu.iot.service.device.IotDeviceSimService;
import com.yihu.jw.entity.iot.device.IotDeviceSimDO;
import com.yihu.jw.entity.iot.dict.IotSystemDictDO;
import com.yihu.jw.entity.iot.message.IotMessageDO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
 * @author HZY
 * @vsrsion 1.0
 * Created at 2020/5/9
 */
@Service
@Transactional
public class SimBalanceService {
    private static Logger logger = LoggerFactory.getLogger(SimBalanceService.class);
    @Autowired
    private IotSystemDictDao iotSystemDictDao;
    @Autowired
    private IotDeviceSimService iotDeviceSimService;
    @Autowired
    private IotMessageDao iotMessageDao;
    public  void autoPush() {
        logger.info("autoPush start");
        IotSystemDictDO simBalanceRemind = iotSystemDictDao.findByDictName("SIM_BALANCE_REMIND").get(0);
       List<IotDeviceSimDO> list  = iotDeviceSimService.findAllRemindSim(simBalanceRemind.getTime(),simBalanceRemind.getCode());
       list.forEach(one->{
           IotMessageDO iotMessageDO = new IotMessageDO();
           iotMessageDO.setTitle("SIM卡续费通知");
           iotMessageDO.setContent("您的:"+one.getDeviceName()+"设备绑定的SIM卡:"+one.getSim()+"余额不足"+simBalanceRemind.getCode()+"元,请及时充值,避免设备离线");
           iotMessageDO.setReadMsg("0");
           iotMessageDO.setDel("0");
           iotMessageDO.setType("1");
           iotMessageDao.save(iotMessageDO);
       });
    }
    public String getCron(){
        IotSystemDictDO simBalanceRemind = iotSystemDictDao.findByDictName("SIM_BALANCE_REMIND").get(0);
        return "0 58 16 "+simBalanceRemind.getTime()+" * ?";
    }
}

+ 65 - 0
svr/svr-iot/src/main/java/com/yihu/iot/controller/IotMessageService/IotMessageController.java

@ -0,0 +1,65 @@
package com.yihu.iot.controller.IotMessageService;
import com.yihu.iot.service.message.IotMessageService;
import com.yihu.jw.entity.iot.message.IotMessageDO;
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.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * @author HZY
 * @vsrsion 1.0
 * Created at 2020/5/9
 */
@RestController
@RequestMapping(IotRequestMapping.Common.message)
@Api(tags = "消息列表相关操作", description = "企业管理相关操作")
public class IotMessageController extends EnvelopRestEndpoint {
    @Autowired
    private IotMessageService iotMessageService;
    @GetMapping(value = IotRequestMapping.Message.findAll)
    @ApiOperation(value = "分页查找消息列表", notes = "分页查找消息列表")
    public MixEnvelop<IotMessageDO,IotMessageDO> findAll(@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 iotMessageService.findAll(page,size);
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
        }
    }
    @GetMapping(value = IotRequestMapping.Message.markRead)
    @ApiOperation(value = "分页查找消息列表", notes = "分页查找消息列表")
    public MixEnvelop<IotMessageDO,IotMessageDO> markRead(@ApiParam(name = "id", value = "消息ID", defaultValue = "")
                                                         @RequestParam(value = "id", required = false) String id){
        try {
            return iotMessageService.markRead(id);
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
        }
    }
}

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

@ -74,7 +74,7 @@ public class IotDeviceController extends EnvelopRestEndpoint {
        try {
            Integer re = iotDeviceService.delDevice(id);
            if(re==1){
                return MixEnvelop.getSuccess(IotRequestMapping.Device.message_success_find);
                return MixEnvelop.getSuccess(IotRequestMapping.Device.message_success_delete);
            }else {
                return MixEnvelop.getError(IotRequestMapping.Device.del_message_fail);
            }

+ 12 - 0
svr/svr-iot/src/main/java/com/yihu/iot/controller/device/IotDeviceOrderController.java

@ -219,4 +219,16 @@ public class IotDeviceOrderController extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value = IotRequestMapping.DeviceOrder.findAllOrderNo)
    @ApiOperation(value = "查找所有订单编码", notes = "查找所有订单编码")
    public MixEnvelop<IotOrderPurchaseVO, IotOrderPurchaseVO> findAllOrderNo() {
        try {
            List<String> list = iotDeviceOrderService.findAllOrderNo();
            return MixEnvelop.getSuccess(IotRequestMapping.DeviceOrder.message_success_find,list);
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
        }
    }
}

+ 33 - 6
svr/svr-iot/src/main/java/com/yihu/iot/controller/device/IotDeviceQualityController.java

@ -47,8 +47,8 @@ public class IotDeviceQualityController extends EnvelopRestEndpoint {
    }
    @GetMapping(value = IotRequestMapping.DeviceQuality.findById)
    @ApiOperation(value = "根据code查找设备质检", notes = "根据code查找设备质检")
    public MixEnvelop<IotDeviceQualityInspectionPlanVO, IotDeviceQualityInspectionPlanVO> findByCode(@ApiParam(name = "id", value = "id")
    @ApiOperation(value = "根据ID查找设备质检", notes = "根据ID查找设备质检")
    public MixEnvelop<IotDeviceQualityInspectionPlanVO, IotDeviceQualityInspectionPlanVO> findByCode(@ApiParam(name = "id", value = "质检ID")
                              @RequestParam(value = "id", required = true) String id
    ) {
        try {
@ -61,12 +61,39 @@ public class IotDeviceQualityController extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value = IotRequestMapping.DeviceQuality.findPlanTimeByOrderNo)
    @ApiOperation(value = "根据订单查找设备质检计划时间列表", notes = "根据订单查找设备质检计划时间列表")
    public MixEnvelop<IotDeviceQualityInspectionPlanVO, IotDeviceQualityInspectionPlanVO> findPlanTimeByOrderNo(@ApiParam(name = "orderNo", value = "orderNo")
                                                                                                     @RequestParam(value = "orderNo", required = true
                                                                                                     ) String orderNo,
                                                                                                                @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;
            }
            MixEnvelop<IotDeviceQualityInspectionPlanVO, IotDeviceQualityInspectionPlanVO> list = iotDeviceQualityInspectionPlanService.findPlanTimeByOrderNo(orderNo, page, size);
            return MixEnvelop.getSuccess(IotRequestMapping.Common.message_success_find,list);
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
        }
    }
    @GetMapping(value = IotRequestMapping.DeviceQuality.queryQualityPlanPage)
    @ApiOperation(value = "分页获取设备质检计划", notes = "分页获取设备质检计划")
    public MixEnvelop<IotDeviceQualityInspectionPlanVO, IotDeviceQualityInspectionPlanVO> findProductPageByCompanyId(
            @ApiParam(name = "purcharseId", value = "采购id", defaultValue = "")
            @RequestParam(value = "purcharseId", required = false) String purcharseId,
            @ApiParam(name = "status", value = "质检状态", defaultValue = "")
            @RequestParam(value = "status", required = false) String status,
            @ApiParam(name = "orderNo", value = "订单编号", defaultValue = "")
            @RequestParam(value = "orderNo", required = false) String orderNo,
            @ApiParam(name = "startTime", value = "开始时间", defaultValue = "")
@ -116,7 +143,7 @@ public class IotDeviceQualityController extends EnvelopRestEndpoint {
//
//            return Envelop.getSuccessListWithPage(IotRequestMapping.Common.message_success_find_functions,voList, page, size,count);
            return iotDeviceQualityInspectionPlanService.queryPage(purcharseId, orderNo, startTime, endTime, page, size);
            return iotDeviceQualityInspectionPlanService.queryPage(status, orderNo, startTime, endTime, page, size);
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
@ -129,7 +156,7 @@ public class IotDeviceQualityController extends EnvelopRestEndpoint {
                                            @RequestParam(value = "id", required = true) String id) {
        try {
            iotDeviceQualityInspectionPlanService.delPlan(id);
            return MixEnvelop.getSuccess(IotRequestMapping.Common.message_success_find);
            return MixEnvelop.getSuccess(IotRequestMapping.Common.message_success_delete);
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());

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

@ -117,7 +117,7 @@ public class IotDeviceSimController extends EnvelopRestEndpoint {
    }
    @GetMapping(value = IotRequestMapping.DeviceSim.remind)
    @ApiOperation(value = "分页查询所有SIM卡信息",notes = "分页查询所有SIM卡信息")
    @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 = "")

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

@ -321,6 +321,23 @@ public class IotPatientDeviceController extends EnvelopRestEndpoint {
        }
    }
    @PostMapping(value = IotRequestMapping.PatientDevice.changePatientDevice)
    @ApiOperation(value = "设备更换", notes = "设备更换")
    public MixEnvelop<IotPatientDeviceVO, IotPatientDeviceVO> changePatientDevice(@ApiParam(name = "id", value = "居民设备id")
                                                                                      @RequestParam String id,
                                                                                  @ApiParam(name = "newDeviceSn", value = "新的设备sn码")
                                                                                  @RequestParam(value = "newDeviceSn", required = true) String newDeviceSn,
                                                                                  @ApiParam(name = "newDeviceId", value = "新的设备id")
                                                                                      @RequestParam(value = "newDeviceId", required = false) String newDeviceId) {
        try {
            IotPatientDeviceDO patientDevice =  iotPatientDeviceService.changePatientDevice(id, newDeviceSn, newDeviceId);
            return MixEnvelop.getSuccess(IotRequestMapping.Device.message_success_update, patientDevice);
        } 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码")
@ -389,4 +406,44 @@ public class IotPatientDeviceController extends EnvelopRestEndpoint {
            return MixEnvelop.getError(e.getMessage());
        }
    }
    @GetMapping(value = IotRequestMapping.PatientDevice.getPatientDeviceList)
    @ApiOperation(value = "获取居民设备发放和回收列表", notes = "获取居民设备发放和回收列表")
    public MixEnvelop<IotPatientDeviceVO, IotPatientDeviceVO> getDelPatientDeviceList(
            @ApiParam(name = "hospitalName", value = "机构名称", defaultValue = "")
            @RequestParam(value = "hospitalName", required = false) String hospitalName,
            @ApiParam(name = "deviceSn", value = "sn码", defaultValue = "")
            @RequestParam(value = "deviceSn", required = false) String deviceSn,
            @ApiParam(name = "deviceName", value = "设备名称", defaultValue = "")
            @RequestParam(value = "deviceName", required = false) String deviceName,
            @ApiParam(name = "categoryCode", value = "设备类型标识")
            @RequestParam(value = "categoryCode", required = false) String categoryCode,
            @ApiParam(name = "patientName", value = "居民姓名")
            @RequestParam(value = "patientName", required = false) String patientName,
            @ApiParam(name = "isDel", value = "是否是设备回收列表(1是 0否,设备发放列表)")
            @RequestParam(value = "isDel", required = false) Integer isDel,
            @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 iotPatientDeviceService.getPatientDeviceList(deviceSn, deviceName, categoryCode, patientName,hospitalName, isDel, page, pageSize);
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
        }
    }
    @PostMapping(value = IotRequestMapping.PatientDevice.deleteDelPatientDevice)
    @ApiOperation(value = "删除设备回收记录", notes = "删除设备回收记录")
    public MixEnvelop<IotPatientDeviceVO, IotPatientDeviceVO> deleteDelPatientDevice(@ApiParam(name = "id", value = "居民设备id")
                                                                                 @RequestParam(value = "id", required = true) String id) {
        try {
            iotPatientDeviceService.deleteDelPatientDevice(id);
            return MixEnvelop.getSuccess(IotRequestMapping.Device.message_success_delete);
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
        }
    }
}

+ 3 - 1
svr/svr-iot/src/main/java/com/yihu/iot/controller/dict/HospitalController.java

@ -40,12 +40,14 @@ public class HospitalController extends EnvelopRestEndpoint {
    public MixEnvelop getListByName(
            @ApiParam(name = "name", value = "机构名称")
            @RequestParam(value = "name", required = false) String name,
            @ApiParam(name = "level", value = "级别,1医院,2社区医院")
            @RequestParam(value = "level", required = false) String level,
            @ApiParam(name = "page", value = "当前页,从1开始")
            @RequestParam(value = "page", required = false) Integer page,
            @ApiParam(name = "pageSize", value = "页面大小")
            @RequestParam(value = "pageSize", required = false) Integer pageSize){
        try {
            List<IotHospitalDO> hospitalDOList = hospitalService.getListByName(name, page, pageSize);
            List<IotHospitalDO> hospitalDOList = hospitalService.getListByName(name, level, page, pageSize);
            return MixEnvelop.getSuccessList(IotRequestMapping.Company.message_success_find, hospitalDOList);
        } catch (Exception e) {
            e.printStackTrace();

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

@ -31,6 +31,6 @@ 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();
    List<IotDeviceQualityInspectionPlanDO> findByOrderNo(String orderNo);
}

+ 4 - 0
svr/svr-iot/src/main/java/com/yihu/iot/dao/device/IotOrderPurchaseDao.java

@ -5,6 +5,9 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
import java.util.Map;
/**
 * @author yeshijie on 2017/12/1.
 */
@ -19,4 +22,5 @@ public interface IotOrderPurchaseDao extends PagingAndSortingRepository<IotOrder
    @Query(value = "SELECT IFNULL(SUM(purchase_num),0)  from iot_order_purchase WHERE order_id =?1 and del = 1 ",nativeQuery = true)
    int sumByOrderId(String orderId);
    IotOrderPurchaseDO findByOrderNo(String orderNo);
}

+ 16 - 0
svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotDeviceOrderService.java

@ -427,4 +427,20 @@ public class IotDeviceOrderService extends BaseJpaService<IotDeviceOrderDO,IotDe
        return MixEnvelop.getSuccessListWithPage(IotRequestMapping.Common.message_success_find_functions,iotOrderPurchaseVOList, page, size,count);
    }
    /**
     * 、获取所有订单编码
     * @return
     */
    public List<String> findAllOrderNo() {
        String sql="select a.order_no from iot_order_purchase a where  a.del = 1 GROUP BY a.order_no";
        List<Map<String, Object>> mapList = jdbcTempalte.queryForList(sql);
        ArrayList<String> list = new ArrayList<>();
        mapList.forEach(one->{
            String orderNo = (String) one.get("order_no");
            list.add(orderNo);
        });
        return list;
    }
}

+ 61 - 25
svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotDeviceQualityInspectionPlanService.java

@ -5,16 +5,20 @@ 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.dict.IotSystemDictDao;
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.dict.IotSystemDictDO;
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;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.mysql.query.BaseJpaService;
import com.yihu.utils.network.HttpUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
@ -48,6 +52,11 @@ public class IotDeviceQualityInspectionPlanService extends BaseJpaService<IotDev
    @Autowired
    private IotDeviceDao iotDeviceDao;
    @Autowired
    private IotSystemDictDao iotSystemDictDao;
    private final static String jobUrl = "http://localhost:10031/job/reStartById?taskId=data_device_quality_plan_job";
    /**
     * 新增
     * @param iotDeviceQualityInspectionPlan
@ -56,7 +65,10 @@ public class IotDeviceQualityInspectionPlanService extends BaseJpaService<IotDev
    @Transactional
    public IotDeviceQualityInspectionPlanDO create(IotDeviceQualityInspectionPlanDO iotDeviceQualityInspectionPlan) {
        IotOrderPurchaseDO purchaseDO = iotOrderPurchaseDao.findById(iotDeviceQualityInspectionPlan.getPurchaseId());
        IotOrderPurchaseDO purchaseDO = iotOrderPurchaseDao.findByOrderNo(iotDeviceQualityInspectionPlan.getOrderNo());
        iotDeviceQualityInspectionPlan.setPurchaseId(purchaseDO.getId());
        iotDeviceQualityInspectionPlan.setDeviceId(purchaseDO.getProductId());
        iotDeviceQualityInspectionPlan.setOrderNo(purchaseDO.getOrderNo());
        iotDeviceQualityInspectionPlan.setDeviceId(purchaseDO.getProductId());
@ -225,39 +237,32 @@ public class IotDeviceQualityInspectionPlanService extends BaseJpaService<IotDev
     * 分页查找
     * @param page
     * @param size
     * @param purcharseId
     * @param status
     * @return
     */
    public MixEnvelop<IotDeviceQualityInspectionPlanVO, IotDeviceQualityInspectionPlanVO> queryPage(String purcharseId, String orderNo, String startTime, String endTime, Integer page, Integer size){
        StringBuffer sql = new StringBuffer("SELECT c.* from iot_device_quality_inspection_plan c  WHERE c.del=1 ");
        StringBuffer sqlCount = new StringBuffer("SELECT COUNT(c.id) count from iot_device_quality_inspection_plan c WHERE c.del=1 ");
    public MixEnvelop<IotDeviceQualityInspectionPlanVO, IotDeviceQualityInspectionPlanVO> queryPage(String status, String orderNo, String startTime, String endTime, Integer page, Integer size){
        StringBuffer sql = new StringBuffer("SELECT  c.* from iot_device_quality_inspection_plan c  WHERE c.del=1 ");
        List<Object> args = new ArrayList<>();
        if(StringUtils.isNotBlank(purcharseId)){
            sql.append(" and c.purchase_id=? ");
            sqlCount.append(" and c.purchase_id='").append(purcharseId).append("' ");
            args.add(purcharseId);
        if(StringUtils.isNotBlank(status)){
            sql.append(" and c.status=? ");
            args.add(status);
        }
        if(StringUtils.isNotBlank(orderNo)){
            sql.append(" and c.order_no=? ");
            sqlCount.append(" and c.order_no='").append(orderNo).append("' ");
            args.add(orderNo);
            sql.append("and c.order_no like'%").append(orderNo).append("%' ");
        }
        if(StringUtils.isNotBlank(startTime)){
            sql.append(" and c.plan_time>=? ");
            sqlCount.append(" and c.plan_time>='").append(startTime).append("' ");
            args.add(startTime);
        }
        if(StringUtils.isNotBlank(endTime)){
            sql.append(" and c.plan_time<=? ");
            sqlCount.append(" and c.plan_time<='").append(endTime).append("' ");
            args.add(endTime);
        }
        sql.append("order by c.update_time desc limit ").append((page-1)*size).append(",").append(size);
        sql.append(" GROUP BY c.order_no ORDER BY c.plan_time DESC limit ").append((page-1)*size).append(",").append(size);
        List<IotDeviceQualityInspectionPlanDO> list = jdbcTempalte.query(sql.toString(),args.toArray(),new BeanPropertyRowMapper(IotDeviceQualityInspectionPlanDO.class));
        List<Map<String,Object>> countList = jdbcTempalte.queryForList(sqlCount.toString());
        long count = Long.valueOf(countList.get(0).get("count").toString());
        long count = list.size();
        //DO转VO
        List<IotDeviceQualityInspectionPlanVO> qualityInspectionPlanVOList = transforList(list);
@ -271,16 +276,47 @@ public class IotDeviceQualityInspectionPlanService extends BaseJpaService<IotDev
     */
    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);
        });
        IotSystemDictDO qualityRemind= iotSystemDictDao.findByDictName("DEVICE_QUALITY_REMIND").get(0);
        qualityRemind.setTime(time);
        qualityRemind.setDel(1);
        iotSystemDictDao.save(qualityRemind);
    }
    /**
     * 查询所有需要提醒的质检信息
     * @param time
     * @return
     */
    public List<IotDeviceQualityInspectionPlanDO>  findListAll(String time){
        StringBuffer sql = new StringBuffer("SELECT c.* FROM  iot_device_quality_inspection_plan c WHERE del=1");
        List<Object> args = new ArrayList<>();
        if (StringUtils.isNotBlank(time)){
            sql.append("  and DATEDIFF(c.plan_time,CURRENT_TIMESTAMP)=?");
            args.add(time);
        }
        List<IotDeviceQualityInspectionPlanDO> list = jdbcTempalte.query(sql.toString(),args.toArray(),new BeanPropertyRowMapper(IotDeviceQualityInspectionPlanDO.class));
        return list;
    }
    /**
     * 根据订单编号查找所有计划时间
     * @param orderNo
     * @return
     */
    public MixEnvelop<IotDeviceQualityInspectionPlanVO, IotDeviceQualityInspectionPlanVO>  findPlanTimeByOrderNo(String orderNo,Integer page,Integer size) {
        List<IotDeviceQualityInspectionPlanDO> listOrderNo = iotDeviceQualityInspectionPlanDao.findByOrderNo(orderNo);
        List<IotDeviceQualityInspectionPlanVO> list = transforList(listOrderNo);
        long count = list.size();
        return MixEnvelop.getSuccessListWithPage(IotRequestMapping.Common.message_success_find_functions,list,page,size,count);
    }
}

+ 47 - 8
svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotDeviceSimService.java

@ -4,15 +4,19 @@ 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.iot.dao.dict.IotSystemDictDao;
import com.yihu.jw.entity.iot.company.IotCompanyDO;
import com.yihu.jw.entity.iot.device.IotDeviceDO;
import com.yihu.jw.entity.iot.device.IotDeviceQualityInspectionPlanDO;
import com.yihu.jw.entity.iot.device.IotDeviceSimDO;
import com.yihu.jw.entity.iot.device.IotPatientDeviceDO;
import com.yihu.jw.entity.iot.dict.IotSystemDictDO;
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.jw.util.http.HttpClientUtil;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -47,6 +51,14 @@ public class IotDeviceSimService  extends BaseJpaService<IotDeviceSimDO, IotDevi
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private IotSystemDictDao iotSystemDictDao;
    @Autowired
    private HttpClientUtil httpClientUtil;
    private final static String jobUrl = "http://localhost:10031/job/reStartById?taskId=data_sim_Balance_remind_job";
    /**
     * 增加SIM卡管理
     * @param advancePayment
@ -154,19 +166,46 @@ public class IotDeviceSimService  extends BaseJpaService<IotDeviceSimDO, IotDevi
    /**
     *
     *SIM余额提醒
     * @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);
        });
        IotSystemDictDO sim = iotSystemDictDao.findByDictName("SIM_BALANCE_REMIND").get(0);
        sim.setCode(money);
        sim.setStatus(Integer.parseInt(status));
        sim.setTime(time);
        iotSystemDictDao.save(sim);
        //触发JOB工程
        httpClientUtil.get(jobUrl,"UTF-8");
    }
    /**
     * 获取所有需要提醒的SIM卡
     * @param time
     * @param code
     * @return
     */
    public List<IotDeviceSimDO> findAllRemindSim(String time, String code) {
        StringBuffer sql = new StringBuffer("SELECT a.* FROM iot_device_sim a WHERE 1=1");
        List<Object> args = new ArrayList<>();
        if (StringUtils.isNotBlank(time)){
            sql.append("  AND DAY(CURRENT_TIMESTAMP)=?");
            args.add(time);
        }
        if(StringUtils.isNotBlank(code)){
            sql.append(" and a.remaining_balance <=? ");
            args.add(code);
        }
        List<IotDeviceSimDO> list = jdbcTemplate.query(sql.toString(),args.toArray(),new BeanPropertyRowMapper(IotDeviceSimDO.class));
        return list;
    }
}

+ 66 - 2
svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotPatientDeviceService.java

@ -9,6 +9,7 @@ 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.IotDeviceDO;
import com.yihu.jw.entity.iot.device.IotDeviceOverhaulDO;
import com.yihu.jw.entity.iot.device.IotPatientDeviceDO;
import com.yihu.jw.entity.iot.dict.IotSystemDictDO;
@ -409,6 +410,7 @@ public class IotPatientDeviceService extends BaseJpaService<IotPatientDeviceDO,
    public void delPatientDevice(String id, Integer del) {
        IotPatientDeviceDO patientDeviceDO = iotPatientDeviceDao.findOne(id);
        patientDeviceDO.setDel(del);
        patientDeviceDO.setUpdateTime(new Date());
        iotPatientDeviceDao.save(patientDeviceDO);
        //更新设备绑定状态,加库存
        iotDeviceDao.updateIsGrantById(patientDeviceDO.getDeviceId(), 0);
@ -421,10 +423,10 @@ public class IotPatientDeviceService extends BaseJpaService<IotPatientDeviceDO,
    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 + "'% ";
            sql += "and d.device_sn like '%" + deviceSn + "%' ";
        }
        if(StringUtils.isNotBlank(patientName)){
            sql += "and d.patientName like '%" + patientName + "'% ";
            sql += "and d.patient_name like '%" + patientName + "%' ";
        }
        //判断是否需要分页
        if (page != null && pageSize != null) {
@ -437,4 +439,66 @@ public class IotPatientDeviceService extends BaseJpaService<IotPatientDeviceDO,
            return MixEnvelop.getSuccessList(IotRequestMapping.Common.message_success_find, deviceVOList);
        }
    }
    public MixEnvelop<IotPatientDeviceVO,IotPatientDeviceVO> getPatientDeviceList(String deviceSn, String deviceName, String categoryCode, String patientName, String hospitalName, Integer isDel, Integer page, Integer pageSize) {
        String sql = "SELECT DISTINCT d.* FROM `iot_patient_device` d  where 1=1  ";
        if(isDel != null &&isDel == 1){
            sql += "and d.del != 1 ";
        }
        if(StringUtils.isNotBlank(deviceSn)){
            sql += "and d.device_sn like '%" + deviceSn + "%' ";
        }
        if(StringUtils.isNotBlank(patientName)){
            sql += "and d.patient_name like '%" + patientName + "%' ";
        }
        if(StringUtils.isNotBlank(deviceName)){
            sql += "and d.device_name like '%" + deviceName + "%' ";
        }
        if(StringUtils.isNotBlank(categoryCode)){
            sql += "and d.category_code = '" + categoryCode + "' ";
        }
        if(StringUtils.isNotBlank(hospitalName)){
            sql += "and d.hospital_name like '%" + hospitalName + "%' ";
        }
        //判断是否需要分页
        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);
        }
    }
    @Transactional
    public IotPatientDeviceDO changePatientDevice(String id, String newDeviceSn, String newDeviceId) {
        IotPatientDeviceDO patientDeviceDO = iotPatientDeviceDao.findOne(id);
        IotDeviceDO deviceDO = null;
        if(StringUtils.isNotBlank(newDeviceId)){
            deviceDO = iotDeviceDao.findById(newDeviceId);
        }else {
            deviceDO = iotDeviceDao.findByDeviceSn(newDeviceSn);
        }
        patientDeviceDO.setDeviceId(deviceDO.getId());
        patientDeviceDO.setDeviceName(deviceDO.getName());
        patientDeviceDO.setDeviceSn(deviceDO.getDeviceSn());
        patientDeviceDO.setSim(deviceDO.getSimNo());
        patientDeviceDO.setCategoryCode(deviceDO.getCategoryCode());
        patientDeviceDO.setCategoryName(deviceDO.getCategoryName());
        patientDeviceDO.setHospital(deviceDO.getHospital());
        patientDeviceDO.setHospitalName(deviceDO.getHospitalName());
        patientDeviceDO.setUpdateTime(new Date());
        iotPatientDeviceDao.save(patientDeviceDO);
        //更新设备绑定状态,减库存
        iotDeviceDao.updateIsGrantById(deviceDO.getId(), 1);
        return patientDeviceDO;
    }
    //删除居民设备回收记录
    public void deleteDelPatientDevice(String id) {
        iotPatientDeviceDao.delete(id);
    }
}

+ 4 - 1
svr/svr-iot/src/main/java/com/yihu/iot/service/dict/IotHospitalService.java

@ -28,11 +28,14 @@ public class IotHospitalService extends BaseJpaService<IotHospitalDO, IotHospita
        return hospitalDO;
    }
    public List<IotHospitalDO> getListByName(String name, Integer page, Integer pageSize) {
    public List<IotHospitalDO> getListByName(String name, String level, Integer page, Integer pageSize) {
        String sql = "SELECT * FROM `iot_hospital` h WHERE h.del = 1 ";
        if(StringUtils.isNotBlank(name)){
            sql += "and h.name like '%" + name + "%' ";
        }
        if(StringUtils.isNotBlank(level)){
            sql += "and h.level = '" + level + "' ";
        }
        if(page != null && pageSize != null){
            sql += "limit " + (page-1)*pageSize + "," + pageSize;
        }

+ 83 - 0
svr/svr-iot/src/main/java/com/yihu/iot/service/message/IotMessageService.java

@ -0,0 +1,83 @@
package com.yihu.iot.service.message;
import com.alibaba.fastjson.JSONArray;
import com.yihu.iot.dao.message.IotMessageDao;
import com.yihu.jw.entity.iot.company.IotCompanyDO;
import com.yihu.jw.entity.iot.device.IotDeviceQualityInspectionPlanDO;
import com.yihu.jw.entity.iot.message.IotMessageDO;
import com.yihu.jw.restmodel.iot.company.IotCompanyVO;
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.text.ParseException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * @author HZY
 * @vsrsion 1.0
 * Created at 2020/5/9
 */
@Service
@Transactional
public class IotMessageService  extends BaseJpaService<IotMessageDO, IotMessageDao> {
    @Autowired
    private IotMessageDao iotMessageDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    /**
     * 分页查找
     * @param page
     * @param size
     * @return
     * @throws ParseException
     */
    public MixEnvelop<IotMessageDO, IotMessageDO> findAll(Integer page, Integer size) throws ParseException {
        String sqlunRead="SELECT * FROM iot_message WHERE read_msg=0 ORDER BY create_time DESC;";
        String sqlRead="SELECT * FROM iot_message WHERE read_msg=1 ORDER BY create_time DESC;";
        List<IotMessageDO> unlist = jdbcTemplate.query(sqlunRead, new BeanPropertyRowMapper<>(IotMessageDO.class));
        List<IotMessageDO> list = jdbcTemplate.query(sqlRead, new BeanPropertyRowMapper<>(IotMessageDO.class));
        Map<String, List> listMap = new HashMap<>();
        listMap.put("unread",unlist);
        listMap.put("read",list);
        long size2 = unlist.size();
        long size1 = list.size();
        long count =size1+size2;
        return MixEnvelop.getSuccessMapWithPage(IotRequestMapping.Company.message_success_find_functions,listMap, page, size,count);
    }
    /**
     * 根据ID 设置消息已读
     * @param id
     * @return
     */
    public MixEnvelop<IotMessageDO, IotMessageDO> markRead(String id) {
        IotMessageDO messageDO = iotMessageDao.findOne(id);
        if(messageDO.getReadMsg().equalsIgnoreCase("1")){
            return MixEnvelop.getError("消息已标记已读,请勿重复操作");
        }
        messageDO.setReadMsg("1");
        iotMessageDao.save(messageDO);
        return MixEnvelop.getSuccess(IotRequestMapping.Message.message_success_update);
    }
}

+ 42 - 15
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/service/SpecialistScreenResultService.java

@ -139,23 +139,49 @@ public class SpecialistScreenResultService {
        List<SurveyTemplateQuestionsVo> questionList = jdbcTemplate.query(questionSql,new BeanPropertyRowMapper<>(SurveyTemplateQuestionsVo.class));
        String sql = "SELECT soa.*,sto.score,sto.content FROM "+basedb+".wlyy_survey_option_answers soa LEFT JOIN "+basedb+".wlyy_survey_template_options sto ON soa.options_code= sto.code WHERE soa.screen_result_code=? AND soa.patient=? AND soa.survey_code=?";
        List<Map<String,Object>> optionAnswersList = jdbcTemplate.queryForList(sql,new Object[]{code,patientCode,templateCode});
        //问答题答案
        String sqlQuestion = "SELECT sa.* FROM "+basedb+".wlyy_survey_answers sa LEFT JOIN "+basedb+".wlyy_survey_template_questions stq ON sa.question_code = stq.`code` WHERE sa.question_result_code=? AND sa.patient=? AND sa.survey_code=? ";
        List<Map<String, Object>> questionAnswersList = jdbcTemplate.queryForList(sqlQuestion, new Object[]{code, patientCode, templateCode});
        for (SurveyTemplateQuestionsVo surveyTemplateQuestionsVo : questionList){
            Map<String,Object> Qusmap = new HashMap<>();
            Qusmap.put("question",surveyTemplateQuestionsVo);
            String qusCode = surveyTemplateQuestionsVo.getCode();
            for (Map<String,Object> option : optionAnswersList){
            /*for (Map<String,Object> option : optionAnswersList){
                if (option.get("question_code").equals(qusCode)){
                    Qusmap.put("option",option);
                }
            }*/
            if(surveyTemplateQuestionsVo.getQuestionType() == 2){//问答题答案放在wlyy_survey_answers
                for (Map<String, Object> question : questionAnswersList) {
                    if (question.get("question_code").equals(qusCode)) {
                        Qusmap.put("option", question);
                    }
                }
            }else if(surveyTemplateQuestionsVo.getQuestionType() == 0){
                for (Map<String, Object> option : optionAnswersList) {
                    if (option.get("question_code").equals(qusCode)) {
                        Qusmap.put("option", option);
                    }
                }
            }else {
                List<Map<String, Object>> options = new ArrayList<>();
                for (Map<String, Object> option : optionAnswersList) {
                    if (option.get("question_code").equals(qusCode)) {
                        options.add(option);
                    }
                }
                Qusmap.put("option", options);
            }
            //map.put(surveyTemplateQuestionsVo.getSort()+"",Qusmap);
            answerMap.put(surveyTemplateQuestionsVo.getSort()+"",Qusmap);
        }
        map.put("answer",answerMap);
        //结果
        int following = surveyScreenResultVo.getFollowing();
        String reultSql ="SELECT ssr.screen_result_score,ssr.screen_result,str.advice FROM "+basedb+".wlyy_survey_screen_result ssr LEFT JOIN "+basedb+".wlyy_survey_template_result str ON ssr.screen_result_code = str.code WHERE ssr.code='"+code+"'";
        Map<String,Object> resultMap = jdbcTemplate.queryForMap(reultSql);
        String reultSql = "SELECT ssr.screen_result_score,ssr.screen_result,str.advice,ssr.other_advice,ssr.third_advice FROM " + basedb + ".wlyy_survey_screen_result ssr LEFT JOIN " + basedb + ".wlyy_survey_template_result str ON ssr.screen_result_code = str.code WHERE ssr.code='" + code + "'";
        Map<String, Object> resultMap = jdbcTemplate.queryForMap(reultSql);
        if(surveyScreenResultVo.getFollowing() != null) {
            int following = surveyScreenResultVo.getFollowing();
        /*int following = surveyScreenResultVo.getFollowing();
        int order = surveyScreenResultVo.getOrder();
        if (following==1){
@ -169,20 +195,21 @@ public class SpecialistScreenResultService {
            }
            resultMap.put("advice",surveyAdviceList);
        }*/
        if (following==1){
            String adviceCodes = surveyScreenResultVo.getAdviceCode();
            List<Map<String,Object>> surveyAdviceList = new ArrayList<>();
            if (StringUtils.isNotEmpty(adviceCodes)){
                String[] advicesStr = adviceCodes.split(",");
                for (String adviceCode : advicesStr){
                    String advice ="SELECT * FROM wlyy.wlyy_survey_advice where code='"+adviceCode+"'";
                    surveyAdviceList.addAll(jdbcTemplate.queryForList(advice));
            if (following == 1) {
                String adviceCodes = surveyScreenResultVo.getAdviceCode();
                List<Map<String, Object>> surveyAdviceList = new ArrayList<>();
                if (StringUtils.isNotEmpty(adviceCodes)) {
                    String[] advicesStr = adviceCodes.split(",");
                    for (String adviceCode : advicesStr) {
                        String advice = "SELECT * FROM wlyy.wlyy_survey_advice where code='" + adviceCode + "'";
                        surveyAdviceList.addAll(jdbcTemplate.queryForList(advice));
                    }
                }
                resultMap.put("doctorAdvice", surveyAdviceList);
                resultMap.put("doctorOtherAdvice", surveyScreenResultVo.getOtherAdvice());
            }
            resultMap.put("doctorAdvice",surveyAdviceList);
            resultMap.put("doctorOtherAdvice",surveyScreenResultVo.getOtherAdvice());
        }
        map.put("result",resultMap);
        map.put("result", resultMap);
        return MixEnvelop.getSuccess(SpecialistMapping.api_success,map);
    }