Browse Source

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

shikejing 4 years ago
parent
commit
18c39e9fa5

+ 4 - 1
common/common-entity/sql记录

@ -448,4 +448,7 @@ alter table base_patient ADD disease varchar(50) ;
alter table patient_medicare_card ADD medicare_number varchar(50) ;
-- 2021-05-07 ysj
alter table base_patient_family_member add is_contacts tinyint(1) DEFAULT NULL COMMENT '是否是一键联系人';
alter table base_patient_family_member add is_contacts tinyint(1) DEFAULT NULL COMMENT '是否是一键联系人';
-- 2021-05-07 skj
ALTER TABLE base.wlyy_patient_device add COLUMN  `sos_address` varchar(50) DEFAULT NULL COMMENT '设备类型为报警器时,需要填写投放地址 category_code = 7';

+ 12 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/device/DevicePatientDevice.java

@ -65,6 +65,9 @@ public class DevicePatientDevice extends IdEntity {
    private String applyReason;
    //医生拒绝原因
    private String refuseReason;
    //设备类型为报警器时,需要填写投放地址 category_code = 7
    private String sosAddress;
  //========================非表字段======================
    //患者居住地址
    private String address;
@ -251,6 +254,15 @@ public class DevicePatientDevice extends IdEntity {
        this.checkDoctorName = checkDoctorName;
    }
    @Column(name = "sos_address")
    public String getSosAddress() {
        return sosAddress;
    }
    public void setSosAddress(String sosAddress) {
        this.sosAddress = sosAddress;
    }
    @Transient
    public String getAddress() {
        return address;

+ 4 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/device/PatientDeviceDao.java

@ -43,6 +43,10 @@ public interface PatientDeviceDao extends PagingAndSortingRepository<DevicePatie
    @Query("update DevicePatientDevice t set t.deviceSn = ?3 , t.userType = ?4,t.sim=?5,t.hospital=?6,t.hospitalName=?7,t.checkDoctorName=?8 where t.user = ?1 and t.deviceSn = ?2 ")
    int updatePatientDevice(String user, String deviceSN, String newDeviceSN, String userType, String sim, String hospital, String hospitalName, String checkDoctorName);
    //管理员解绑居民设备
    @Modifying
    @Query("update DevicePatientDevice t set t.del = 1  where t.deviceSn = ?1 ")
    int updatePatientDevice(String deviceSN);
    @Query("select a from DevicePatientDevice a")
    List<DevicePatientDevice> findAll();

+ 157 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/PadDeviceController.java

@ -0,0 +1,157 @@
package com.yihu.jw.care.endpoint.device;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.care.dao.device.PatientDeviceDao;
import com.yihu.jw.care.endpoint.BaseController;
import com.yihu.jw.care.service.device.DeviceDetailService;
import com.yihu.jw.care.service.device.PatientDeviceService;
import com.yihu.jw.care.service.device.PatientHealthIndexService;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.sync.BaseSyncDataDO;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.rm.base.BaseRequestMapping;
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.data.domain.Page;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.Date;
import java.util.List;
import java.util.Map;
/***
 * @ClassName: PadDeviceController
 * @Description:
 * @Auther: shi kejing
 * @Date: 2021/5/7 13:39
 */
@RestController
@RequestMapping(value = "pad/device")
@Api(value = "患者设备管理(平板端)", description = "患者设备管理")
public class PadDeviceController extends BaseController {
    @Autowired
    private PatientDeviceService patientDeviceService;
    @Autowired
    private DeviceDetailService deviceDetailService;
    @Autowired
    private BasePatientDao patientDao;
    private ObjectMapper objectMapper = new ObjectMapper();
    @Autowired
    private BaseDoctorDao baseDoctorDao;
    /**
     * 设备列表获取
     *
     * @return 操作结果
     */
    @ApiOperation("管理员获取设备列表")
    @RequestMapping(value = "PatientDeviceList", method = RequestMethod.GET)
    public String getDeviceByPatient(@ApiParam(name = "patientName", value = "居民姓名", defaultValue = "张")
                                     @RequestParam(value = "patientName", required = false) String patientName,
                                     @ApiParam(name = "idcard", value = "身份证号", defaultValue = "")
                                     @RequestParam(value = "idcard", required = false) String idcard,
                                     @ApiParam(name = "page", value = "分页起始id", defaultValue = "1")
                                     @RequestParam(value = "page", required = true) int page,
                                     @ApiParam(name = "pagesize", value = "每页条数", defaultValue = "10")
                                     @RequestParam(value = "pagesize", required = true) int pagesize) {
        try {
            List<Map<String , Object>> list = patientDeviceService.findDeviceFromAdmin(patientName, idcard, page, pagesize);
            return write(200, "查询成功", "data", list);
        } catch (Exception ex) {
            error(ex);
            return invalidUserException(ex, -1, ex.getMessage());
        }
    }
    @ApiOperation("平板端,添加设备时获取设备类型(大类)")
    @RequestMapping(value = "getDeviceTypeBig", method = RequestMethod.GET)
    public String getDeviceTypeBig(@ApiParam(name = "pyCode", value = "获取设备类型(默认为null,获取大类)", defaultValue = "")
                                       @RequestParam(value = "pyCode", required = false) String pyCode) {
        try {
            List<Map<String , Object>> list = patientDeviceService.getDeviceType(1,pyCode);
            return write(200, "查询成功", "data", list);
        } catch (Exception ex) {
            error(ex);
            return invalidUserException(ex, -1, ex.getMessage());
        }
    }
    @ApiOperation("平板端,添加设备时获取设备类型(小类)")
    @RequestMapping(value = "getDeviceTypeSmall", method = RequestMethod.GET)
    public String getDeviceTypeSmall(@ApiParam(name = "pyCode", value = "获取设备类型(默认为 watch,获取小类(智能手表多类型))", defaultValue = "watch")
                                         @RequestParam(value = "pyCode", required = false) String pyCode) {
        try {
            List<Map<String , Object>> list = patientDeviceService.getDeviceType(0,pyCode);
            return write(200, "查询成功", "data", list);
        } catch (Exception ex) {
            error(ex);
            return invalidUserException(ex, -1, ex.getMessage());
        }
    }
    @ApiOperation("设备保存接口(平板端绑定设备  设备为报警器时需要填写投放地址)")
    @RequestMapping(value = "SavePatientDevice", method = RequestMethod.POST)
    public String saveDevice(@ApiParam(name = "json", value = "设备数据json", defaultValue = "{     \"deviceId\":\"3\",     \"deviceName\":\"血压计-优瑞恩\",     \"deviceSn\":\"7052169111\",     \"categoryCode\":\"7\",     \"userType\":\"-1\", \"sosAddress\":\"福建省厦门市思明区望海路55号之1\" }")
                             @RequestParam(value = "json", required = true) String json,
                             @ApiParam(name = "patient", value = "居民code") @RequestParam(value = "patient", required = false) String patientCode
                             ) {
        try {
            DevicePatientDevice device = objectMapper.readValue(json, DevicePatientDevice.class);
            // 设置患者标识
            device.setUser(patientCode);
            //患者和设备是否首绑
            Map<String,Object> checkMap = patientDeviceService.checkBindingFirstAndType(device);
            boolean flag = (Boolean)checkMap.get("flag");
            int code = (Integer)checkMap.get("code");
            if (code==-30000){
                return write(-1,"设备不存在或者数据存在错误!");
            }
            BaseDoctorDO doctor = baseDoctorDao.findById(getUID());
            device.setAgent(getUID());
            device.setAgentName(doctor.getName());
            String sn = device.getDeviceSn();
            synchronized (sn.intern()){
                Boolean flagDevice = patientDeviceService.saveDevice(device);
                if (flagDevice == false){
                    return write(-1,"请填写投放地址");
                }
            }
            //修改设备表中{"1":"0", "2":"0"}的绑定次数 和其他绑定信息
            deviceDetailService.updateAfterBinding(device,new Date(),flag);
            return success("设备保存成功!");
        } catch (Exception ex) {
            error(ex);
            return invalidUserException(ex, -1, ex.getMessage());
        }
    }
    @ApiOperation("设备解绑接口(平板端解绑设备 )")
    @RequestMapping(value = "delDeviceByDeviceSn", method = RequestMethod.POST)
    public String delDeviceByDeviceSn(
                             @ApiParam(name = "deviceSn", value = "设备sn码") @RequestParam(value = "deviceSn", required = false) String deviceSn
    ) {
        try {
                int flagDevice = patientDeviceService.delDeviceByDeviceSn(deviceSn);
                if (flagDevice == 1){
                    return success("设备解绑成功!");
                }else {
                    return write(-1,"解绑失败,请确认设备sn码");
                }
        } catch (Exception ex) {
            error(ex);
            return invalidUserException(ex, -1, ex.getMessage());
        }
    }
}

+ 5 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/PatientDeviceController.java

@ -94,7 +94,11 @@ public class PatientDeviceController extends BaseController {
            }
            String sn = device.getDeviceSn();
            synchronized (sn.intern()){
                patientDeviceService.saveDevice(device);
//                patientDeviceService.saveDevice(device);
                Boolean flagDevice = patientDeviceService.saveDevice(device);
                if (flagDevice == false){
                    return write(-1,"请填写投放地址");
                }
            }
            //修改设备表中{"1":"0", "2":"0"}的绑定次数 和其他绑定信息
            deviceDetailService.updateAfterBinding(device,new Date(),flag);

+ 130 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/lifeCare/PadLifeCareEndpoint.java

@ -0,0 +1,130 @@
package com.yihu.jw.care.endpoint.lifeCare;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.service.lifeCare.LifeCareOrderService;
import com.yihu.jw.entity.care.lifeCare.LifeCareOrderDO;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
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.web.bind.annotation.*;
import java.util.List;
/***
 * @ClassName: PadLifeCareEndpoint
 * @Description:
 * @Auther: shi kejing
 * @Date: 2021/5/7 11:05
 */
@RestController
@RequestMapping(value = "pad/lifeCare")
@Api(value = "平板端-生活照料", description = "生活照料相关", tags = {"平板端-生活照料相关"})
public class PadLifeCareEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private LifeCareOrderService lifeCareOrderService;
    @PostMapping(value = "create")
    @ApiOperation(value = "申请生活照料")
    public Envelop create(@ApiParam(name = "jsonData", value = "Json数据", required = true) @RequestParam String jsonData) {
        JSONObject result = new JSONObject();
        try{
            result = lifeCareOrderService.create(jsonData,getUID());
        }catch (Exception e){
            e.printStackTrace();
            return Envelop.getError("操作失败",-1);
        }
        if (result.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
            return Envelop.getError(result.getString(ResponseContant.resultMsg),-1);
        }
        return success(result);
    }
    @PostMapping(value = "cancelOrder")
    @ApiOperation(value = "取消工单")
    public Envelop cancelOrder(
            @ApiParam(name = "orderId", value = "工单id") @RequestParam(value = "orderId", required = true) String orderId,
            @ApiParam(name = "reason", value = "取消理由") @RequestParam(value = "reason", required = true) String reason) {
        JSONObject result = new JSONObject();
        try{
            result = lifeCareOrderService.cancelOrder(orderId, 2, reason);
            if (result.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
                return Envelop.getError(result.getString(ResponseContant.resultMsg),-1);
            }
        }catch (Exception e){
            e.printStackTrace();
            return Envelop.getError("操作失败",-1);
        }
        return success(result.get(ResponseContant.resultMsg));
    }
    @GetMapping(value = "queryInfoStatusCountList")
    @ApiOperation(value = "统计生活照料工单各状态下的数量列表")
    public Envelop queryInfoStatusCountList(
            @ApiParam(name = "patient", value = "居民code") @RequestParam(value = "patient", required = false) String patient) {
        try {
            JSONObject result = lifeCareOrderService.queryInfoStatusCountList(patient);
            if (result.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
                return Envelop.getError(result.getString(ResponseContant.resultMsg),-1);
            }
            return success(result.get(ResponseContant.resultMsg));
        }catch (Exception e){
            e.printStackTrace();
            return Envelop.getError("查询失败",-1);
        }
    }
    @GetMapping(value = "infoList")
    @ApiOperation(value = "查询工单记录")
    public PageEnvelop page(
            @ApiParam(name = "patient", value = "居民code") @RequestParam(value = "patient", required = true) String patient,
            @ApiParam(name = "status", value = "工单状态,状态为全部时不传") @RequestParam(value = "status", required = false) Integer status,
            @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1") @RequestParam(value = "page") int page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15") @RequestParam(value = "size") int size) {
        try {
            JSONObject result = lifeCareOrderService.queryInfoList(patient, status, page, size);
            if (result.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
                return PageEnvelop.getError(result.getString(ResponseContant.resultMsg), -1);
            }
            int count = result.getIntValue(ResponseContant.count);
            return success((List) result.get(ResponseContant.resultMsg), count, page, size);
        }catch (Exception e){
            e.printStackTrace();
            return PageEnvelop.getError("查询失败", -1);
        }
    }
    @GetMapping(value = "findItemDict")
    @ApiOperation(value = "查找服务项字典")
    public ListEnvelop findItemDict() {
        try {
            return ListEnvelop.getSuccess("查询成功",lifeCareOrderService.findItemDict());
        }catch (Exception e){
            e.printStackTrace();
            return ListEnvelop.getError("查询失败");
        }
    }
    @GetMapping("getByOrderId")
    @ApiOperation(value = "根据工单id获取相应的工单")
    public ObjEnvelop getByOrderId(
            @ApiParam(value = "工单id", name = "orderId")
            @RequestParam(value = "orderId", required = true) String orderId) {
        try {
            // 根据orderId获取工单信息
            LifeCareOrderDO doorServiceOrderDO = lifeCareOrderService.getServiceOrderById(orderId);
            return ObjEnvelop.getSuccess("获取成功", doorServiceOrderDO);
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError( "获取失败" ,-1);
        }
    }
}

