Browse Source

Merge branch 'dev' of http://192.168.1.220:10080/jiwei/jw2.0 into dev

Conflicts:
	svr/svr-iot/src/main/resources/application.yml
yeshijie 7 years ago
parent
commit
eaeea19edf
26 changed files with 306 additions and 76 deletions
  1. 1 0
      app/app-iot-server/src/main/java/com/yihu/ehr/iot/constant/ServiceApi.java
  2. 6 4
      app/app-iot-server/src/main/java/com/yihu/ehr/iot/controller/device/IotDeviceController.java
  3. 13 0
      app/app-iot-server/src/main/java/com/yihu/ehr/iot/controller/device/IotDeviceOrderController.java
  4. 1 1
      app/app-iot-server/src/main/java/com/yihu/ehr/iot/controller/device/IotDeviceQualityController.java
  5. 13 0
      app/app-iot-server/src/main/java/com/yihu/ehr/iot/service/device/DeviceOrderService.java
  6. 3 1
      app/app-iot-server/src/main/java/com/yihu/ehr/iot/service/device/DeviceService.java
  7. 1 0
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/iot/IotRequestMapping.java
  8. 10 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/iot/device/IotDeviceVO.java
  9. 7 32
      svr/svr-iot/src/main/java/com/yihu/iot/controller/device/IotDeviceController.java
  10. 17 0
      svr/svr-iot/src/main/java/com/yihu/iot/controller/device/IotDeviceOrderController.java
  11. 1 1
      svr/svr-iot/src/main/java/com/yihu/iot/controller/device/IotDeviceQualityController.java
  12. 4 4
      svr/svr-iot/src/main/java/com/yihu/iot/controller/device/IotPatientDeviceController.java
  13. 3 19
      svr/svr-iot/src/main/java/com/yihu/iot/controller/product/IotProductController.java
  14. 3 0
      svr/svr-iot/src/main/java/com/yihu/iot/dao/device/IotPatientDeviceDao.java
  15. 9 0
      svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotDeviceOrderService.java
  16. 134 6
      svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotDeviceService.java
  17. 52 0
      svr/svr-iot/src/main/java/com/yihu/iot/service/product/IotProductBaseInfoService.java
  18. 4 2
      web-gateway/src/main/java/com/yihu/jw/controller/iot/device/IotDeviceController.java
  19. 7 0
      web-gateway/src/main/java/com/yihu/jw/controller/iot/device/IotDeviceOrderController.java
  20. 1 1
      web-gateway/src/main/java/com/yihu/jw/controller/iot/device/IotDeviceQualityController.java
  21. 3 1
      web-gateway/src/main/java/com/yihu/jw/feign/fallbackfactory/iot/device/IotDeviceFallbackFactory.java
  22. 6 0
      web-gateway/src/main/java/com/yihu/jw/feign/fallbackfactory/iot/device/IotDeviceOrderFallbackFactory.java
  23. 1 2
      web-gateway/src/main/java/com/yihu/jw/feign/fallbackfactory/iot/device/IotDeviceQualityFallbackFactory.java
  24. 3 1
      web-gateway/src/main/java/com/yihu/jw/feign/iot/device/IotDeviceFeign.java
  25. 2 0
      web-gateway/src/main/java/com/yihu/jw/feign/iot/device/IotDeviceOrderFeign.java
  26. 1 1
      web-gateway/src/main/java/com/yihu/jw/feign/iot/device/IotDeviceQualityFeign.java

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

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

+ 6 - 4
app/app-iot-server/src/main/java/com/yihu/ehr/iot/controller/device/IotDeviceController.java

