Browse Source

Merge branch 'dev' of yeshijie/jw2.0 into dev

yeshijie 7 years ago
parent
commit
eda593d657
29 changed files with 654 additions and 113 deletions
  1. 1 0
      app/app-iot-server/src/main/java/com/yihu/ehr/iot/constant/ServiceApi.java
  2. 30 1
      app/app-iot-server/src/main/java/com/yihu/ehr/iot/controller/device/IotDeviceOrderController.java
  3. 14 7
      app/app-iot-server/src/main/java/com/yihu/ehr/iot/controller/device/IotDeviceQualityController.java
  4. 3 1
      app/app-iot-server/src/main/java/com/yihu/ehr/iot/controller/third/wlyy/MonitoringHealthPlatformController.java
  5. 24 0
      app/app-iot-server/src/main/java/com/yihu/ehr/iot/service/device/DeviceOrderService.java
  6. 5 1
      app/app-iot-server/src/main/java/com/yihu/ehr/iot/service/device/IotDeviceQualityService.java
  7. 47 10
      app/app-iot-server/src/main/java/com/yihu/ehr/iot/service/third/wlyy/MonitoringHealthService.java
  8. 1 1
      app/app-iot-server/src/main/resources/application.yml
  9. 29 18
      common/common-entity/src/main/java/com/yihu/jw/iot/device/IotOrderPurchaseDO.java
  10. 18 0
      common/common-fegin/src/main/java/com/yihu/jw/fegin/fallbackfactory/iot/device/IotDeviceOrderFallbackFactory.java
  11. 6 0
      common/common-fegin/src/main/java/com/yihu/jw/fegin/fallbackfactory/iot/device/IotDeviceQualityFallbackFactory.java
  12. 13 1
      common/common-fegin/src/main/java/com/yihu/jw/fegin/iot/device/IotDeviceOrderFeign.java
  13. 3 0
      common/common-fegin/src/main/java/com/yihu/jw/fegin/iot/device/IotDeviceQualityFeign.java
  14. 1 0
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/iot/IotRequestMapping.java
  15. 9 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/common/Envelop.java
  16. 33 1
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/iot/device/IotDeviceVO.java
  17. 20 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/iot/device/IotOrderPurchaseVO.java
  18. 10 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/iot/device/IotPatientDeviceVO.java
  19. 1 0
      svr/svr-iot/src/main/java/com/yihu/iot/controller/device/IotDeviceController.java
  20. 47 11
      svr/svr-iot/src/main/java/com/yihu/iot/controller/device/IotDeviceOrderController.java
  21. 45 29
      svr/svr-iot/src/main/java/com/yihu/iot/controller/device/IotDeviceQualityController.java
  22. 1 1
      svr/svr-iot/src/main/java/com/yihu/iot/controller/device/IotPatientDeviceController.java
  23. 8 0
      svr/svr-iot/src/main/java/com/yihu/iot/dao/device/IotDeviceQualityInspectionPlanDao.java
  24. 112 21
      svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotDeviceOrderService.java
  25. 77 0
      svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotDeviceQualityInspectionPlanService.java
  26. 52 0
      svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotDeviceService.java
  27. 12 3
      svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotPatientDeviceService.java
  28. 18 0
      web-gateway/src/main/java/com/yihu/jw/controller/iot/device/IotDeviceOrderController.java
  29. 14 7
      web-gateway/src/main/java/com/yihu/jw/controller/iot/device/IotDeviceQualityController.java

+ 1 - 0
app/app-iot-server/src/main/java/com/yihu/ehr/iot/constant/ServiceApi.java

