Kaynağa Gözat

设备绑定

Shi Kejing 4 yıl önce
ebeveyn
işleme
18ac26dd9c

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

@ -604,4 +604,38 @@ CREATE TABLE `base_business_sys_dict` (
  `model_name` varchar(50) DEFAULT NULL COMMENT '模块名称',
  PRIMARY KEY (`id`),
  KEY `dict_name` (`dict_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='托育业务字典表';
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='托育业务字典表';
CREATE TABLE `wlyy_devices` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `apply_date` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '申请日期',
  `org_name` varchar(255) DEFAULT NULL COMMENT '机构名称',
  `linkman` varchar(255) DEFAULT NULL COMMENT '联系人',
  `tel` varchar(255) DEFAULT NULL COMMENT '联系电话',
  `server_ip` varchar(255) DEFAULT NULL COMMENT '服务IP地址',
  `device_name` varchar(255) DEFAULT NULL COMMENT '设备名称',
  `device_model` varchar(255) DEFAULT NULL COMMENT '型号',
  `device_code` varchar(255) DEFAULT NULL COMMENT '设备唯一标识',
  `manufacturer_code` varchar(255) DEFAULT NULL COMMENT '厂商代码',
  `manufacturer` varchar(255) DEFAULT NULL COMMENT '厂家名称',
  `address` varchar(255) DEFAULT NULL COMMENT '厂家地址',
  `representative` varchar(255) DEFAULT NULL COMMENT '法人代表',
  `applicant_name` varchar(255) DEFAULT NULL COMMENT '申请注册人',
  `applicant_identity` varchar(255) DEFAULT NULL COMMENT '申请人身份证号',
  `applicant_tel` varchar(255) DEFAULT NULL COMMENT '申请人手机',
  `applicant_mail` varchar(255) DEFAULT NULL COMMENT '申请人邮箱',
  `sim` varchar(50) DEFAULT NULL COMMENT 'sim卡号',
  `manufacturer_id` varchar(50) DEFAULT NULL COMMENT '厂商id',
  `is_grant` int(2) DEFAULT '0' COMMENT '是否发放(0否1是)',
  `grant_admin_team` varchar(50) DEFAULT NULL COMMENT '发放的患者所在团队',
  `grant_org_code` varchar(50) DEFAULT NULL COMMENT '发放所在机构',
  `is_binding` int(2) DEFAULT '0' COMMENT '是否绑定(0否 1 是)',
  `binding_count` varchar(50) DEFAULT NULL COMMENT '绑定次数({"1":"0", "2":"0"})',
  `grant_time` datetime DEFAULT NULL COMMENT '发放时间',
  `grant_doctor` varchar(50) DEFAULT NULL COMMENT '发放医生code',
  `grant_doctor_name` varchar(50) DEFAULT NULL COMMENT '发放医生姓名',
  `neighborhood_committee_code` varchar(12) DEFAULT NULL COMMENT '居委会code',
  `neighborhood_committee_name` varchar(100) DEFAULT NULL COMMENT '居委会名称',
  PRIMARY KEY (`id`),
  KEY `idx_device_code` (`device_code`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='厦门设备信息表';

+ 1 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/device/DeviceDetailDao.java

@ -10,7 +10,7 @@ import org.springframework.data.repository.PagingAndSortingRepository;
 */
public interface DeviceDetailDao extends PagingAndSortingRepository<DeviceDetail, Long>, JpaSpecificationExecutor<DeviceDetail> {
    @Query(value = "select a.* from device.wlyy_devices a where a.device_code=?1 limit 0,1",nativeQuery = true)
    @Query(value = "select a.* from wlyy_devices a where a.device_code=?1 limit 0,1",nativeQuery = true)
    DeviceDetail findBySn(String sn);
}

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

@ -45,12 +45,16 @@ public interface PatientDeviceDao extends PagingAndSortingRepository<DevicePatie
    //管理员解绑居民设备
    @Modifying
    @Query("update DevicePatientDevice t set t.del = 1  where t.deviceSn = ?1 ")
    @Query("update DevicePatientDevice t set t.del = 1  where t.deviceSn = ?1 and t.del =0  ")
    int updatePatientDevice(String deviceSN);
    @Query("select a from DevicePatientDevice a")
    List<DevicePatientDevice> findAll();
    @Modifying
    @Query("delete DevicePatientDevice a where a.deviceSn = ?1")
    int deleteByDeviceSn(String deviceSN);
    @Query("select a from DevicePatientDevice a where a.user=?1 and a.del=0")
    List<DevicePatientDevice> findAllByUser(String user);

+ 3 - 3
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/DeviceDetailService.java

@ -81,17 +81,17 @@ public class DeviceDetailService extends BaseJpaService<DeviceDetail, DeviceDeta
		}
		if (isFirst){
			String updateFirstSql ="update device.wlyy_devices dd set dd.is_grant=1,dd.grant_admin_team=?,dd.grant_org_code=?,dd.binding_count=?,dd.grant_time = ?,dd.org_name=?,dd.grant_doctor=?,dd.grant_doctor_name=?,dd.is_binding=1 where dd.device_code=?";
			String updateFirstSql ="update wlyy_devices dd set dd.is_grant=1,dd.grant_admin_team=?,dd.grant_org_code=?,dd.binding_count=?,dd.grant_time = ?,dd.org_name=?,dd.grant_doctor=?,dd.grant_doctor_name=?,dd.is_binding=1 where dd.device_code=?";
			jdbcTemplate.update(updateFirstSql,new Object[]{String.valueOf(adminTeam),hospital,isFirstBind,grantTime,hospitalName,doctorCode, doctorName, devicePatientDevice.getDeviceSn()});
		}else {
			List<DevicePatientDevice> devicePatientDeviceList = patientDeviceDao.findByDeviceSn(devicePatientDevice.getDeviceSn());
			int patientDeviceSize = devicePatientDeviceList.size();
			String updateSql = "";
			if (bind == 0){
				updateSql ="update device.wlyy_devices dd set dd.is_grant=1,dd.grant_admin_team=?,dd.grant_org_code=?,dd.binding_count=?,dd.is_binding=?,dd.org_name=?,dd.grant_doctor=?,dd.grant_doctor_name=?  where dd.device_code=?";
				updateSql ="update wlyy_devices dd set dd.is_grant=1,dd.grant_admin_team=?,dd.grant_org_code=?,dd.binding_count=?,dd.is_binding=?,dd.org_name=?,dd.grant_doctor=?,dd.grant_doctor_name=?  where dd.device_code=?";
				jdbcTemplate.update(updateSql,new Object[]{String.valueOf(adminTeam),hospital,isFirstBind,patientDeviceSize,hospitalName,doctorCode,doctorName, devicePatientDevice.getDeviceSn()});
			}else if (bind>0){
				updateSql ="update device.wlyy_devices dd set dd.is_grant=1,dd.binding_count=?,dd.is_binding=? where dd.device_code=?";
				updateSql ="update wlyy_devices dd set dd.is_grant=1,dd.binding_count=?,dd.is_binding=? where dd.device_code=?";
				jdbcTemplate.update(updateSql,new Object[]{isFirstBind,patientDeviceSize, devicePatientDevice.getDeviceSn()});
			}
		}

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

@ -159,7 +159,7 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
        //校验sn码是否被使用
        if (needVerify) {
            DevicePatientDevice device = patientDeviceDao.findByDeviceSnAndUserType(sn, userType);
            if (device != null && !device.getId().equals(devicePatientDevice.getId())) {
            if (device != null && !device.getId().equals(devicePatientDevice.getId()) && device.getDel() == 0) {
                throw new Exception("sn码" + sn + "已被使用!");
            }
        }
@ -183,7 +183,7 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
        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);
            return patientDeviceDao.deleteByDeviceSn(deviceSn);
        }else {
            return 0;
        }
@ -252,7 +252,7 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
    public List<Map<String , Object>> findDeviceFromAdmin(String patientName, int page, int pageSize) {
        String sql = "select p.id,p.`name`,dd.photo,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,dm_device dd where p.id = pd.`user` and pd.category_code = dd.category_code";
                "pd.doctor_name doctorName,pd.agent,pd.agent_name agentName from wlyy_patient_device pd,base_patient p,dm_device dd where p.id = pd.`user` and pd.del = 0 and pd.category_code = dd.category_code";
        if (StringUtils.isNotBlank(patientName)){
            sql += " AND (p.`name` LIKE '%" + patientName +"%' or  p.idcard LIKE '%" + patientName + "%') ";
        }