@ -12,7 +12,6 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@ -27,7 +26,7 @@ public class IotDeviceController extends BaseController{
    @Autowired
    private DeviceService deviceService;
    @PostMapping(value = IotRequestMapping.Device.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @PostMapping(value = IotRequestMapping.Device.api_create)
    @ApiOperation(value = "创建设备", notes = "创建设备")
    public Envelop<IotDeviceVO> create(@ApiParam(name = "json_data", value = "", defaultValue = "")
                          @RequestParam String jsonData) {
@ -99,7 +98,9 @@ public class IotDeviceController extends BaseController{
                                                           @ApiParam(name = "orderId", value = "订单id", defaultValue = "")
                                                           @RequestParam(value = "orderId", required = false) String orderId,
                                                           @ApiParam(name = "purcharseId", value = "采购id", defaultValue = "")
                                                           @RequestParam(value = "purcharseId", required = true) String purcharseId,
                                                           @RequestParam(value = "purcharseId", required = false) String purcharseId,
                                                           @ApiParam(name = "isBinding", value = "是否绑定(1已绑定,2未绑定)", defaultValue = "")
                                                           @RequestParam(value = "isBinding", required = false) Integer isBinding,
                                                           @ApiParam(name = "page", value = "第几页", defaultValue = "")
                                                           @RequestParam(value = "page", required = false) Integer page,
                                                           @ApiParam(name = "size", value = "每页记录数", defaultValue = "")
@ -111,7 +112,7 @@ public class IotDeviceController extends BaseController{
            if(size == null){
                size = 10;
            }
            return deviceService.findProductPageByCompanyId(sn,hospital,orderId,purcharseId,page,size);
            return deviceService.findProductPageByCompanyId(sn,hospital,orderId,purcharseId,isBinding,page,size);
        } catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError(e.getMessage());
@ -166,4 +167,5 @@ public class IotDeviceController extends BaseController{
            return Envelop.getError(e.getMessage());
        }
    }
}

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

@ -117,4 +117,17 @@ public class IotDeviceOrderController extends BaseController {
        }
    }
    @GetMapping(value = IotRequestMapping.DeviceOrder.findPurcharseById)
    @ApiOperation(value = "根据id查找采购订单", notes = "根据id查找采购订单")
    public Envelop<IotOrderPurchaseVO>  findPurcharseById(
            @ApiParam(name = "id", value = "id")
            @RequestParam(value = "id", required = true) String id) {
        try {
            return deviceOrderService.findPurcharseById(id);
        } catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError(e.getMessage());
        }
    }
}

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

@ -50,7 +50,7 @@ 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 = true) String purcharseId,
                                                           @RequestParam(value = "purcharseId", required = false) String purcharseId,
                                                           @ApiParam(name = "page", value = "第几页", defaultValue = "")
                                                           @RequestParam(value = "page", required = false) Integer page,
                                                           @ApiParam(name = "size", value = "每页记录数", defaultValue = "")

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

@ -114,4 +114,17 @@ public class DeviceOrderService extends BaseService{
        return envelop;
    }
    /**
     * 根据id查找采购订单
     * @param id
     * @return
     */
    public Envelop<IotOrderPurchaseVO> findPurcharseById(String id) throws IOException {
        Map<String, Object> params = new HashMap<>();
        params.put("id", id);
        HttpResponse response = HttpHelper.get(iotUrl + ServiceApi.DeviceOrder.FindPurcharseById, params);
        Envelop<IotOrderPurchaseVO> envelop = objectMapper.readValue(response.getBody(),Envelop.class);
        return envelop;
    }
}

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