@ -84,6 +84,7 @@ public class ServiceApi {
        public static final String FindPurcharsePage = Base +"findPurcharsePage";
        public static final String FindPurcharseById = Base +"findPurcharseById";
        public static final String FindQualityPage = Base +"findQualityPage";
        public DeviceOrder() {
        }

+ 30 - 1
app/app-iot-server/src/main/java/com/yihu/ehr/iot/controller/device/IotDeviceOrderController.java

@ -37,7 +37,7 @@ public class IotDeviceOrderController extends BaseController {
    @GetMapping(value = IotRequestMapping.DeviceOrder.findById)
    @ApiOperation(value = "根据id查找设备订单", notes = "根据id查找设备订单")
    public Envelop<IotDeviceOrderVO>  findByCode(@ApiParam(name = "id", value = "id")
    public Envelop<IotDeviceOrderVO> findByCode(@ApiParam(name = "id", value = "id")
                              @RequestParam(value = "id", required = true) String id) {
        try {
            return deviceOrderService.findByCode(id);
@ -130,4 +130,33 @@ public class IotDeviceOrderController extends BaseController {
        }
    }
    @GetMapping(value = IotRequestMapping.DeviceOrder.findQualityPage)
    @ApiOperation(value = "质检管理", notes = "质检管理")
    public Envelop<IotOrderPurchaseVO> findQualityPage(
            @ApiParam(name = "qualityStatus", value = "质检状态", defaultValue = "")
            @RequestParam(value = "qualityStatus", required = false) String qualityStatus,
            @ApiParam(name = "orderNo", value = "订单编号", defaultValue = "")
            @RequestParam(value = "orderNo", required = false) String orderNo,
            @ApiParam(name = "startTime", value = "开始时间", defaultValue = "")
            @RequestParam(value = "startTime", required = false) String startTime,
            @ApiParam(name = "endTime", value = "结束时间", defaultValue = "")
            @RequestParam(value = "endTime", required = false) String endTime,
            @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 deviceOrderService.findQualityPage(qualityStatus, orderNo, startTime, endTime, page, size);
        } catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError(e.getMessage());
        }
    }
}

+ 14 - 7
app/app-iot-server/src/main/java/com/yihu/ehr/iot/controller/device/IotDeviceQualityController.java

@ -49,14 +49,21 @@ public class IotDeviceQualityController extends BaseController{
    @GetMapping(value = IotRequestMapping.DeviceQuality.queryQualityPlanPage)
    @ApiOperation(value = "分页获取设备质检计划", notes = "分页获取设备质检计划")
    public Envelop<IotDeviceQualityInspectionPlanVO> queryQualityPlanPage(@ApiParam(name = "purcharseId", value = "采购id", defaultValue = "")
                                                           @RequestParam(value = "purcharseId", required = false) String purcharseId,
                                                           @ApiParam(name = "page", value = "第几页", defaultValue = "")
                                                           @RequestParam(value = "page", required = false) Integer page,
                                                           @ApiParam(name = "size", value = "每页记录数", defaultValue = "")
                                                           @RequestParam(value = "size", required = false) Integer size){
    public Envelop<IotDeviceQualityInspectionPlanVO> queryQualityPlanPage(
            @ApiParam(name = "purcharseId", value = "采购id", defaultValue = "")
            @RequestParam(value = "purcharseId", required = false) String purcharseId,
            @ApiParam(name = "orderNo", value = "订单编号", defaultValue = "")
            @RequestParam(value = "orderNo", required = false) String orderNo,
            @ApiParam(name = "startTime", value = "开始时间", defaultValue = "")
            @RequestParam(value = "startTime", required = false) String startTime,
            @ApiParam(name = "endTime", value = "结束时间", defaultValue = "")
            @RequestParam(value = "endTime", required = false) String endTime,
            @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 {
            return iotDeviceQualityService.queryQualityPlanPage(purcharseId, page, size);
            return iotDeviceQualityService.queryQualityPlanPage(purcharseId, orderNo, startTime, endTime, page, size);
        } catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError(e.getMessage());

+ 3 - 1
app/app-iot-server/src/main/java/com/yihu/ehr/iot/controller/third/wlyy/MonitoringHealthPlatformController.java

@ -41,6 +41,8 @@ public class MonitoringHealthPlatformController extends BaseController{
    public Envelop<List<LocationDataVO>> findDeviceLocationsByIdCard(
            @ApiParam(name = "diseaseCondition", value = "病情:0绿标,1黄标,2红标,-1没有标注的居民", defaultValue = "")
            @RequestParam(value = "diseaseCondition",required = false) Integer diseaseCondition,
            @ApiParam(name = "type", value = "1高血压 2糖尿病", defaultValue = "")
            @RequestParam(value = "type",required = false) String type,
            @ApiParam(name="page",value="第几页(默认第一页)",defaultValue = "1")
            @RequestParam(value="page",required = false) Integer page,
            @ApiParam(name="pageSize",value="每页几行(默认10条记录)",defaultValue = "10")
@ -52,7 +54,7 @@ public class MonitoringHealthPlatformController extends BaseController{
            if(pageSize==null){
                pageSize = 10;
            }
            return monitoringHealthService.findDeviceLocations(diseaseCondition,page,pageSize);
            return monitoringHealthService.findDeviceLocations(diseaseCondition,page,pageSize,type);
        } catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError(e.getMessage());

+ 24 - 0
app/app-iot-server/src/main/java/com/yihu/ehr/iot/service/device/DeviceOrderService.java

@ -127,4 +127,28 @@ public class DeviceOrderService extends BaseService{
        return envelop;
    }
    /**
     * 质检管理
     * @param qualityStatus
     * @param orderNo
     * @param startTime
     * @param endTime
     * @param page
     * @param size
     * @return
     */
    public Envelop<IotOrderPurchaseVO> findQualityPage(String qualityStatus,
            String orderNo,String startTime,String endTime,Integer page,Integer size) throws IOException {
        Map<String, Object> params = new HashMap<>();
        params.put("qualityStatus", qualityStatus);
        params.put("orderNo", orderNo);
        params.put("startTime", startTime);
        params.put("endTime", endTime);
        params.put("page", page);
        params.put("size", size);
        HttpResponse response = HttpHelper.get(iotUrl + ServiceApi.DeviceOrder.FindQualityPage, params);
        Envelop<IotOrderPurchaseVO> envelop = objectMapper.readValue(response.getBody(), Envelop.class);
        return envelop;
    }
}

+ 5 - 1
app/app-iot-server/src/main/java/com/yihu/ehr/iot/service/device/IotDeviceQualityService.java

@ -52,9 +52,13 @@ public class IotDeviceQualityService extends BaseService{
     * @return
     * @throws IOException
     */
    public Envelop<IotDeviceQualityInspectionPlanVO> queryQualityPlanPage(String purcharseId,Integer page,Integer size) throws IOException{
    public Envelop<IotDeviceQualityInspectionPlanVO> queryQualityPlanPage(String purcharseId,String orderNo,
            String startTime,String endTime,Integer page,Integer size) throws IOException{
        Map<String, Object> params = new HashMap<>();
        params.put("purcharseId", purcharseId);
        params.put("orderNo", orderNo);
        params.put("startTime", startTime);
        params.put("endTime", endTime);
        params.put("page", page);
        params.put("size", size);
        HttpResponse response = HttpHelper.get(iotUrl + ServiceApi.Quality.QueryQualityPlanPage, params);

+ 47 - 10
app/app-iot-server/src/main/java/com/yihu/ehr/iot/service/third/wlyy/MonitoringHealthService.java

@ -11,6 +11,7 @@ import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.iot.device.LocationDataVO;
import com.yihu.jw.util.date.DateUtil;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
@ -44,17 +45,37 @@ public class MonitoringHealthService extends BaseService{
     * @param diseaseCondition
     * @return
     */
    public Envelop<List<LocationDataVO>> findDeviceLocations(Integer diseaseCondition,Integer page,Integer size) throws IOException {
    public Envelop<List<LocationDataVO>> findDeviceLocations(Integer diseaseCondition,Integer page,Integer size,String type) throws IOException {
        Envelop<List<LocationDataVO>> envelop = null;
        JSONArray jsonArray = new JSONArray();
        if(diseaseCondition!=null){
            JSONObject json = new JSONObject();
            json.put("andOr","and");
            json.put("field","diseaseCondition");
            json.put("condition","=");
            json.put("value",diseaseCondition);
            jsonArray.add(json);
        Integer total = 0;
        if(StringUtils.isNotBlank(type)){
            String re = searchpatientdevicesn(type, page, size);
            JSONObject json = JSON.parseObject(re);
            if(json.getInteger("status")==200){
                JSONObject data = json.getJSONObject("data");
                total = data.getInteger("total");
                JSONArray list = data.getJSONArray("list");
                for(int i=0;i<list.size();i++){
                    JSONObject deviceSn = new JSONObject();
                    deviceSn.put("andOr","or");
                    deviceSn.put("field","deviceSn");
                    deviceSn.put("condition","=");
                    deviceSn.put("value",list.getString(i));
                    jsonArray.add(deviceSn);
                }
            }
        }else {
            //查找全部
            if(diseaseCondition!=null){
                JSONObject json = new JSONObject();
                json.put("andOr","and");
                json.put("field","diseaseCondition");
                json.put("condition","=");
                json.put("value",diseaseCondition);
                jsonArray.add(json);
            }
        }
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("filter",jsonArray);
        jsonObject.put("page",page);
@ -62,10 +83,26 @@ public class MonitoringHealthService extends BaseService{
        Map<String, Object> params = new HashMap<>();
        params.put("jsonData", jsonObject.toString());
        HttpResponse response = HttpHelper.get(iotUrl + ServiceApi.PatientDevice.findLocationByIdCard, params);
        Envelop<List<LocationDataVO>> envelop = objectMapper.readValue(response.getBody(),Envelop.class);
        envelop = objectMapper.readValue(response.getBody(),Envelop.class);
        if(envelop.getTotalCount()==0){
            envelop.setTotalCount(total);
        }
        return envelop;
    }
    /**
     * 根据病种类型,搜索已绑定设备的居民设备SN码
     * 类型(1高血压 2糖尿病)
     */
    public String searchpatientdevicesn(String type,Integer page,Integer size){
        String url = "/wlyygc/iot_monitoring/searchpatientdevicesn";
        Map<String, Object> params = new HashMap<>();
        params.put("type",type);
        params.put("page",page);
        params.put("pageSize",size);
        return sendGet(url,params);
    }
    /**
     * 访问i健康接口,自带登录信息

+ 1 - 1
app/app-iot-server/src/main/resources/application.yml

@ -90,7 +90,7 @@ app:
  oauth2InnerUrl: http://172.19.103.73:10260/
  oauth2OuterUrl: http://27.154.233.186:10260/
service-gateway:
  iotUrl: http://172.19.103.88:8088/svr-iot/
  iotUrl: http://172.19.103.33:8088/svr-iot/
  profileInnerUrl: http://172.19.103.73:10000/api/v1.0/admin
  profileOuterUrl: http://27.154.233.186:10000/api/v1.0/admin
  portalInnerUrl: http://172.19.103.73:10280/api/v1.0/portal

+ 29 - 18
common/common-entity/src/main/java/com/yihu/jw/iot/device/IotOrderPurchaseDO.java

@ -6,6 +6,7 @@ import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;
/**
 * 采购清单表
@ -51,11 +52,14 @@ public class IotOrderPurchaseDO extends IdEntityWithOperation implements Seriali
    @Column(name = "purchase_num")
    private Long purchaseNum;//采购数量
//    @Column(name = "next_quality_time")
//    private Date nextQualityTime;//'下次质检时间'
    @Column(name = "next_quality_time")
    private Date nextQualityTime;//下次质检时间
//    @Column(name = "quality_status")
//    private String qualityStatus;//'质检状态'
    @Column(name = "quality_status")
    private String qualityStatus;//质检状态
    @Column(name = "quality_leader")
    private String qualityLeader;//质检负责人
    @Column(name = "maintenance_unit_id")
    private String maintenanceUnitId;//维护单位Id
@ -154,14 +158,13 @@ public class IotOrderPurchaseDO extends IdEntityWithOperation implements Seriali
        this.purchaseNum = purchaseNum;
    }
//    public Date getNextQualityTime() {
//        return nextQualityTime;
//    }
//
//    public void setNextQualityTime(Date nextQualityTime) {
//        this.nextQualityTime = nextQualityTime;
//    }
    public Date getNextQualityTime() {
        return nextQualityTime;
    }
    public void setNextQualityTime(Date nextQualityTime) {
        this.nextQualityTime = nextQualityTime;
    }
    public String getProductId() {
        return productId;
@ -171,13 +174,21 @@ public class IotOrderPurchaseDO extends IdEntityWithOperation implements Seriali
        this.productId = productId;
    }
//    public String getQualityStatus() {
//        return qualityStatus;
//    }
//
//    public void setQualityStatus(String qualityStatus) {
//        this.qualityStatus = qualityStatus;
//    }
    public String getQualityStatus() {
        return qualityStatus;
    }
    public void setQualityStatus(String qualityStatus) {
        this.qualityStatus = qualityStatus;
    }
    public String getQualityLeader() {
        return qualityLeader;
    }
    public void setQualityLeader(String qualityLeader) {
        this.qualityLeader = qualityLeader;
    }
    public Integer getDel() {
        return del;

+ 18 - 0
common/common-fegin/src/main/java/com/yihu/jw/fegin/fallbackfactory/iot/device/IotDeviceOrderFallbackFactory.java

@ -83,6 +83,24 @@ public class IotDeviceOrderFallbackFactory implements FallbackFactory<IotDeviceO
                tracer.getCurrentSpan().logEvent("id:" + id);
                return null;
            }
            @Override
            public Envelop<IotOrderPurchaseVO> findQualityPage(
                    @RequestParam(value = "qualityStatus", required = false) String qualityStatus,
                    @RequestParam(value = "orderNo", required = false) String orderNo,
                    @RequestParam(value = "startTime", required = false) String startTime,
                    @RequestParam(value = "endTime", required = false) String endTime,
                    @RequestParam(value = "page", required = false) Integer page,
                    @RequestParam(value = "size", required = false) Integer size){
                tracer.getCurrentSpan().logEvent("查找质检管理失败:原因:" + e.getMessage());
                tracer.getCurrentSpan().logEvent("qualityStatus:" + qualityStatus);
                tracer.getCurrentSpan().logEvent("orderNo:" + orderNo);
                tracer.getCurrentSpan().logEvent("startTime:" + startTime);
                tracer.getCurrentSpan().logEvent("endTime:" + endTime);
                tracer.getCurrentSpan().logEvent("page:" + page);
                tracer.getCurrentSpan().logEvent("size:" + size);
                return null;
            }
        };
    }

+ 6 - 0
common/common-fegin/src/main/java/com/yihu/jw/fegin/fallbackfactory/iot/device/IotDeviceQualityFallbackFactory.java

@ -39,10 +39,16 @@ public class IotDeviceQualityFallbackFactory implements FallbackFactory<IotDevic
            @Override
            public Envelop<IotDeviceQualityInspectionPlanVO> queryQualityPlanPage(
                    @RequestParam(value = "purcharseId", required = false) String purcharseId,
                    @RequestParam(value = "orderNo", required = false) String orderNo,
                    @RequestParam(value = "startTime", required = false) String startTime,
                    @RequestParam(value = "endTime", required = false) String endTime,
                    @RequestParam(value = "page", required = false) Integer page,
                    @RequestParam(value = "size", required = false) Integer size){
                tracer.getCurrentSpan().logEvent("分页获取设备质检计划失败:原因:" + e.getMessage());
                tracer.getCurrentSpan().logEvent("purcharseId:" + purcharseId);
                tracer.getCurrentSpan().logEvent("orderNo:" + orderNo);
                tracer.getCurrentSpan().logEvent("startTime:" + startTime);
                tracer.getCurrentSpan().logEvent("endTime:" + endTime);
                tracer.getCurrentSpan().logEvent("page:" + page);
                tracer.getCurrentSpan().logEvent("size:" + size);
                return null;

+ 13 - 1
common/common-fegin/src/main/java/com/yihu/jw/fegin/iot/device/IotDeviceOrderFeign.java

@ -8,7 +8,10 @@ import com.yihu.jw.restmodel.iot.device.IotOrderPurchaseVO;
import com.yihu.jw.restmodel.iot.device.IotOrderVO;
import com.yihu.jw.rm.iot.IotRequestMapping;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
/**
 * @author yeshijie on 2018/01/20.
@ -47,4 +50,13 @@ public interface IotDeviceOrderFeign {
    @GetMapping(value = IotRequestMapping.DeviceOrder.findPurcharseById)
    Envelop<IotOrderPurchaseVO>  findPurcharseById(@RequestParam(value = "id", required = true) String id);
    @GetMapping(value = IotRequestMapping.DeviceOrder.findQualityPage)
    Envelop<IotOrderPurchaseVO> findQualityPage(
            @RequestParam(value = "qualityStatus", required = false) String qualityStatus,
            @RequestParam(value = "orderNo", required = false) String orderNo,
            @RequestParam(value = "startTime", required = false) String startTime,
            @RequestParam(value = "endTime", required = false) String endTime,
            @RequestParam(value = "page", required = false) Integer page,
            @RequestParam(value = "size", required = false) Integer size);
}

+ 3 - 0
common/common-fegin/src/main/java/com/yihu/jw/fegin/iot/device/IotDeviceQualityFeign.java

@ -30,6 +30,9 @@ public interface IotDeviceQualityFeign{
    @GetMapping(value = IotRequestMapping.DeviceQuality.queryQualityPlanPage)
    public Envelop<IotDeviceQualityInspectionPlanVO> queryQualityPlanPage(
           @RequestParam(value = "purcharseId", required = false) String purcharseId,
           @RequestParam(value = "orderNo", required = false) String orderNo,
           @RequestParam(value = "startTime", required = false) String startTime,
           @RequestParam(value = "endTime", required = false) String endTime,
           @RequestParam(value = "page", required = false) Integer page,
           @RequestParam(value = "size", required = false) Integer size);

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

@ -191,6 +191,7 @@ public class IotRequestMapping {
        public static final String findPurcharsePage = "findPurcharsePage";
        public static final String findPurcharseById = "findPurcharseById";
        public static final String findQualityPage = "findQualityPage";
        public static final String api_create = "deviceOrder";
        public static final String api_delete = "deviceOrder";

+ 9 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/common/Envelop.java

@ -113,6 +113,15 @@ public class Envelop<T> extends BaseEnvelop implements Serializable {
        return envelop;
    }
    public static Envelop getSuccess(String message, Object obj,Integer total) {
        Envelop envelop = new Envelop();
        envelop.setSuccessMsg(message);
        envelop.setObj(obj);
        envelop.setTotalCount(total);
        envelop.setStatus(200);
        return envelop;
    }
    public static Envelop getSuccessListWithPage(String message, List detailModelList, int page, int size, Long count) {
        Envelop envelop = new Envelop();
        envelop.setSuccessMsg(message);

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

@ -3,11 +3,13 @@ package com.yihu.jw.restmodel.iot.device;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.yihu.jw.restmodel.iot.common.BaseVO;
import com.yihu.jw.restmodel.iot.product.IotProductDataTransmissionVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
 * 设备表
@ -54,12 +56,18 @@ public class IotDeviceVO extends BaseVO implements Serializable {
    @ApiModelProperty("设备状态(1正常、2报废、3检修)")
    private String status;
    @ApiModelProperty("下次质检时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+08:00")
    private Date nextQualityTime;
    @ApiModelProperty("采购id")
    private String purchaseId;
    @ApiModelProperty("sim卡号")
    private String simNo;
    @ApiModelProperty("质检状态")
    private String qualityStatus;
    @ApiModelProperty("数据传输方式")
    private List<IotProductDataTransmissionVO> dataTransmissionVOList;
    @ApiModelProperty("关联居民")
    private List<IotPatientDeviceVO> patientDeviceVOList;
    public String getName() {
        return name;
@ -228,4 +236,28 @@ public class IotDeviceVO extends BaseVO implements Serializable {
    public void setDeviceSourceName(String deviceSourceName) {
        this.deviceSourceName = deviceSourceName;
    }
    public List<IotProductDataTransmissionVO> getDataTransmissionVOList() {
        return dataTransmissionVOList;
    }
    public void setDataTransmissionVOList(List<IotProductDataTransmissionVO> dataTransmissionVOList) {
        this.dataTransmissionVOList = dataTransmissionVOList;
    }
    public String getQualityStatus() {
        return qualityStatus;
    }
    public void setQualityStatus(String qualityStatus) {
        this.qualityStatus = qualityStatus;
    }
    public List<IotPatientDeviceVO> getPatientDeviceVOList() {
        return patientDeviceVOList;
    }
    public void setPatientDeviceVOList(List<IotPatientDeviceVO> patientDeviceVOList) {
        this.patientDeviceVOList = patientDeviceVOList;
    }
}

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

@ -39,6 +39,10 @@ public class IotOrderPurchaseVO extends BaseVO implements Serializable{
    private String nextQualityTime;
    @ApiModelProperty("质检状态")
    private String qualityStatus;
    @ApiModelProperty("质检状态")
    private String qualityStatusName;
    @ApiModelProperty("质检负责人")
    private String qualityLeader;
    @ApiModelProperty("维护单位Id")
    private String maintenanceUnitId;
    @ApiModelProperty("维护单位名称")
@ -167,4 +171,20 @@ public class IotOrderPurchaseVO extends BaseVO implements Serializable{
    public void setProductId(String productId) {
        this.productId = productId;
    }
    public String getQualityStatusName() {
        return qualityStatusName;
    }
    public void setQualityStatusName(String qualityStatusName) {
        this.qualityStatusName = qualityStatusName;
    }
    public String getQualityLeader() {
        return qualityLeader;
    }
    public void setQualityLeader(String qualityLeader) {
        this.qualityLeader = qualityLeader;
    }
}

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

@ -37,6 +37,8 @@ public class IotPatientDeviceVO extends BaseVO implements Serializable {
    private String categoryCode;
    @ApiModelProperty("地址")
    private String address;
    @ApiModelProperty("社区地址")
    private String hospitalName;
    @ApiModelProperty("病情:0绿标,1黄标,2红标")
    private Integer diseaseCondition;
@ -135,4 +137,12 @@ public class IotPatientDeviceVO extends BaseVO implements Serializable {
    public void setDiseaseCondition(Integer diseaseCondition) {
        this.diseaseCondition = diseaseCondition;
    }
    public String getHospitalName() {
        return hospitalName;
    }
    public void setHospitalName(String hospitalName) {
        this.hospitalName = hospitalName;
    }
}

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

@ -78,6 +78,7 @@ public class IotDeviceController extends EnvelopRestController{
        try {
            IotDeviceDO iotDeviceDO = iotDeviceService.findById(id);
            IotDeviceVO iotDeviceVO = convertToModel(iotDeviceDO,IotDeviceVO.class);
            iotDeviceService.translateDictForOne(iotDeviceVO);
            return Envelop.getSuccess(IotRequestMapping.Device.message_success_find, iotDeviceVO);
        } catch (Exception e) {
            e.printStackTrace();

+ 47 - 11
svr/svr-iot/src/main/java/com/yihu/iot/controller/device/IotDeviceOrderController.java

@ -12,6 +12,7 @@ import com.yihu.jw.restmodel.iot.device.IotDeviceOrderVO;
import com.yihu.jw.restmodel.iot.device.IotOrderPurchaseVO;
import com.yihu.jw.restmodel.iot.device.IotOrderVO;
import com.yihu.jw.rm.iot.IotRequestMapping;
import com.yihu.jw.util.date.DateUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@ -40,8 +41,8 @@ public class IotDeviceOrderController extends EnvelopRestController{
                          @RequestParam String jsonData) {
        try {
            IotOrderVO iotOrderVO = toEntity(jsonData, IotOrderVO.class);
            iotDeviceOrderService.create(iotOrderVO);
            return Envelop.getSuccess(IotRequestMapping.DeviceOrder.message_success_create);
            IotDeviceOrderDO deviceOrderDO = iotDeviceOrderService.create(iotOrderVO);
            return Envelop.getSuccess(deviceOrderDO.getOrderNo());
        } catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError(e.getMessage());
@ -57,9 +58,14 @@ public class IotDeviceOrderController extends EnvelopRestController{
            IotDeviceOrderDO iotDeviceOrderDO = iotDeviceOrderService.findById(id);
            IotDeviceOrderVO deviceOrderVO = convertToModel(iotDeviceOrderDO,IotDeviceOrderVO.class);
            //获取企业类型
            List<IotCompanyTypeDO> companyTypeDOList = iotCompanyService.findTypeByCompanyId(deviceOrderVO.getSupplierId());
            List<IotCompanyTypeVO> companyTypeVOList = convertToModels(companyTypeDOList,new ArrayList<>(companyTypeDOList.size()),IotCompanyTypeVO.class);
            deviceOrderVO.setTypeList(companyTypeVOList);
            if(deviceOrderVO!=null){
                List<IotCompanyTypeDO> companyTypeDOList = iotCompanyService.findTypeByCompanyId(deviceOrderVO.getSupplierId());
                List<IotCompanyTypeVO> companyTypeVOList = convertToModels(companyTypeDOList,new ArrayList<>(companyTypeDOList.size()),IotCompanyTypeVO.class);
                deviceOrderVO.setTypeList(companyTypeVOList);
                if(iotDeviceOrderDO.getPurchaseTime()!=null){
                    deviceOrderVO.setPurchaseTime(DateUtil.dateToStrShort(iotDeviceOrderDO.getPurchaseTime()));
                }
            }
            return Envelop.getSuccess(IotRequestMapping.DeviceOrder.message_success_find,deviceOrderVO);
        } catch (Exception e) {
            e.printStackTrace();
@ -124,12 +130,13 @@ public class IotDeviceOrderController extends EnvelopRestController{
    @GetMapping(value = IotRequestMapping.DeviceOrder.findPurcharsePage)
    @ApiOperation(value = "分页查找采购清单", notes = "分页查找采购清单")
    public Envelop<IotOrderPurchaseVO> findPurcharsePage(@ApiParam(name = "orderId", value = "订单id", defaultValue = "")
                                                     @RequestParam(value = "orderId", required = true) String orderId,
                                                         @ApiParam(name = "page", value = "第几页", defaultValue = "")
                                                     @RequestParam(value = "page", required = false) Integer page,
                                                         @ApiParam(name = "size", value = "每页记录数", defaultValue = "")
                                                     @RequestParam(value = "size", required = false) Integer size){
    public Envelop<IotOrderPurchaseVO> findPurcharsePage(
            @ApiParam(name = "orderId", value = "订单id", defaultValue = "")
            @RequestParam(value = "orderId", required = true) String orderId,
            @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;
@ -144,6 +151,35 @@ public class IotDeviceOrderController extends EnvelopRestController{
        }
    }
    @GetMapping(value = IotRequestMapping.DeviceOrder.findQualityPage)
    @ApiOperation(value = "质检管理", notes = "质检管理")
    public Envelop<IotOrderPurchaseVO> findQualityPage(
            @ApiParam(name = "qualityStatus", value = "质检状态", defaultValue = "")
            @RequestParam(value = "qualityStatus", required = false) String qualityStatus,
            @ApiParam(name = "orderNo", value = "订单编号", defaultValue = "")
            @RequestParam(value = "orderNo", required = false) String orderNo,
            @ApiParam(name = "startTime", value = "开始时间", defaultValue = "")
            @RequestParam(value = "startTime", required = false) String startTime,
            @ApiParam(name = "endTime", value = "结束时间", defaultValue = "")
            @RequestParam(value = "endTime", required = false) String endTime,
            @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 iotDeviceOrderService.queryPurcharsePage(page, size, qualityStatus, orderNo, startTime, endTime);
        } catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError(e.getMessage());
        }
    }
    @GetMapping(value = IotRequestMapping.DeviceOrder.findPurcharseById)
    @ApiOperation(value = "根据id查找采购订单", notes = "根据id查找采购订单")
    public Envelop<IotOrderPurchaseVO> findPurcharseById(@ApiParam(name = "id", value = "id")

+ 45 - 29
svr/svr-iot/src/main/java/com/yihu/iot/controller/device/IotDeviceQualityController.java

@ -1,7 +1,6 @@
package com.yihu.iot.controller.device;
import com.yihu.iot.service.device.IotDeviceQualityInspectionPlanService;
import com.yihu.jw.iot.device.IotDeviceDO;
import com.yihu.jw.iot.device.IotDeviceQualityInspectionPlanDO;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.common.EnvelopRestController;
@ -10,13 +9,9 @@ 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.*;
import java.util.ArrayList;
import java.util.List;
/**
 * @author yeshijie on 2017/12/8.
 */
@ -58,12 +53,19 @@ public class IotDeviceQualityController extends EnvelopRestController{
    @GetMapping(value = IotRequestMapping.DeviceQuality.queryQualityPlanPage)
    @ApiOperation(value = "分页获取设备质检计划", notes = "分页获取设备质检计划")
    public Envelop<IotDeviceQualityInspectionPlanVO> findProductPageByCompanyId(@ApiParam(name = "purcharseId", value = "采购id", defaultValue = "")
                                                           @RequestParam(value = "purcharseId", required = false) String purcharseId,
                                                           @ApiParam(name = "page", value = "第几页", defaultValue = "")
                                                           @RequestParam(value = "page", required = false) Integer page,
                                                           @ApiParam(name = "size", value = "每页记录数", defaultValue = "")
                                                           @RequestParam(value = "size", required = false) Integer size){
    public Envelop<IotDeviceQualityInspectionPlanVO> findProductPageByCompanyId(
            @ApiParam(name = "purcharseId", value = "采购id", defaultValue = "")
            @RequestParam(value = "purcharseId", required = false) String purcharseId,
            @ApiParam(name = "orderNo", value = "订单编号", defaultValue = "")
            @RequestParam(value = "orderNo", required = false) String orderNo,
            @ApiParam(name = "startTime", value = "开始时间", defaultValue = "")
            @RequestParam(value = "startTime", required = false) String startTime,
            @ApiParam(name = "endTime", value = "结束时间", defaultValue = "")
            @RequestParam(value = "endTime", required = false) String endTime,
            @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;
@ -71,25 +73,39 @@ public class IotDeviceQualityController extends EnvelopRestController{
            if(size == null){
                size = 10;
            }
            String filters = "";
            String semicolon = "";
            if(StringUtils.isNotBlank(purcharseId)){
                filters += semicolon +"purcharseId="+purcharseId;
                semicolon = ";";
            }
            if(StringUtils.isBlank(filters)){
                filters+= semicolon + "del=1";
            }
            String sorts = "-updateTime";
            //得到list数据
            List<IotDeviceDO> list = iotDeviceQualityInspectionPlanService.search(null, filters, sorts, page, size);
            //获取总数
            long count = iotDeviceQualityInspectionPlanService.getCount(filters);
            //DO转VO
            List<IotDeviceQualityInspectionPlanVO> voList = convertToModels(list,new ArrayList<>(list.size()),IotDeviceQualityInspectionPlanVO.class);
//            String filters = "";
//            String semicolon = "";
//            if(StringUtils.isNotBlank(purcharseId)){
//                filters += semicolon +"purchaseId="+purcharseId;
//                semicolon = ";";
//            }
//            if(StringUtils.isNotBlank(orderNo)){
//                filters += semicolon +"orderNo="+orderNo;
//                semicolon = ";";
//            }
//            if(StringUtils.isNotBlank(startTime)){
//                filters += semicolon +"planTime>="+startTime;
//                semicolon = ";";
//            }
//            if(StringUtils.isNotBlank(endTime)){
//                filters += semicolon +"planTime<="+endTime;
//                semicolon = ";";
//            }
//            if(StringUtils.isBlank(filters)){
//                filters+= semicolon + "del=1";
//            }
//            String sorts = "-updateTime";
//            //得到list数据
//            List<IotDeviceQualityInspectionPlanDO> list = iotDeviceQualityInspectionPlanService.search(null, filters, sorts, page, size);
//            //获取总数
//            long count = iotDeviceQualityInspectionPlanService.getCount(filters);
//
//            //DO转VO
//            List<IotDeviceQualityInspectionPlanVO> voList = convertToModels(list,new ArrayList<>(list.size()),IotDeviceQualityInspectionPlanVO.class);
//
//            return Envelop.getSuccessListWithPage(IotRequestMapping.Common.message_success_find_functions,voList, page, size,count);
            return Envelop.getSuccessListWithPage(IotRequestMapping.Common.message_success_find_functions,voList, page, size,count);
            return iotDeviceQualityInspectionPlanService.queryPage(purcharseId, orderNo, startTime, endTime, page, size);
        } catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError(e.getMessage());

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

@ -201,7 +201,7 @@ public class IotPatientDeviceController extends EnvelopRestController{
                                                                     @RequestParam(value = "jsonData",required = true) String jsonData) {
        try {
            List<LocationDataVO> list = iotPatientDeviceService.findDeviceLocationsByIdCard(jsonData);
            return Envelop.getSuccess(IotRequestMapping.Device.message_success_create,list);
            return Envelop.getSuccess(IotRequestMapping.Device.message_success_create,list,iotPatientDeviceService.getESCount(jsonData));
        } catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError(e.getMessage());

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

@ -5,6 +5,8 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * @author yeshijie on 2017/12/1.
 */
@ -14,6 +16,12 @@ public interface IotDeviceQualityInspectionPlanDao extends PagingAndSortingRepos
    @Query("from IotDeviceQualityInspectionPlanDO w where w.id =?1")
    IotDeviceQualityInspectionPlanDO findById(String id);
    @Query("from IotDeviceQualityInspectionPlanDO w where w.purchaseId =?1 and w.status=?2 and w.del=1")
    List<IotDeviceQualityInspectionPlanDO> findListByPurchaseId(String purchaseId,String qualityStatus);
    @Query("from IotDeviceQualityInspectionPlanDO w where w.deviceId =?1")
    IotDeviceQualityInspectionPlanDO findByDeviceId(String deviceId);
    @Query(value = "SELECT a.* from iot_device_quality_inspection_plan a WHERE a.purchase_id = ?1 and a.del=1 ORDER BY a.status asc,a.plan_time desc limit 1",nativeQuery = true)
    IotDeviceQualityInspectionPlanDO findLastByPurchaseId(String purchaseId);
}

+ 112 - 21
svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotDeviceOrderService.java

@ -6,9 +6,9 @@ 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.service.dict.IotSystemDictService;
import com.yihu.jw.iot.company.IotCompanyTypeDO;
import com.yihu.jw.iot.device.IotDeviceOrderDO;
import com.yihu.jw.iot.device.IotDeviceQualityInspectionPlanDO;
import com.yihu.jw.iot.device.IotOrderPurchaseDO;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.iot.company.IotCompanyTypeVO;
@ -18,16 +18,14 @@ import com.yihu.jw.restmodel.iot.device.IotOrderVO;
import com.yihu.jw.rm.iot.IotRequestMapping;
import com.yihu.jw.util.date.DateUtil;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
 * @author yeshijie on 2017/12/8.
@ -47,6 +45,8 @@ public class IotDeviceOrderService extends BaseJpaService<IotDeviceOrderDO,IotDe
    private IotDeviceDao iotDeviceDao;
    @Autowired
    private IotDeviceQualityInspectionPlanDao iotDeviceQualityInspectionPlanDao;
    @Autowired
    private IotSystemDictService iotSystemDictService;
    /**
     * 查找采购清单
@ -57,6 +57,7 @@ public class IotDeviceOrderService extends BaseJpaService<IotDeviceOrderDO,IotDe
        return iotOrderPurchaseDao.findById(id);
    }
    /**
     * 新增
     * @param iotOrderVO
@ -74,12 +75,13 @@ public class IotDeviceOrderService extends BaseJpaService<IotDeviceOrderDO,IotDe
        String time = DateUtil.dateToStr(new Date(),DateUtil.YYYYMMDD);
        List<IotDeviceOrderDO> doList = iotDeviceOrderDao.findByYmd(time);
        String orderNo = String.format("%05d",doList.size());
        String orderNo = time + String.format("%05d",doList.size());
        iotDeviceOrderDO.setOrderNo(orderNo);
        iotDeviceOrderDO.setOrderStatus(IotDeviceOrderDO.DeviceOrderStatus.create.getValue());
        iotDeviceOrderDO.setSaasId(getCode());
        iotDeviceOrderDO.setDel(1);
        iotDeviceOrderDO.setYmd(time);
        iotDeviceOrderDO.setPurchaseTime(DateUtil.strToDate(iotDeviceOrderVO.getPurchaseTime()));
        iotDeviceOrderDao.save(iotDeviceOrderDO);
        String orderId = iotDeviceOrderDO.getId();
        //采购清单
@ -90,6 +92,23 @@ public class IotDeviceOrderService extends BaseJpaService<IotDeviceOrderDO,IotDe
            purchase.setSaasId(getCode());
        });
        iotOrderPurchaseDao.save(orderPurchaseDOList);
        //质检计划
//        List<IotDeviceQualityInspectionPlanDO> planDOList = new ArrayList<>();
//        orderPurchaseDOList.forEach(purchase->{
//            //质检计划
//            IotDeviceQualityInspectionPlanDO planDO = new IotDeviceQualityInspectionPlanDO();
//            planDO.setPurchaseNum(purchase.getPurchaseNum());
//            planDO.setOrderNo(orderNo);
//            planDO.setOrderId(orderId);
//            planDO.setSaasId(getCode());
//            planDO.setStatus(IotDeviceQualityInspectionPlanDO.QualityPlanStatus.create.getValue());
//            planDO.setDeviceName(purchase.getDeviceName());
//            planDO.setPurchaseId(purchase.getId());
////            planDO.set
//
//            planDOList.add(planDO);
//        });
//        iotDeviceQualityInspectionPlanDao.save(planDOList);
        return iotDeviceOrderDO;
    }
@ -143,6 +162,24 @@ public class IotDeviceOrderService extends BaseJpaService<IotDeviceOrderDO,IotDe
        iotOrderPurchaseDao.save(orderPurchaseDOList);
    }
    /**
     * 转换
     * @param sources
     * @param targets
     * @return
     */
    public List<IotDeviceOrderVO> convertToModelVOs(List<IotDeviceOrderDO> sources, List<IotDeviceOrderVO> targets){
        sources.forEach(one -> {
            IotDeviceOrderVO target = new IotDeviceOrderVO();
            BeanUtils.copyProperties(one, target);
            if(one.getPurchaseTime()!=null){
                target.setPurchaseTime(DateUtil.dateToStrShort(one.getPurchaseTime()));
            }
            targets.add(target);
        });
        return targets;
    }
    /**
     * 分页查找
     * @param page
@ -169,7 +206,8 @@ public class IotDeviceOrderService extends BaseJpaService<IotDeviceOrderDO,IotDe
        long count = getCount(filters);
        //DO转VO
        List<IotDeviceOrderVO> iotDeviceOrderVOList = convertToModels(list,new ArrayList<>(list.size()),IotDeviceOrderVO.class);
        List<IotDeviceOrderVO> iotDeviceOrderVOList = new ArrayList<>();
        convertToModelVOs(list,iotDeviceOrderVOList);
        iotDeviceOrderVOList.forEach(one->{
            findType(one);
        });
@ -209,14 +247,12 @@ public class IotDeviceOrderService extends BaseJpaService<IotDeviceOrderDO,IotDe
        StringBuffer sqlCount = new StringBuffer("SELECT COUNT(DISTINCT c.id) count from iot_device_order c ,iot_company_type t WHERE c.del=1 ");
        List<Object> args = new ArrayList<>();
        if(StringUtils.isNotBlank(name)){
            sql.append(" and (c.supplier_name like ? or c.purchaser_name like ?)");
            sqlCount.append(" and (c.supplier_name like '").append(name).append("' or c.purchaser_name like '").append(name).append("')");
            args.add(name);
            args.add(name);
            sql.append(" and (c.supplier_name like '%").append(name).append("%' or c.purchaser_name like '%").append(name).append("%')");
            sqlCount.append(" and (c.supplier_name like '%").append(name).append("%' or c.purchaser_name like '%").append(name).append("%')");
        }
        if(StringUtils.isNotBlank(type)){
            sql.append(" and t.type=? ");
            sqlCount.append(" and t.type='").append(type).append("' ");
            sql.append(" and c.supplier_id=t.company_id and t.type=? ");
            sqlCount.append(" and c.supplier_id=t.company_id and t.type='").append(type).append("' ");
            args.add(type);
        }
        sql.append("order by c.update_time desc limit ").append((page-1)*size).append(",").append(size);
@ -226,7 +262,8 @@ public class IotDeviceOrderService extends BaseJpaService<IotDeviceOrderDO,IotDe
        long count = Long.valueOf(countList.get(0).get("count").toString());
        //DO转VO
        List<IotDeviceOrderVO> iotDeviceOrderVOList = convertToModels(list,new ArrayList<>(list.size()),IotDeviceOrderVO.class);
        List<IotDeviceOrderVO> iotDeviceOrderVOList = new ArrayList<>();
        convertToModelVOs(list,iotDeviceOrderVOList);
        iotDeviceOrderVOList.forEach(one->{
            findType(one);
        });
@ -263,20 +300,74 @@ public class IotDeviceOrderService extends BaseJpaService<IotDeviceOrderDO,IotDe
        iotOrderPurchaseVOList.forEach(purchase->{
            //计算已关联设备数量
            if("1".equals(type)){
                Integer num = iotDeviceDao.countByPurchaseId(purchase.getId());
                Long unNum = (purchase.getPurchaseNum()-num)>0? (purchase.getPurchaseNum()-num):0;
                purchase.setAssociatedNum(Long.valueOf(num));
                purchase.setUnAssociatedNum(unNum);
            }
            //获取质检信息
            IotDeviceQualityInspectionPlanDO planDO = iotDeviceQualityInspectionPlanDao.findLastByPurchaseId(purchase.getId());
            if(planDO!=null){
                purchase.setQualityStatus(planDO.getStatus());//质检状态
                purchase.setNextQualityTime(DateUtil.dateToStrLong(planDO.getPlanTime()));//下次质检时间
            }
        });
        translateForList(iotOrderPurchaseVOList);
        return Envelop.getSuccessListWithPage(IotRequestMapping.Common.message_success_find_functions,iotOrderPurchaseVOList, page, size,count);
    }
    /**
     * 字典翻译
     * @param iotOrderPurchaseVOList
     */
    public void translateForList(List<IotOrderPurchaseVO> iotOrderPurchaseVOList){
        if(iotOrderPurchaseVOList!=null&&iotOrderPurchaseVOList.size()>0){
            Map<String,String> qualityStatusMap = iotSystemDictService.findByDictName("QUALITY_STATUS");
            iotOrderPurchaseVOList.forEach(one->{
                if(StringUtils.isNotBlank(one.getQualityStatus())){
                    one.setQualityStatusName(qualityStatusMap.get(one.getQualityStatus()));
                }
            });
        }
    }
    /**
     * 按类型分页查找
     * @param page
     * @param size
     * @return
     */
    public Envelop<IotOrderPurchaseVO> queryPurcharsePage(Integer page, Integer size,
              String qualityStatus,String orderNo,String startTime,String endTime){
        StringBuffer sql = new StringBuffer("SELECT c.* from iot_order_purchase c  WHERE c.del=1 ");
        StringBuffer sqlCount = new StringBuffer("SELECT COUNT(c.id) count from iot_order_purchase c WHERE c.del=1 ");
        List<Object> args = new ArrayList<>();
        if(StringUtils.isNotBlank(qualityStatus)){
            sql.append(" and c.quality_status=? ");
            sqlCount.append(" and c.quality_status='").append(qualityStatus).append("' ");
            args.add(qualityStatus);
        }
        if(StringUtils.isNotBlank(orderNo)){
            sql.append(" and c.order_no like '%").append(orderNo).append("%' ");
            sqlCount.append(" and c.order_no like '%").append(orderNo).append("%' ");
        }
        if(StringUtils.isNotBlank(startTime)){
            sql.append(" and c.next_quality_time>=? ");
            sqlCount.append(" and c.next_quality_time>='").append(startTime).append("' ");
            args.add(startTime);
        }
        if(StringUtils.isNotBlank(endTime)){
            sql.append(" and c.next_quality_time<=? ");
            sqlCount.append(" and c.next_quality_time<='").append(endTime).append("' ");
            args.add(endTime);
        }
        sql.append("order by c.update_time desc limit ").append((page-1)*size).append(",").append(size);
        List<IotOrderPurchaseDO> list = jdbcTempalte.query(sql.toString(),args.toArray(),new BeanPropertyRowMapper(IotOrderPurchaseDO.class));
        List<Map<String,Object>> countList = jdbcTempalte.queryForList(sqlCount.toString());
        long count = Long.valueOf(countList.get(0).get("count").toString());
        //DO转VO
        List<IotOrderPurchaseVO> iotOrderPurchaseVOList = convertToModels(list,new ArrayList<>(list.size()),IotOrderPurchaseVO.class);
        translateForList(iotOrderPurchaseVOList);
        return Envelop.getSuccessListWithPage(IotRequestMapping.Common.message_success_find_functions,iotOrderPurchaseVOList, page, size,count);
    }
}

+ 77 - 0
svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotDeviceQualityInspectionPlanService.java

@ -6,10 +6,20 @@ import com.yihu.iot.dao.device.IotDeviceQualityInspectionPlanDao;
import com.yihu.iot.dao.device.IotOrderPurchaseDao;
import com.yihu.jw.iot.device.IotDeviceQualityInspectionPlanDO;
import com.yihu.jw.iot.device.IotOrderPurchaseDO;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.iot.device.IotDeviceQualityInspectionPlanVO;
import com.yihu.jw.rm.iot.IotRequestMapping;
import com.yihu.jw.util.date.DateUtil;
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 java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
 * @author yeshijie on 2017/12/8.
 */
@ -26,6 +36,8 @@ public class IotDeviceQualityInspectionPlanService extends BaseJpaService<IotDev
    private IotDeviceOrderService iotDeviceOrderService;
    @Autowired
    private IotDeviceOrderDao iotDeviceOrderDao;
    @Autowired
    private JdbcTemplate jdbcTempalte;
    /**
     * 新增
@ -44,6 +56,15 @@ public class IotDeviceQualityInspectionPlanService extends BaseJpaService<IotDev
        iotDeviceQualityInspectionPlan.setSaasId(getCode());
        iotDeviceQualityInspectionPlan.setStatus(IotDeviceQualityInspectionPlanDO.QualityPlanStatus.create.getValue());
        iotDeviceQualityInspectionPlan.setDel(1);
        //更新采购清单的质检信息
        if(StringUtils.isNotBlank(purchaseDO.getQualityStatus())
                ||(iotDeviceQualityInspectionPlan.getPlanTime().getTime()-purchaseDO.getNextQualityTime().getTime())<0){
            purchaseDO.setQualityStatus(IotDeviceQualityInspectionPlanDO.QualityPlanStatus.create.getValue());
            purchaseDO.setNextQualityTime(iotDeviceQualityInspectionPlan.getPlanTime());
            purchaseDO.setQualityLeader(iotDeviceQualityInspectionPlan.getQualityLeader());
            iotOrderPurchaseDao.save(purchaseDO);
        }
        return iotDeviceQualityInspectionPlanDao.save(iotDeviceQualityInspectionPlan);
    }
@ -74,6 +95,62 @@ public class IotDeviceQualityInspectionPlanService extends BaseJpaService<IotDev
        IotDeviceQualityInspectionPlanDO planDO = iotDeviceQualityInspectionPlanDao.findById(id);
        planDO.setStatus(IotDeviceQualityInspectionPlanDO.QualityPlanStatus.complete.getValue());
        planDO.setActualTime(DateUtil.strToDate(time));
        //更新采购清单的质检信息
        List<IotDeviceQualityInspectionPlanDO> list = iotDeviceQualityInspectionPlanDao.
                findListByPurchaseId(planDO.getPurchaseId(),IotDeviceQualityInspectionPlanDO.QualityPlanStatus.create.getValue());
        if(list==null||list.size()==0){
            IotDeviceQualityInspectionPlanDO last = iotDeviceQualityInspectionPlanDao.findLastByPurchaseId(planDO.getPurchaseId());
            IotOrderPurchaseDO purchaseDO = iotOrderPurchaseDao.findById(planDO.getPurchaseId());
            purchaseDO.setQualityStatus(IotDeviceQualityInspectionPlanDO.QualityPlanStatus.complete.getValue());
            purchaseDO.setNextQualityTime(last.getPlanTime());
            purchaseDO.setQualityLeader(last.getQualityLeader());
            iotOrderPurchaseDao.save(purchaseDO);
        }
        iotDeviceQualityInspectionPlanDao.save(planDO);
    }
    /**
     * 分页查找
     * @param page
     * @param size
     * @param purcharseId
     * @return
     */
    public Envelop<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 ");
        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(orderNo)){
            sql.append(" and c.order_no=? ");
            sqlCount.append(" and c.order_no='").append(orderNo).append("' ");
            args.add(orderNo);
        }
        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);
        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());
        //DO转VO
        List<IotDeviceQualityInspectionPlanVO> qualityInspectionPlanVOList = convertToModels(list,new ArrayList<>(list.size()),IotDeviceQualityInspectionPlanVO.class);
        return Envelop.getSuccessListWithPage(IotRequestMapping.Common.message_success_find_functions,qualityInspectionPlanVOList, page, size,count);
    }
}

+ 52 - 0
svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotDeviceService.java

@ -3,13 +3,17 @@ package com.yihu.iot.service.device;
import com.yihu.base.fastdfs.FastDFSHelper;
import com.yihu.base.mysql.query.BaseJpaService;
import com.yihu.iot.dao.device.*;
import com.yihu.iot.dao.product.IotProductDataTransmissionDao;
import com.yihu.iot.service.dict.IotSystemDictService;
import com.yihu.jw.iot.device.*;
import com.yihu.jw.iot.product.IotProductDataTransmissionDO;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.common.base.BaseEnvelop;
import com.yihu.jw.restmodel.iot.device.IotDeviceImportRecordVO;
import com.yihu.jw.restmodel.iot.device.IotDeviceImportVO;
import com.yihu.jw.restmodel.iot.device.IotDeviceVO;
import com.yihu.jw.restmodel.iot.device.IotPatientDeviceVO;
import com.yihu.jw.restmodel.iot.product.IotProductDataTransmissionVO;
import com.yihu.jw.rm.iot.IotRequestMapping;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -49,6 +53,8 @@ public class IotDeviceService extends BaseJpaService<IotDeviceDO,IotDeviceDao> {
    private IotDeviceQualityInspectionPlanDao iotDeviceQualityInspectionPlanDao;
    @Autowired
    private IotSystemDictService iotSystemDictService;
    @Autowired
    private IotProductDataTransmissionDao iotProductDataTransmissionDao;
    /**
     * 新增
@ -329,4 +335,50 @@ public class IotDeviceService extends BaseJpaService<IotDeviceDO,IotDeviceDao> {
            });
        }
    }
    /**
     * 字典翻译
     * @param iotDeviceVO
     */
    public void translateDictForOne(IotDeviceVO iotDeviceVO){
        if(iotDeviceVO!=null){
            //字典翻译
            Map<String,String> deviceBindingMap = iotSystemDictService.findByDictName("DEVICE_BINDING");
            Map<String,String> deviceSourceMap = iotSystemDictService.findByDictName("DEVICE_SOURCE");
            Map<String,String> qualityStatusMap = iotSystemDictService.findByDictName("QUALITY_STATUS");
            List<IotPatientDeviceDO>  deviceDOList = iotPatientDeviceDao.findByDeviceSn(iotDeviceVO.getDeviceSn());
            if(deviceDOList!=null&&deviceDOList.size()>0){
                iotDeviceVO.setIsBinding(1);
            }else {
                iotDeviceVO.setIsBinding(2);
            }
            iotDeviceVO.setIsBindingName(deviceBindingMap.get(iotDeviceVO.getIsBinding().toString()));
            if(StringUtils.isNotBlank(iotDeviceVO.getDeviceSource())){
                iotDeviceVO.setDeviceSourceName(deviceSourceMap.get(iotDeviceVO.getDeviceSource()));
            }
            //获取质检信息
            IotDeviceQualityInspectionPlanDO planDO = iotDeviceQualityInspectionPlanDao.findByDeviceId(iotDeviceVO.getId());
            if(planDO!=null){
                iotDeviceVO.setQualityStatus(qualityStatusMap.get(planDO.getStatus()));//质检状态
            }
            //数据来源
            if(StringUtils.isNotBlank(iotDeviceVO.getPurchaseId())){
                List<IotProductDataTransmissionDO> dataTransmissionDOList = iotProductDataTransmissionDao.findByProductId(iotDeviceVO.getProductId());
                if(dataTransmissionDOList!=null){
                    List<IotProductDataTransmissionVO> dataTransmissionVOList =
                            convertToModels(dataTransmissionDOList,new ArrayList<>(dataTransmissionDOList.size()),IotProductDataTransmissionVO.class);
                    iotDeviceVO.setDataTransmissionVOList(dataTransmissionVOList);
                }
            }
            //关联居民
            List<IotPatientDeviceDO> patientDeviceDOList = iotPatientDeviceDao.findByDeviceSn(iotDeviceVO.getDeviceSn());
            if(patientDeviceDOList!=null){
                List<IotPatientDeviceVO> patientDeviceVOList =
                        convertToModels(patientDeviceDOList,new ArrayList<>(patientDeviceDOList.size()),IotPatientDeviceVO.class);
                iotDeviceVO.setPatientDeviceVOList(patientDeviceVOList);
            }
        }
    }
}

+ 12 - 3
svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotPatientDeviceService.java

@ -22,8 +22,10 @@ import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import javax.naming.directory.SearchResult;
import java.util.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * @author yeshijie on 2018/1/16.
@ -75,7 +77,14 @@ public class IotPatientDeviceService extends BaseJpaService<IotPatientDeviceDO,I
            Map<String, String> json = LatitudeUtils.getGeocoderLatitude(deviceVO.getAddress().replace("G.", "").replace("(糖友网)", "").replace("(高友网)", ""));
            if (json == null) {
                return;
                if(!StringUtils.isEmpty(deviceVO.getHospitalName())){
                    json = LatitudeUtils.getGeocoderLatitude(deviceVO.getHospitalName().replace("G.", "").replace("(糖友网)", "").replace("(高友网)", ""));
                    if(json==null){
                        return;
                    }
                }else {
                    return;
                }
            }
            logger.info("地址:," + deviceVO.getAddress() + "坐标" + json.toString());
            dataDTO.setLocation(Double.valueOf(json.get("lat")), Double.valueOf(json.get("lng")));

+ 18 - 0
web-gateway/src/main/java/com/yihu/jw/controller/iot/device/IotDeviceOrderController.java

@ -84,4 +84,22 @@ public class IotDeviceOrderController extends EnvelopRestController{
    ) {
        return iotDeviceOrderFeign.findPurcharseById(id);
    }
    @GetMapping(value = IotRequestMapping.DeviceOrder.findQualityPage)
    @ApiOperation(value = "质检管理", notes = "质检管理")
    public Envelop<IotOrderPurchaseVO> findQualityPage(
            @ApiParam(name = "qualityStatus", value = "质检状态", defaultValue = "")
            @RequestParam(value = "qualityStatus", required = false) String qualityStatus,
            @ApiParam(name = "orderNo", value = "订单编号", defaultValue = "")
            @RequestParam(value = "orderNo", required = false) String orderNo,
            @ApiParam(name = "startTime", value = "开始时间", defaultValue = "")
            @RequestParam(value = "startTime", required = false) String startTime,
            @ApiParam(name = "endTime", value = "结束时间", defaultValue = "")
            @RequestParam(value = "endTime", required = false) String endTime,
            @ApiParam(name = "page", value = "第几页", defaultValue = "")
            @RequestParam(value = "page", required = false) Integer page,
            @ApiParam(name = "size", value = "每页记录数", defaultValue = "")
            @RequestParam(value = "size", required = false) Integer size){
        return iotDeviceOrderFeign.findQualityPage(qualityStatus, orderNo, startTime, endTime, page, size);
    }
}

+ 14 - 7
web-gateway/src/main/java/com/yihu/jw/controller/iot/device/IotDeviceQualityController.java

@ -40,13 +40,20 @@ public class IotDeviceQualityController extends EnvelopRestController{
    @GetMapping(value = IotRequestMapping.DeviceQuality.queryQualityPlanPage)
    @ApiOperation(value = "分页获取设备质检计划", notes = "分页获取设备质检计划")
    public Envelop<IotDeviceQualityInspectionPlanVO> queryQualityPlanPage(@ApiParam(name = "purcharseId", value = "采购id", defaultValue = "")
                                                           @RequestParam(value = "purcharseId", required = false) String purcharseId,
                                                           @ApiParam(name = "page", value = "第几页", defaultValue = "")
                                                           @RequestParam(value = "page", required = false) Integer page,
                                                           @ApiParam(name = "size", value = "每页记录数", defaultValue = "")
                                                           @RequestParam(value = "size", required = false) Integer size){
        return iotDeviceQualityFeign.queryQualityPlanPage(purcharseId,page,size);
    public Envelop<IotDeviceQualityInspectionPlanVO> queryQualityPlanPage(
            @ApiParam(name = "purcharseId", value = "采购id", defaultValue = "")
            @RequestParam(value = "purcharseId", required = false) String purcharseId,
            @ApiParam(name = "orderNo", value = "订单编号", defaultValue = "")
            @RequestParam(value = "orderNo", required = false) String orderNo,
            @ApiParam(name = "startTime", value = "开始时间", defaultValue = "")
            @RequestParam(value = "startTime", required = false) String startTime,
            @ApiParam(name = "endTime", value = "结束时间", defaultValue = "")
            @RequestParam(value = "endTime", required = false) String endTime,
            @ApiParam(name = "page", value = "第几页", defaultValue = "")
            @RequestParam(value = "page", required = false) Integer page,
            @ApiParam(name = "size", value = "每页记录数", defaultValue = "")
            @RequestParam(value = "size", required = false) Integer size){
        return iotDeviceQualityFeign.queryQualityPlanPage(purcharseId, orderNo, startTime, endTime, page, size);
    }
    @PostMapping(value = IotRequestMapping.DeviceQuality.delQualityPlan)