|  | @ -4,14 +4,17 @@ package com.yihu.jw.base.service.a3service;
 | 
	
		
			
				|  |  | import com.alibaba.fastjson.JSONObject;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import com.fasterxml.jackson.databind.ObjectMapper;
 | 
	
		
			
				|  |  | import com.yihu.jw.base.dao.a2dao.MedicineDeviceDeliveryDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.base.dao.a2dao.MediicineDeviceDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.base.dao.a2dao.MediicineDeviceUserDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.base.dao.a2dao.MediicinedrugsDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.base.util.ConstantUtils;
 | 
	
		
			
				|  |  | import com.yihu.jw.base.util.JavaBeanUtils;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.a1entity.MedicineDeviceDelivery;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.a1entity.MediicineDeviceUser;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.a1entity.Mediicinedevice;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.a1entity.Mediicinedrugs;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.restmodel.ResponseContant;
 | 
	
		
			
				|  |  | import com.yihu.jw.util.date.DateUtil;
 | 
	
		
			
				|  |  | import com.yihu.jw.utils.hibernate.HibenateUtils;
 | 
	
	
		
			
				|  | @ -38,6 +41,10 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private MediicineDeviceUserDao deviceUserDao;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private MedicineDeviceDeliveryDao deviceDeliveryDao;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private ObjectMapper objectMapper;
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -90,6 +97,69 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
 | 
	
		
			
				|  |  |         return result.toJSONString();
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @Transactional(rollbackFor = Exception.class)
 | 
	
		
			
				|  |  |     public String createDeviceAddress(String jsonData) {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         JSONObject result = new JSONObject();
 | 
	
		
			
				|  |  |         if(StringUtils.isEmpty(jsonData)){
 | 
	
		
			
				|  |  |             result.put("msg","jsonData is null");
 | 
	
		
			
				|  |  |             result.put("response", ConstantUtils.FAIL);
 | 
	
		
			
				|  |  |             return result.toJSONString();
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         JSONObject device = JSONObject.parseObject(jsonData);
 | 
	
		
			
				|  |  |         if(null == device){
 | 
	
		
			
				|  |  |             result.put("msg","parameter delivery of jsonData is null");
 | 
	
		
			
				|  |  |             result.put("response", ConstantUtils.FAIL);
 | 
	
		
			
				|  |  |             return result.toJSONString();
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         //判断设备id是否存在
 | 
	
		
			
				|  |  | //        if(StringUtils.isEmpty(device.getString("id"))){
 | 
	
		
			
				|  |  | //            result.put("msg","parameter id for device is null when update device");
 | 
	
		
			
				|  |  | //            result.put("response", ConstantUtils.FAIL);
 | 
	
		
			
				|  |  | //            return result.toJSONString();
 | 
	
		
			
				|  |  | //        }
 | 
	
		
			
				|  |  |         MedicineDeviceDelivery deviceDelivery = null;
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             deviceDelivery = objectMapper.readValue(device.toJSONString(), MedicineDeviceDelivery.class);
 | 
	
		
			
				|  |  |         } catch (IOException e) {
 | 
	
		
			
				|  |  |             result.put("msg", "convert deviceDelivery jsonObject to BaseDeviceDO failed," + e.getCause());
 | 
	
		
			
				|  |  |             result.put("response", ConstantUtils.FAIL);
 | 
	
		
			
				|  |  |             return result.toJSONString();
 | 
	
		
			
				|  |  |         } catch (Exception e) {
 | 
	
		
			
				|  |  |             result.put("msg", "convert deviceDelivery birth failed," + e.getCause());
 | 
	
		
			
				|  |  |             result.put("response", ConstantUtils.FAIL);
 | 
	
		
			
				|  |  |             return result.toJSONString();
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         deviceDeliveryDao.save(deviceDelivery);
 | 
	
		
			
				|  |  |         result.put("response",ConstantUtils.SUCCESS);
 | 
	
		
			
				|  |  |         result.put("msg",deviceDelivery);
 | 
	
		
			
				|  |  |         return result.toJSONString();
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 删除投放地址
 | 
	
		
			
				|  |  |      * @param ids
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public JSONObject deleteAddress(String ids) {
 | 
	
		
			
				|  |  |         JSONObject result = new JSONObject();
 | 
	
		
			
				|  |  |         if (StringUtils.isEmpty(ids)) {
 | 
	
		
			
				|  |  |             result.put("response",ConstantUtils.FAIL);
 | 
	
		
			
				|  |  |             result.put("msg","ids is empty");
 | 
	
		
			
				|  |  |             return result;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         for (String id : ids.split(",")) {
 | 
	
		
			
				|  |  |             if (!StringUtils.isEmpty(id)) {
 | 
	
		
			
				|  |  |                 deviceDeliveryDao.delete(id);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         result.put("response",ConstantUtils.SUCCESS);
 | 
	
		
			
				|  |  |         result.put("msg",ConstantUtils.SUCCESS);
 | 
	
		
			
				|  |  |         return result;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 修改设备
 | 
	
		
			
				|  |  |      * @param jsonData
 | 
	
	
		
			
				|  | @ -165,6 +235,7 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
 | 
	
		
			
				|  |  |             result.put("response", ConstantUtils.FAIL);
 | 
	
		
			
				|  |  |             return result.toJSONString();
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         for (String deviceId : deviceIds.split(",")) {
 | 
	
		
			
				|  |  |             if(!StringUtils.isEmpty(deviceId)){
 | 
	
		
			
				|  |  |                 Mediicinedevice mediicinedevice = deviceDao.findOne(deviceId);
 | 
	
	
		
			
				|  | @ -1114,5 +1185,24 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
 | 
	
		
			
				|  |  |         result.put("msg",list);
 | 
	
		
			
				|  |  |         return result;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  |     //getDevicesDelivery
 | 
	
		
			
				|  |  |     public List<Map<String,Object>> getDevicesDelivery(String belongCommunity){
 | 
	
		
			
				|  |  |         String sql = "SELECT\n" +
 | 
	
		
			
				|  |  |                 "    t.id AS id,\n" +
 | 
	
		
			
				|  |  |                 "    t.belong_community AS belongCommunity,\n" +
 | 
	
		
			
				|  |  |                 "    t.address AS address,\n" +
 | 
	
		
			
				|  |  |                 "    t.create_time AS createTime,\n" +
 | 
	
		
			
				|  |  |                 "    t.create_user AS createUser,\n" +
 | 
	
		
			
				|  |  |                 "    t.create_user_name AS createUserName,\n" +
 | 
	
		
			
				|  |  |                 "    t.update_time AS updateTime,\n" +
 | 
	
		
			
				|  |  |                 "    t.update_user AS updateUser,\n" +
 | 
	
		
			
				|  |  |                 "    t.update_user_name AS updateUserName\n" +
 | 
	
		
			
				|  |  |                 "FROM\n" +
 | 
	
		
			
				|  |  |                 "    t_medicine_device_delivery AS t \n" +
 | 
	
		
			
				|  |  |                 "WHERE t.belong_community = '" + belongCommunity + "'";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         List<Map<String,Object>> list = hibenateUtils.createSQLQuery(sql);
 | 
	
		
			
				|  |  |         return list;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | }
 |