@ -124,12 +124,13 @@ public class DeviceService extends BaseService{
     * @throws IOException
     */
    public Envelop<IotDeviceVO> findProductPageByCompanyId(String sn,String hospital,String orderId,
                String purcharseId,Integer page,Integer size) throws IOException{
                String purcharseId,Integer isBinding,Integer page,Integer size) throws IOException{
        Map<String, Object> params = new HashMap<>();
        params.put("sn", sn);
        params.put("hospital", hospital);
        params.put("orderId", orderId);
        params.put("purcharseId", purcharseId);
        params.put("isBinding", isBinding);
        params.put("page", page);
        params.put("size", size);
        HttpResponse response = HttpHelper.get(iotUrl + ServiceApi.Device.QueryDevicePage, params);
@ -224,4 +225,5 @@ public class DeviceService extends BaseService{
        Envelop<IotDeviceImportRecordVO> envelop = objectMapper.readValue(response.getBody(),Envelop.class);
        return envelop;
    }
}

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

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

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

@ -25,6 +25,8 @@ public class IotDeviceVO extends BaseVO implements Serializable {
    private String deviceSn;
    @ApiModelProperty("是否复合型(1是,0否即设备为单一功能)")
    private Integer isComposite;
    @ApiModelProperty("是否绑定(1已绑定,2未绑定)")
    private Integer isBinding;
    @ApiModelProperty("是否平台型(1是,0否)")
    private Integer isPlatform;
    @ApiModelProperty("设备来源(1采购订单关联,2居民绑定,3管理员新增)")
@ -198,4 +200,12 @@ public class IotDeviceVO extends BaseVO implements Serializable {
    public void setHospitalName(String hospitalName) {
        this.hospitalName = hospitalName;
    }
    public Integer getIsBinding() {
        return isBinding;
    }
    public void setIsBinding(Integer isBinding) {
        this.isBinding = isBinding;
    }
}

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

@ -26,7 +26,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
/**
@ -139,7 +138,9 @@ public class IotDeviceController extends EnvelopRestController{
                                                           @ApiParam(name = "orderId", value = "订单id", defaultValue = "")
                                                           @RequestParam(value = "orderId", required = false) String orderId,
                                                           @ApiParam(name = "purcharseId", value = "采购id", defaultValue = "")
                                                           @RequestParam(value = "purcharseId", required = true) String purcharseId,
                                                           @RequestParam(value = "purcharseId", required = false) String purcharseId,
                                                           @ApiParam(name = "isBinding", value = "是否绑定(1已绑定,2未绑定)", defaultValue = "")
                                                           @RequestParam(value = "isBinding", required = false) Integer isBinding,
                                                           @ApiParam(name = "page", value = "第几页", defaultValue = "")
                                                           @RequestParam(value = "page", required = false) Integer page,
                                                           @ApiParam(name = "size", value = "每页记录数", defaultValue = "")
@ -151,37 +152,11 @@ public class IotDeviceController extends EnvelopRestController{
            if(size == null){
                size = 10;
            }
            String filters = "";
            String semicolon = "";
            if(StringUtils.isNotBlank(orderId)){
                filters += semicolon +"orderId="+orderId;
                semicolon = ";";
            }
            if(StringUtils.isNotBlank(purcharseId)){
                filters += semicolon +"purcharseId="+purcharseId;
                semicolon = ";";
            }
            if(StringUtils.isNotBlank(hospital)){
                filters += semicolon +"hospital="+hospital;
                semicolon = ";";
            }
            if(StringUtils.isNotBlank(sn)){
                filters = "deviceSn?"+sn+" g1;simNo?"+sn+" g1";
                semicolon = ";";
            if(isBinding==null){
                return iotDeviceService.queryPage(sn, hospital, orderId, purcharseId, page, size);
            }else {
                return iotDeviceService.queryPage(sn, hospital, orderId, purcharseId, isBinding, page, size);
            }
            if(StringUtils.isBlank(filters)){
                filters+= semicolon + "del=1";
            }
            String sorts = "-updateTime";
            //得到list数据
            List<IotDeviceDO> list = iotDeviceService.search(null, filters, sorts, page, size);
            //获取总数
            long count = iotDeviceService.getCount(filters);
            //DO转VO
            List<IotDeviceVO> iotDeviceVOList = convertToModels(list,new ArrayList<>(list.size()),IotDeviceVO.class);
            return Envelop.getSuccessListWithPage(IotRequestMapping.Company.message_success_find_functions,iotDeviceVOList, page, size,count);
        } catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError(e.getMessage());

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

@ -4,6 +4,7 @@ import com.yihu.iot.service.company.IotCompanyService;
import com.yihu.iot.service.device.IotDeviceOrderService;
import com.yihu.jw.iot.company.IotCompanyTypeDO;
import com.yihu.jw.iot.device.IotDeviceOrderDO;
import com.yihu.jw.iot.device.IotOrderPurchaseDO;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.common.EnvelopRestController;
import com.yihu.jw.restmodel.iot.company.IotCompanyTypeVO;
@ -143,4 +144,20 @@ public class IotDeviceOrderController extends EnvelopRestController{
        }
    }
    @GetMapping(value = IotRequestMapping.DeviceOrder.findPurcharseById)
    @ApiOperation(value = "根据id查找采购订单", notes = "根据id查找采购订单")
    public Envelop<IotOrderPurchaseVO> findPurcharseById(@ApiParam(name = "id", value = "id")
                                                 @RequestParam(value = "id", required = true) String id
    ) {
        try {
            IotOrderPurchaseDO iotOrderPurchaseDO = iotDeviceOrderService.findPurchaseById(id);
            IotOrderPurchaseVO orderPurchaseVO = convertToModel(iotOrderPurchaseDO,IotOrderPurchaseVO.class);
            return Envelop.getSuccess(IotRequestMapping.DeviceOrder.message_success_find,orderPurchaseVO);
        } catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError(e.getMessage());
        }
    }
}

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

@ -59,7 +59,7 @@ 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 = true) String purcharseId,
                                                           @RequestParam(value = "purcharseId", required = false) String purcharseId,
                                                           @ApiParam(name = "page", value = "第几页", defaultValue = "")
                                                           @RequestParam(value = "page", required = false) Integer page,
                                                           @ApiParam(name = "size", value = "每页记录数", defaultValue = "")

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

@ -165,13 +165,13 @@ public class IotPatientDeviceController extends EnvelopRestController{
    public Envelop<IotPatientDeviceVO> updatePatientDevice(
            @ApiParam(name = "patient", value = "sn码", defaultValue = "")
            @RequestParam(value = "patient",required = true) String patient,
            @ApiParam(name = "deviceSN", value = "设备类型", defaultValue = "")
            @ApiParam(name = "deviceSN", value = "旧sn码", defaultValue = "")
            @RequestParam(value = "deviceSN",required = true) String deviceSN,
            @ApiParam(name = "newDeviceSN", value = "设备类型", defaultValue = "")
            @ApiParam(name = "newDeviceSN", value = "新sn码", defaultValue = "")
            @RequestParam(value = "newDeviceSN",required = true) String newDeviceSN,
            @ApiParam(name = "userType", value = "sn码", defaultValue = "")
            @ApiParam(name = "userType", value = "按键号", defaultValue = "")
            @RequestParam(value = "userType",required = true) String userType,
            @ApiParam(name = "sim", value = "按键号", defaultValue = "")
            @ApiParam(name = "sim", value = "sim卡号", defaultValue = "")
            @RequestParam(value = "sim",required = true) String sim) {
        try {
            iotPatientDeviceService.updatePatientDevice(patient, deviceSN, newDeviceSN, userType, sim);

+ 3 - 19
svr/svr-iot/src/main/java/com/yihu/iot/controller/product/IotProductController.java

@ -18,7 +18,6 @@ import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
 * @author yeshijie on 2018/1/17.
@ -35,7 +34,7 @@ public class IotProductController extends EnvelopRestController {
    @GetMapping(value = IotRequestMapping.Product.findProductPage)
    @ApiOperation(value = "分页查1找产品", notes = "分页查找产品")
    @ApiOperation(value = "分页查找产品", notes = "分页查找产品")
    public Envelop<IotProductBaseInfoVO> findCompanyPage(
            @ApiParam(name = "name", value = "注册证号或产品名称", defaultValue = "")
            @RequestParam(value = "name", required = false) String name,
@ -76,6 +75,7 @@ public class IotProductController extends EnvelopRestController {
            //DO转VO
            List<IotProductBaseInfoVO> iotCompanyVOList = convertToModels(list,new ArrayList<>(list.size()),IotProductBaseInfoVO.class);
            iotProductBaseInfoService.translateDictForList(iotCompanyVOList);
            return Envelop.getSuccessListWithPage(IotRequestMapping.Company.message_success_find_functions,iotCompanyVOList, page, size,count);
        } catch (Exception e) {
@ -116,23 +116,7 @@ public class IotProductController extends EnvelopRestController {
            //DO转VO
            List<IotProductBaseInfoVO> iotCompanyVOList = convertToModels(list,new ArrayList<>(list.size()),IotProductBaseInfoVO.class);
            if(iotCompanyVOList.size()>0){
                //字典翻译
                Map<String,String> product68Map = iotSystemDictService.findByDictName("PRODUCT_68_TYPE");
                Map<String,String> originMap = iotSystemDictService.findByDictName("ORIGIN_TYPE");
                Map<String,String> productSmallMap = iotSystemDictService.findByDictName("PRODUCT_SMALL_TYPE");
                iotCompanyVOList.forEach(infoVO->{
                    if(StringUtils.isNotBlank(infoVO.getType())){
                        infoVO.setTypeName(originMap.get(infoVO.getType()));
                    }
                    if(StringUtils.isNotBlank(infoVO.getInstrumentClassify())){
                        infoVO.setInstrumentClassifyName(product68Map.get(infoVO.getInstrumentClassify()));
                    }
                    if(StringUtils.isNotBlank(infoVO.getProductSubclass())){
                        infoVO.setProductSubclassName(productSmallMap.get(infoVO.getType()));
                    }
                });
            }
            iotProductBaseInfoService.translateDictForList(iotCompanyVOList);
            return Envelop.getSuccessListWithPage(IotRequestMapping.Company.message_success_find_functions,iotCompanyVOList, page, size,count);
        } catch (Exception e) {

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

@ -20,6 +20,9 @@ public interface IotPatientDeviceDao extends PagingAndSortingRepository<IotPatie
    @Query("from IotPatientDeviceDO a where a.patient = ?1 and a.del=1 ")
    List<IotPatientDeviceDO> findByPatient(String patient);
    @Query("from IotPatientDeviceDO a where a.deviceSn = ?1 and a.del=1 ")
    List<IotPatientDeviceDO> findByDeviceSn(String deviceSn);
    @Query("from IotPatientDeviceDO a where a.patient = ?1 and a.deviceSn=?2 and a.del=1")
    List<IotPatientDeviceDO> findByPatientAndDeviceSn(String patient,String deviceSn);

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

@ -48,6 +48,15 @@ public class IotDeviceOrderService extends BaseJpaService<IotDeviceOrderDO,IotDe
    @Autowired
    private IotDeviceQualityInspectionPlanDao iotDeviceQualityInspectionPlanDao;
    /**
     * 查找采购清单
     * @param id
     * @return
     */
    public IotOrderPurchaseDO findPurchaseById(String id){
        return iotOrderPurchaseDao.findById(id);
    }
    /**
     * 新增
     * @param iotOrderVO

+ 134 - 6
svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotDeviceService.java

@ -2,16 +2,13 @@ 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.IotDeviceDao;
import com.yihu.iot.dao.device.IotDeviceImportRecordDao;
import com.yihu.iot.dao.device.IotOrderPurchaseDao;
import com.yihu.jw.iot.device.IotDeviceDO;
import com.yihu.jw.iot.device.IotDeviceImportRecordDO;
import com.yihu.jw.iot.device.IotOrderPurchaseDO;
import com.yihu.iot.dao.device.*;
import com.yihu.jw.iot.device.*;
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.rm.iot.IotRequestMapping;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -45,6 +42,10 @@ public class IotDeviceService extends BaseJpaService<IotDeviceDO,IotDeviceDao> {
    private IotOrderPurchaseDao iotOrderPurchaseDao;
    @Autowired
    private IotDeviceImportRecordService importRecordService;
    @Autowired
    private IotPatientDeviceDao iotPatientDeviceDao;
    @Autowired
    private IotDeviceQualityInspectionPlanDao iotDeviceQualityInspectionPlanDao;
    /**
     * 新增
@ -53,6 +54,25 @@ public class IotDeviceService extends BaseJpaService<IotDeviceDO,IotDeviceDao> {
     */
    public IotDeviceDO create(IotDeviceDO iotDevice) {
        if(iotDevice.getPurchaseId()!=null){
            IotOrderPurchaseDO purchaseDO = iotOrderPurchaseDao.findById(iotDevice.getPurchaseId());
            iotDevice.setName(purchaseDO.getDeviceName());
            iotDevice.setOrderNo(purchaseDO.getOrderNo());
            iotDevice.setProductId(purchaseDO.getProductId());
            iotDevice.setSupplierId(purchaseDO.getSupplierId());
            iotDevice.setSupplierName(purchaseDO.getSupplierName());
            iotDevice.setManufacturerId(purchaseDO.getManufacturerId());
            iotDevice.setManufacturerName(purchaseDO.getManufacturerName());
            iotDevice.setStatus(IotDeviceDO.DeviceStatus.normal.getValue());
            iotDevice.setDeviceSource(IotDeviceDO.DeviceSource.purchaese.getValue());
            //获取质检信息
            IotDeviceQualityInspectionPlanDO planDO = iotDeviceQualityInspectionPlanDao.findLastByPurchaseId(iotDevice.getPurchaseId());
            if(planDO!=null){
                iotDevice.setNextQualityTime(planDO.getPlanTime());//下次质检时间
            }
        }
        iotDevice.setSaasId(getCode());
        iotDevice.setDel(1);
        return iotDeviceDao.save(iotDevice);
@ -101,6 +121,114 @@ public class IotDeviceService extends BaseJpaService<IotDeviceDO,IotDeviceDao> {
        this.batchInsert(iotDeviceDO);
    }
    /**
     * 查询
     * @param sn
     * @param hospital
     * @param orderId
     * @param purcharseId
     * @param page
     * @param size
     * @return
     */
    public Envelop<IotDeviceVO> queryPage(String sn,String hospital,String orderId,String purcharseId,Integer page,Integer size) throws Exception{
        String filters = "";
        String semicolon = "";
        if(StringUtils.isNotBlank(orderId)){
            filters += semicolon +"orderId="+orderId;
            semicolon = ";";
        }
        if(StringUtils.isNotBlank(purcharseId)){
            filters += semicolon +"purchaseId="+purcharseId;
            semicolon = ";";
        }
        if(StringUtils.isNotBlank(hospital)){
            filters += semicolon +"hospital="+hospital;
            semicolon = ";";
        }
        if(StringUtils.isNotBlank(sn)){
            filters = "deviceSn?"+sn+" g1;name?"+sn+" g1";
            semicolon = ";";
        }
        if(StringUtils.isBlank(filters)){
            filters+= semicolon + "del=1";
        }
        String sorts = "-updateTime";
        //得到list数据
        List<IotDeviceDO> list = search(null, filters, sorts, page, size);
        //获取总数
        long count = getCount(filters);
        //DO转VO
        List<IotDeviceVO> iotDeviceVOList = convertToModels(list,new ArrayList<>(list.size()),IotDeviceVO.class);
        iotDeviceVOList.forEach(one->{
            String deviceSn = one.getDeviceSn();
            List<IotPatientDeviceDO>  deviceDOList = iotPatientDeviceDao.findByDeviceSn(deviceSn);
            if(deviceDOList!=null&&deviceDOList.size()>0){
                one.setIsBinding(1);
            }else {
                one.setIsBinding(2);
            }
        });
        return Envelop.getSuccessListWithPage(IotRequestMapping.Company.message_success_find_functions,iotDeviceVOList, page, size,count);
    }
    /**
     * 是否绑定查询
     * @param sn
     * @param hospital
     * @param orderId
     * @param purcharseId
     * @param isBinding
     * @param page
     * @param size
     * @return
     */
    public Envelop<IotDeviceVO> queryPage(String sn,String hospital,String orderId,String purcharseId,Integer isBinding,Integer page,Integer size){
        StringBuffer sql = new StringBuffer("SELECT DISTINCT c.* from iot_device c ,iot_patient_device t WHERE c.del=1 and t.del=1 ");
        StringBuffer sqlCount = new StringBuffer("SELECT COUNT(DISTINCT c.id) count from iot_device c ,iot_patient_device t WHERE c.del=1 and t.del=1 ");
        List<Object> args = new ArrayList<>();
        if(StringUtils.isNotBlank(orderId)){
            sql.append(" and c.order_id = ? ");
            sqlCount.append(" and c.order_id = '").append(orderId).append("'");
            args.add(orderId);
        }
        if(StringUtils.isNotBlank(purcharseId)){
            sql.append(" and c.purcharse_id = ? ");
            sqlCount.append(" and c.purcharse_id = '").append(purcharseId).append("'");
            args.add(purcharseId);
        }
        if(StringUtils.isNotBlank(hospital)){
            sql.append(" and c.hospital = ? ");
            sqlCount.append(" and c.hospital = '").append(hospital).append("'");
            args.add(hospital);
        }
        if(StringUtils.isNotBlank(sn)){
            sql.append(" and (c.device_sn like ? or c.name like ?)");
            sqlCount.append(" and (c.device_sn like '").append(sn).append("' or c.name like '").append(sn).append("')");
            args.add(sn);
            args.add(sn);
        }
        sql.append(" and c.device_sn = t.device_sn ");
        sqlCount.append("  and c.device_sn = t.device_sn '");
        sql.append("order by c.update_time desc limit ").append((page-1)*size).append(",").append(size);
        List<IotDeviceDO> list = jdbcTempalte.query(sql.toString(),args.toArray(),new BeanPropertyRowMapper(IotDeviceDO.class));
        List<Map<String,Object>> countList = jdbcTempalte.queryForList(sqlCount.toString());
        long count = Long.valueOf(countList.get(0).get("count").toString());
        //DO转VO
        List<IotDeviceVO> iotDeviceVOList = convertToModels(list,new ArrayList<>(list.size()),IotDeviceVO.class);
        iotDeviceVOList.forEach(one->{
            one.setIsBinding(isBinding);
        });
        return Envelop.getSuccessListWithPage(IotRequestMapping.Common.message_success_find_functions,iotDeviceVOList, page, size,count);
    }
    /**
     * 根据设备序列号判断设备是否存在
     * @param deviceSn

+ 52 - 0
svr/svr-iot/src/main/java/com/yihu/iot/service/product/IotProductBaseInfoService.java

@ -2,15 +2,18 @@ package com.yihu.iot.service.product;
import com.yihu.base.mysql.query.BaseJpaService;
import com.yihu.iot.dao.product.*;
import com.yihu.iot.service.dict.IotSystemDictService;
import com.yihu.jw.iot.product.*;
import com.yihu.jw.restmodel.iot.product.*;
import com.yihu.jw.util.date.DateUtil;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
 * @author yeshijie on 2018/1/16.
@ -29,6 +32,8 @@ public class IotProductBaseInfoService extends BaseJpaService<IotProductBaseInfo
    private IotProductDataTransmissionDao iotProductDataTransmissionDao;
    @Autowired
    private IotProductExtendInfoDao iotProductExtendInfoDao;
    @Autowired
    private IotSystemDictService iotSystemDictService;
    /**
     * 按id查找产品详情
@ -48,6 +53,8 @@ public class IotProductBaseInfoService extends BaseJpaService<IotProductBaseInfo
        //日期单独处理
        baseInfoVO.setStartTime(DateUtil.dateToStrShort(baseInfoDO.getStartTime()));
        baseInfoVO.setEndTime(DateUtil.dateToStrShort(baseInfoDO.getEndTime()));
        //字典翻译
        translateDictForOne(baseInfoVO);
        IotProductExtendInfoVO extendInfoVO = convertToModel(extendInfoDO,IotProductExtendInfoVO.class);
        List<IotProductAttachmentVO> attachmentVOList =
@ -225,5 +232,50 @@ public class IotProductBaseInfoService extends BaseJpaService<IotProductBaseInfo
        iotProductDataTransmissionDao.save(dataTransmissionDOList);
    }
    /**
     * 产品字典翻译
     * @param iotCompanyVOList
     */
    public void translateDictForList(List<IotProductBaseInfoVO> iotCompanyVOList){
        if(iotCompanyVOList.size()>0){
            //字典翻译
            Map<String,String> product68Map = iotSystemDictService.findByDictName("PRODUCT_68_TYPE");
            Map<String,String> originMap = iotSystemDictService.findByDictName("ORIGIN_TYPE");
            Map<String,String> productSmallMap = iotSystemDictService.findByDictName("PRODUCT_SMALL_TYPE");
            iotCompanyVOList.forEach(infoVO->{
                if(StringUtils.isNotBlank(infoVO.getType())){
                    infoVO.setTypeName(originMap.get(infoVO.getType()));
                }
                if(StringUtils.isNotBlank(infoVO.getInstrumentClassify())){
                    infoVO.setInstrumentClassifyName(product68Map.get(infoVO.getInstrumentClassify()));
                }
                if(StringUtils.isNotBlank(infoVO.getProductSubclass())){
                    infoVO.setProductSubclassName(productSmallMap.get(infoVO.getType()));
                }
            });
        }
    }
    /**
     * 产品字典翻译
     * @param infoVO
     */
    public void translateDictForOne(IotProductBaseInfoVO infoVO){
        if(infoVO!=null){
            //字典翻译
            Map<String,String> product68Map = iotSystemDictService.findByDictName("PRODUCT_68_TYPE");
            Map<String,String> originMap = iotSystemDictService.findByDictName("ORIGIN_TYPE");
            Map<String,String> productSmallMap = iotSystemDictService.findByDictName("PRODUCT_SMALL_TYPE");
            if(StringUtils.isNotBlank(infoVO.getType())){
                infoVO.setTypeName(originMap.get(infoVO.getType()));
            }
            if(StringUtils.isNotBlank(infoVO.getInstrumentClassify())){
                infoVO.setInstrumentClassifyName(product68Map.get(infoVO.getInstrumentClassify()));
            }
            if(StringUtils.isNotBlank(infoVO.getProductSubclass())){
                infoVO.setProductSubclassName(productSmallMap.get(infoVO.getType()));
            }
        }
    }
}

+ 4 - 2
web-gateway/src/main/java/com/yihu/jw/controller/iot/device/IotDeviceController.java

@ -75,12 +75,14 @@ public class IotDeviceController extends EnvelopRestController{
                                                           @ApiParam(name = "orderId", value = "订单id", defaultValue = "")
                                                           @RequestParam(value = "orderId", required = false) String orderId,
                                                           @ApiParam(name = "purcharseId", value = "采购id", defaultValue = "")
                                                           @RequestParam(value = "purcharseId", required = true) String purcharseId,
                                                           @RequestParam(value = "purcharseId", required = false) String purcharseId,
                                                           @ApiParam(name = "isBinding", value = "是否绑定(1已绑定,2未绑定)", defaultValue = "")
                                                           @RequestParam(value = "isBinding", required = false) Integer isBinding,
                                                           @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 iotDeviceFeign.findProductPageByCompanyId(sn,hospital,orderId,purcharseId,page,size);
        return iotDeviceFeign.findProductPageByCompanyId(sn,hospital,orderId,purcharseId,isBinding,page,size);
    }
    @GetMapping(value = IotRequestMapping.Device.isImportDevice)

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

@ -77,4 +77,11 @@ public class IotDeviceOrderController extends EnvelopRestController{
        return iotDeviceOrderFeign.findPurcharsePage(orderId,page,size);
    }
    @GetMapping(value = IotRequestMapping.DeviceOrder.findPurcharseById)
    @ApiOperation(value = "根据id查找采购订单", notes = "根据id查找采购订单")
    public Envelop<IotOrderPurchaseVO>  findPurcharseById(@ApiParam(name = "id", value = "id")
                                                          @RequestParam(value = "id", required = true) String id
    ) {
        return iotDeviceOrderFeign.findPurcharseById(id);
    }
}

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

@ -41,7 +41,7 @@ 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 = true) String purcharseId,
                                                           @RequestParam(value = "purcharseId", required = false) String purcharseId,
                                                           @ApiParam(name = "page", value = "第几页", defaultValue = "")
                                                           @RequestParam(value = "page", required = false) Integer page,
                                                           @ApiParam(name = "size", value = "每页记录数", defaultValue = "")

