Browse Source

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

ysj 5 years ago
parent
commit
699fea7ebd

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

@ -148,6 +148,8 @@ public class IotRequestMapping {
        //设备维修
        public static final String createRepairDevice = "createRepairDevice";
        public static final String getRepairDeviceList = "getRepairDeviceList";
        public static final String getDeviceInfoByDeviceSn = "getDeviceInfoByDeviceSn";
        public static final String deleteRepairDevice = "deleteRepairDevice";
    }

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

@ -21,6 +21,8 @@ public class IotPatientDeviceVO extends BaseVO implements Serializable {
    private String patientName;
    @ApiModelProperty("居民身份证")
    private String idcard;
    @ApiModelProperty("居民联系方式")
    private String mobile;
    @ApiModelProperty("设备id")
    private String deviceId;
    @ApiModelProperty("设备名称")
@ -35,12 +37,31 @@ public class IotPatientDeviceVO extends BaseVO implements Serializable {
    private String userType;
    @ApiModelProperty("设备类型标识(1血压计,2血糖仪)")
    private String categoryCode;
    @ApiModelProperty("设备类型名称")
    private String categoryName;
    @ApiModelProperty("地址")
    private String address;
    @ApiModelProperty("社区")
    private String hospitalName;
    @ApiModelProperty("病情:0绿标,1黄标,2红标")
    private Integer diseaseCondition;
    @ApiModelProperty("厂商code")
    private String manufacturerId;
    @ApiModelProperty("厂商名称")
    private String manufacturerName;
    @ApiModelProperty("联系人姓名")
    private String contactsName;
    @ApiModelProperty("联系人手机号码")
    private String contactsMobile;
    @ApiModelProperty("维修状态(1待维护 2已报修 3厂家接收 4厂家寄回 5待更换 6已更换)")
    private Integer status;//维修状态(1待维护 2已报修 3厂家接收 4厂家寄回 5待更换 6已更换)
    @ApiModelProperty("损坏说明")
    private String damageDescription;//损坏说明
    @ApiModelProperty("申请维修附件图片,多个用逗号隔开")
    private String damageImages;//申请维修附件图片,多个用逗号隔开
    @ApiModelProperty("维修说明")
    private String repairDescription;//维修说明
    public String getPatient() {
        return patient;
@ -145,4 +166,84 @@ public class IotPatientDeviceVO extends BaseVO implements Serializable {
    public void setHospitalName(String hospitalName) {
        this.hospitalName = hospitalName;
    }
    public String getMobile() {
        return mobile;
    }
    public void setMobile(String mobile) {
        this.mobile = mobile;
    }
    public String getCategoryName() {
        return categoryName;
    }
    public void setCategoryName(String categoryName) {
        this.categoryName = categoryName;
    }
    public String getManufacturerId() {
        return manufacturerId;
    }
    public void setManufacturerId(String manufacturerId) {
        this.manufacturerId = manufacturerId;
    }
    public String getManufacturerName() {
        return manufacturerName;
    }
    public void setManufacturerName(String manufacturerName) {
        this.manufacturerName = manufacturerName;
    }
    public String getContactsName() {
        return contactsName;
    }
    public void setContactsName(String contactsName) {
        this.contactsName = contactsName;
    }
    public String getContactsMobile() {
        return contactsMobile;
    }
    public void setContactsMobile(String contactsMobile) {
        this.contactsMobile = contactsMobile;
    }
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    public String getDamageDescription() {
        return damageDescription;
    }
    public void setDamageDescription(String damageDescription) {
        this.damageDescription = damageDescription;
    }
    public String getDamageImages() {
        return damageImages;
    }
    public void setDamageImages(String damageImages) {
        this.damageImages = damageImages;
    }
    public String getRepairDescription() {
        return repairDescription;
    }
    public void setRepairDescription(String repairDescription) {
        this.repairDescription = repairDescription;
    }
}

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

@ -306,7 +306,7 @@ public class IotPatientDeviceController extends EnvelopRestEndpoint {
    }
    @PostMapping(value = IotRequestMapping.PatientDevice.createRepairDevice)
    @ApiOperation(value = "新增设备维修记录", notes = "新增设备维修记录")
    @ApiOperation(value = "新增编辑设备维修记录", notes = "新增编辑设备维修记录")
    public MixEnvelop<IotPatientDeviceVO, IotPatientDeviceVO> createRepairDevice(@ApiParam(name = "deviceSn", value = "设备sn码")
                                                                                     @RequestParam(value = "deviceSn", required = true) String deviceSn,
                                                                                 @ApiParam(name = "status", value = "维修状态(1待维护 2已报修 3厂家接收 4厂家寄回 5待更换 6已更换)")
@ -314,11 +314,60 @@ public class IotPatientDeviceController extends EnvelopRestEndpoint {
                                                                                 @ApiParam(name = "damageDescription", value = "损坏说明")
                                                                                     @RequestParam(value = "damageDescription", required = false) String damageDescription,
                                                                                 @ApiParam(name = "damageImages", value = "申请维修附件图片,多个用逗号隔开")
                                                                                     @RequestParam(value = "damageImages", required = false) String damageImages) {
                                                                                     @RequestParam(value = "damageImages", required = false) String damageImages,
                                                                                 @ApiParam(name = "repairDescription", value = "维修说明")
                                                                                     @RequestParam(value = "repairDescription", required = false) String repairDescription) {
        try {
            //设备绑定
            List<IotPatientDeviceVO> patientDeviceDOList = iotPatientDeviceService.createRepairDevice(deviceSn, status, damageDescription, damageImages);
            return MixEnvelop.getSuccessList(IotRequestMapping.Device.message_success_create, patientDeviceDOList);
            List<IotPatientDeviceVO> patientDeviceDOList = iotPatientDeviceService.createRepairDevice(deviceSn, status, damageDescription, damageImages, repairDescription);
            return MixEnvelop.getSuccessList(IotRequestMapping.Device.message_success_update, patientDeviceDOList);
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
        }
    }
    @PostMapping(value = IotRequestMapping.PatientDevice.deleteRepairDevice)
    @ApiOperation(value = "删除设备维修记录", notes = "删除设备维修记录")
    public MixEnvelop<IotPatientDeviceVO, IotPatientDeviceVO> deleteRepairDevice(@ApiParam(name = "deviceSn", value = "设备sn码")
                                                                                 @RequestParam(value = "deviceSn", required = true) String deviceSn) {
        try {
            iotPatientDeviceService.deleteRepairDevice(deviceSn);
            return MixEnvelop.getSuccess(IotRequestMapping.Device.message_success_delete);
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
        }
    }
    @GetMapping(value = IotRequestMapping.PatientDevice.getDeviceInfoByDeviceSn)
    @ApiOperation(value = "根据sn码获取厂商相关信息", notes = "根据sn码获取厂商相关信息")
    public MixEnvelop<IotPatientDeviceVO, IotPatientDeviceVO> getDeviceInfoByDeviceSn(
            @ApiParam(name = "deviceSn", value = "sn码", defaultValue = "")
            @RequestParam(value = "deviceSn", required = true) String deviceSn) {
        try {
            List<IotPatientDeviceVO> list = iotPatientDeviceService.getDeviceInfoByDeviceSn(deviceSn);
            return MixEnvelop.getSuccessList(IotRequestMapping.Device.message_success_find, list);
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
        }
    }
    @GetMapping(value = IotRequestMapping.PatientDevice.getRepairDeviceList)
    @ApiOperation(value = "获取售后管理列表", notes = "获取售后管理列表")
    public MixEnvelop<IotPatientDeviceVO, IotPatientDeviceVO> getRepairDeviceList(
            @ApiParam(name = "deviceSn", value = "sn码", defaultValue = "")
            @RequestParam(value = "deviceSn", required = false) String deviceSn,
            @ApiParam(name = "status", value = "维修状态(1待维护 2已报修 3厂家接收 4厂家寄回 5待更换 6已更换)")
            @RequestParam(value = "status", required = false) Integer status,
            @ApiParam(name = "manufacturerId", value = "厂商id")
            @RequestParam(value = "manufacturerId", required = false) String manufacturerId,
            @ApiParam(name = "page", value = "第几页", defaultValue = "1")
            @RequestParam(value = "page", required = false) Integer page,
            @ApiParam(name = "pageSize", value = "每页记录数")
            @RequestParam(value = "pageSize", required = false) Integer pageSize) {
        try {
            return iotPatientDeviceService.getRepairDeviceList(deviceSn, status, manufacturerId, page, pageSize);
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());

+ 82 - 4
svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotPatientDeviceService.java

@ -8,18 +8,21 @@ import com.yihu.iot.service.common.ElasticSearchQueryGenerator;
import com.yihu.jw.device.LocationDataDO;
import com.yihu.jw.entity.iot.device.IotPatientDeviceDO;
import com.yihu.jw.restmodel.iot.device.IotPatientDeviceVO;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.rm.iot.IotRequestMapping;
import com.yihu.jw.util.common.LatitudeUtils;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.mysql.query.BaseJpaService;
import io.searchbox.client.JestResult;
import iot.device.LocationDataVO;
import org.apache.commons.lang3.StringUtils;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.io.IOException;
import java.util.*;
@ -275,16 +278,91 @@ public class IotPatientDeviceService extends BaseJpaService<IotPatientDeviceDO,
        return count;
    }
    public List<IotPatientDeviceVO> createRepairDevice(String deviceSn, Integer status, String damageDescription, String damageImages) {
    /**
     * 新增编辑维修记录
     * @param deviceSn
     * @param status
     * @param damageDescription
     * @param damageImages
     * @param repairDescription
     * @return
     */
    public List<IotPatientDeviceVO> createRepairDevice(String deviceSn, Integer status, String damageDescription, String damageImages, String repairDescription) {
        List<IotPatientDeviceDO> patientDeviceDOList = iotPatientDeviceDao.findByDeviceSn(deviceSn);
        for(IotPatientDeviceDO patientDeviceDO : patientDeviceDOList){
            patientDeviceDO.setStatus(status);
            patientDeviceDO.setDamageDescription(damageDescription);
            patientDeviceDO.setDamageImages(damageImages);
            if(StringUtils.isNotBlank(damageDescription)) {
                patientDeviceDO.setDamageDescription(damageDescription);
            }
            if(StringUtils.isNotBlank(damageImages)) {
                patientDeviceDO.setDamageImages(damageImages);
            }
            if(StringUtils.isNotBlank(repairDescription)) {
                patientDeviceDO.setRepairDescription(repairDescription);
            }
            patientDeviceDO.setUpdateTime(new Date());
        }
        iotPatientDeviceDao.save(patientDeviceDOList);
        List<IotPatientDeviceVO> patientDeviceVOS = new ArrayList<>();
        return convertToModels(patientDeviceDOList, patientDeviceVOS, IotPatientDeviceVO.class);
    }
    /**
     * 根据设备码获取相关厂商信息
     * @param deviceSn
     * @return
     */
    public List<IotPatientDeviceVO> getDeviceInfoByDeviceSn(String deviceSn) {
        String sql = "SELECT p.id,p.device_sn,p.device_id,p.device_name, GROUP_CONCAT(p.patient_name) as patientName,p.idcard,p.mobile,d.manufacturer_id, c.`name` manufacturerName,c.contacts_name, c.contacts_mobile " +
                "FROM `iot_patient_device` p, iot_device d LEFT JOIN iot_company c on d.manufacturer_id = c.id and c.status = 1 " +
                "where p.device_sn = '" + deviceSn + "' and p.del =  1 and p.device_id= d.id GROUP BY p.device_sn ";
        List<IotPatientDeviceVO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(IotPatientDeviceVO.class));
        return list;
    }
    /**
     * 获取设备维修记录
     * @param deviceSn
     * @param status
     * @param manufacturerId
     * @param page
     * @param pageSize
     * @return
     */
    public MixEnvelop<IotPatientDeviceVO, IotPatientDeviceVO> getRepairDeviceList(String deviceSn, Integer status, String manufacturerId, Integer page, Integer pageSize) {
        String sql ="SELECT p.device_sn,p.device_id,p.device_name,GROUP_CONCAT(p.patient_name) as patientName,p.idcard,p.mobile,p.`status`,p.damage_description,p.damage_images,p.repair_description,d.manufacturer_id, c.`name` manufacturerName,c.contacts_name, c.contacts_mobile " +
                "FROM `iot_patient_device` p, iot_device d LEFT JOIN iot_company c on d.manufacturer_id = c.id and c.status = 1 " +
                "where  p.del =  1 and p.`status` is not null and p.`status` > 0 and p.device_id= d.id ";
        if(StringUtils.isNotBlank(deviceSn)){
            sql += " and p.device_sn like '%" + deviceSn + "%' ";
        }
        if(StringUtils.isNotBlank(manufacturerId)){
            sql +=" and d.manufacturer_id = '" +manufacturerId + "' ";
        }
        if(status != null){
            sql += " and p.status = " +status;
        }else if(StringUtils.isNotBlank(manufacturerId)){
            sql +=" and p.status in (2,3,4) ";//厂商只展示三种维修状态
        }
        sql +=" GROUP BY p.device_sn ORDER BY p.update_time desc ";
        if (page != null && pageSize != null) {
            String sqlCount = "SELECT count(DISTINCT p.device_sn) " + sql.substring(sql.indexOf("FROM"), sql.length());
            Long count = jdbcTemplate.queryForObject(sqlCount, Long.class);
            sql += "limit " +(page-1)* pageSize + "," +pageSize;
            List<IotPatientDeviceVO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(IotPatientDeviceVO.class));
            return MixEnvelop.getSuccessListWithPage(IotRequestMapping.Device.message_success_find, list,page, pageSize,count);
        }
        List<IotPatientDeviceVO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(IotPatientDeviceVO.class));
        return MixEnvelop.getSuccessList(IotRequestMapping.Device.message_success_find, list);
    }
    public void deleteRepairDevice(String deviceSn) {
        List<IotPatientDeviceDO> patientDeviceDOList = iotPatientDeviceDao.findByDeviceSn(deviceSn);
        for(IotPatientDeviceDO patientDeviceDO : patientDeviceDOList){
            patientDeviceDO.setStatus(0);
            patientDeviceDO.setUpdateTime(new Date());
        }
        iotPatientDeviceDao.save(patientDeviceDOList);
    }
}