+ 12 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/sign/SignEndpoint.java

@ -492,6 +492,18 @@ public class SignEndpoint extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value="getServerDoctorAll")
    @ApiOperation(value = "获取所有服务医生")
    public ListEnvelop getServerDoctorAll(            @ApiParam(name = "patient", value = "患者id", required = true)
                                                          @RequestParam(value = "patient") String patient){
        try {
            return ListEnvelop.getSuccess("查询成功",servicePackageService.getServerDoctorAll(patient));
        }catch (Exception e){
            e.printStackTrace();
            return ListEnvelop.getError("查询失败");
        }
    }
    @GetMapping(value="getPackageDetailById")
    @ApiOperation(value = "获取服务包详情")
    public ObjEnvelop getPackageDetailById(@ApiParam(name="packageId",value = "服务包id",required = true)

+ 41 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/PatientDeviceService.java

@ -18,6 +18,7 @@ import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.jw.utils.StringUtil;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
@ -127,11 +128,18 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
        String type = devicePatientDevice.getCategoryCode();
        Long deviceId = devicePatientDevice.getDeviceId();
        String userType = devicePatientDevice.getUserType();
        String sosAddress = null;
        if (userType == null) {
            userType = "-1";
            devicePatientDevice.setUserType("-1");
        }
        if (type.equals("7")){
            if (StringUtils.isBlank(devicePatientDevice.getSosAddress())){
                return false;
            }
        }
        boolean needVerify = true;
        //修改操作
        if (devicePatientDevice.getId() != null) {
@ -168,6 +176,15 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
        return true;
    }
    public int delDeviceByDeviceSn(String deviceSn){
        String sql = "select * from wlyy_patient_device where del = 0 and device_sn = '"+deviceSn+"'";
        List<Map<String , Object>> list = jdbcTemplate.queryForList(sql);
        if (list.size() > 0){
            return patientDeviceDao.updatePatientDevice(deviceSn);
        }else {
            return 0;
        }
    }
    public void deleteDevices(String deviceSn, String type, String uuid) {
        List<DevicePatientDevice> devicePatientDevices = patientDeviceDao.findByDeviceSnAndCategoryCode(deviceSn, type);
@ -230,6 +247,30 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
        return patientDeviceDao.findAll(spec, pageRequest);
    }
    public List<Map<String , Object>> findDeviceFromAdmin(String patientName, String Idcard, int page, int pageSize) {
        String sql = "select p.id,p.`name`,pd.device_id deviceId,pd.category_code categoryCode,pd.device_name deviceName,pd.device_sn deviceSn,pd.czrq,pd.doctor,\n" +
                "pd.doctor_name doctorName,pd.agent,pd.agent_name agentName from wlyy_patient_device pd,base_patient p where p.id = pd.`user`";
        if (StringUtils.isNotBlank(patientName)){
            sql += " AND p.`name` LIKE '%" + patientName +"%'";
        }
        if (StringUtils.isNotBlank(Idcard)){
            sql += " AND p.idcard LIKE '%" + Idcard + "%'";
        }
        sql += " ORDER BY pd.czrq DESC LIMIT "+ (page-1)*pageSize +" , " + pageSize + " ";
        List<Map<String , Object>> list = jdbcTemplate.queryForList(sql);
        return list;
    }
    public List<Map<String , Object>> getDeviceType(int type,String pyCode) {
        String sql = "SELECT * FROM base_system_dict WHERE saas_id = 'device_type' AND type = "+type+"";
        if (StringUtils.isNotBlank(pyCode)){
            sql += " and py_code = '"+pyCode+"' " ;
        }
        List<Map<String , Object>> list = jdbcTemplate.queryForList(sql);
        return list;
    }
    /**
     * 患者设备列表接口--医生端
     */

+ 12 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/sign/ServicePackageService.java

@ -480,6 +480,18 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
        return result;
    }
    public List<Map<String,Object>> getServerDoctorAll(String patient){
        String sql="select DISTINCT doc.id doctor,CONCAT(doc.`name`,CASE WHEN doc.doctor_level=1 THEN '(社区医生)' ELSE '(助老员)' END) as name,doc.photo,doc.mobile\n" +
                "from base_service_package_item item ,base_service_package pack,base_team_member mem,base_doctor doc\n" +
                "where item.service_package_id in (\n" +
                "SELECT spc.service_package_id FROM base_service_package_record spc ,base_service_package_sign_record spsr\n" +
                "WHERE spc.patient = '"+patient+"' AND spsr.status = 1 AND spsr.patient = spc.patient\n" +
                ") and item.service_package_id = pack.id\n" +
                "and item.team_code = mem.team_code and mem.doctor_code = doc.id and mem.del=1 and pack.del=1 and item.del = 1";
        List<Map<String,Object>>result = jdbcTemplate.queryForList(sql);
        return result;
    }
    public Map<String,Object> getPackageDetailById(String packageId){
        String sql="select * from base_service_package where id='"+packageId+"' and del=1 ";
        Map<String,Object>result = jdbcTemplate.queryForMap(sql);