+ 3 - 1
web-gateway/src/main/java/com/yihu/jw/feign/fallbackfactory/iot/device/IotDeviceFallbackFactory.java

@ -71,7 +71,8 @@ public class IotDeviceFallbackFactory implements FallbackFactory<IotDeviceFeign>
            public Envelop<IotDeviceVO> findProductPageByCompanyId(@RequestParam(value = "sn", required = false) String sn,
                                                                   @RequestParam(value = "hospital", required = false) String hospital,
                                                                   @RequestParam(value = "orderId", required = false) String orderId,
                                                                   @RequestParam(value = "purcharseId", required = true) String purcharseId,
                                                                   @RequestParam(value = "purcharseId", required = false) String purcharseId,
                                                                   @RequestParam(value = "isBinding", required = false) Integer isBinding,
                                                                   @RequestParam(value = "page", required = false) Integer page,
                                                                   @RequestParam(value = "size", required = false) Integer size){
                tracer.getCurrentSpan().logEvent("分页查找设备失败:原因:" + e.getMessage());
@ -79,6 +80,7 @@ public class IotDeviceFallbackFactory implements FallbackFactory<IotDeviceFeign>
                tracer.getCurrentSpan().logEvent("hospital:" + hospital);
                tracer.getCurrentSpan().logEvent("orderId:" + orderId);
                tracer.getCurrentSpan().logEvent("purcharseId:" + purcharseId);
                tracer.getCurrentSpan().logEvent("isBinding:" + isBinding);
                tracer.getCurrentSpan().logEvent("page:" + page);
                tracer.getCurrentSpan().logEvent("size:" + size);
                return null;

+ 6 - 0
web-gateway/src/main/java/com/yihu/jw/feign/fallbackfactory/iot/device/IotDeviceOrderFallbackFactory.java

@ -77,6 +77,12 @@ public class IotDeviceOrderFallbackFactory implements FallbackFactory<IotDeviceO
                return null;
            }
            @Override
            public Envelop<IotOrderPurchaseVO>  findPurcharseById(@RequestParam(value = "id", required = true) String id) {
                tracer.getCurrentSpan().logEvent("根据id查找采购订单失败:原因:" + e.getMessage());
                tracer.getCurrentSpan().logEvent("id:" + id);
                return null;
            }
        };
    }

