Explorar el Código

Merge branch 'dev' of humingfen/wlyy2.0 into dev

humingfen hace 5 años
padre
commit
ad734df1c5

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

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

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

@ -145,6 +145,9 @@ public class IotRequestMapping {
        public static final String updateLocation= "updateLocation";
        public static final String createPatientDevice = "createPatientDevice";
        public static final String changePatientDevice = "changePatientDevice";
        public static final String getPatientDeviceList = "getPatientDeviceList";
        public static final String deleteDelPatientDevice = "deleteDelPatientDevice";
        //设备维修
        public static final String createRepairDevice = "createRepairDevice";

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

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

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

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

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

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

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

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

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

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

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

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