+ 1 - 2
web-gateway/src/main/java/com/yihu/jw/feign/fallbackfactory/iot/device/IotDeviceQualityFallbackFactory.java

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

+ 3 - 1
web-gateway/src/main/java/com/yihu/jw/feign/iot/device/IotDeviceFeign.java

@ -42,7 +42,8 @@ public interface IotDeviceFeign{
            @RequestParam(value = "sn", required = false) String sn,
            @RequestParam(value = "hospital", required = false) String hospital,
            @RequestParam(value = "orderId", required = false) String orderId,
            @RequestParam(value = "purcharseId", required = true) String purcharseId,
            @RequestParam(value = "purcharseId", required = false) String purcharseId,
            @RequestParam(value = "isBinding", required = false) Integer isBinding,
            @RequestParam(value = "page", required = false) Integer page,
            @RequestParam(value = "size", required = false) Integer size);
@ -57,4 +58,5 @@ public interface IotDeviceFeign{
           @RequestParam(value = "purcharseId", required = true) String purcharseId,
           @RequestParam(value = "page", required = false) Integer page,
           @RequestParam(value = "size", required = false) Integer size);
}

+ 2 - 0
web-gateway/src/main/java/com/yihu/jw/feign/iot/device/IotDeviceOrderFeign.java

@ -45,4 +45,6 @@ public interface IotDeviceOrderFeign {
            @RequestParam(value = "page", required = false) Integer page,
            @RequestParam(value = "size", required = false) Integer size);
    @GetMapping(value = IotRequestMapping.DeviceOrder.findPurcharseById)
    Envelop<IotOrderPurchaseVO>  findPurcharseById(@RequestParam(value = "id", required = true) String id);
}

+ 1 - 1
web-gateway/src/main/java/com/yihu/jw/feign/iot/device/IotDeviceQualityFeign.java

@ -29,7 +29,7 @@ public interface IotDeviceQualityFeign{
    @GetMapping(value = IotRequestMapping.DeviceQuality.queryQualityPlanPage)
    public Envelop<IotDeviceQualityInspectionPlanVO> queryQualityPlanPage(
           @RequestParam(value = "purcharseId", required = true) String purcharseId,
           @RequestParam(value = "purcharseId", required = false) String purcharseId,
           @RequestParam(value = "page", required = false) Integer page,
           @RequestParam(value = "size", required = false) Integer size);