| 
					
				 | 
			
			
				@ -10,6 +10,7 @@ import com.yihu.jw.base.util.ConstantUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.base.util.JavaBeanUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.a1entity.Mediicinedevice; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.a1entity.Mediicinedrugs; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.restmodel.ResponseContant; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.util.date.DateUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.utils.hibernate.HibenateUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.mysql.query.BaseJpaService; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -176,7 +177,11 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    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" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    t.update_user_name as updateUserName,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    t.aisles as aisles,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    t.capacity as capacity,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    t.ratio as ratio,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    t.cargo_capacity as cargoCapacity\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "FROM\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    t_mediicine_device AS t where 1=1\n"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -255,7 +260,11 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    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" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    t.update_user_name as updateUserName,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    t.aisles as aisles,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    t.capacity as capacity,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    t.ratio as ratio,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    t.cargo_capacity as cargoCapacity\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "FROM\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    t_mediicine_device AS t where 1=1\n"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -363,7 +372,11 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    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" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    t.update_user_name as updateUserName,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    t.aisles as aisles,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    t.capacity as capacity,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    t.ratio as ratio,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    t.cargo_capacity as cargoCapacity\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "FROM\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    t_mediicine_device AS t where\n"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -425,10 +438,13 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public  JSONObject countAll() throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONObject result = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONObject jsonObject = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql = "select count(1) from t_mediicine_device a"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        int count = jdbcTemplate.queryForObject(sql,Integer.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        jsonObject.put("count", count); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.put("response",ConstantUtils.SUCCESS); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.put("msg", count); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.put("msg", jsonObject); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -445,9 +461,10 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public JSONObject countOnline() throws Exception{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONObject result = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql = "select count(1) from t_mediicine_device a where a.status = 1"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        int count = jdbcTemplate.queryForObject(sql,Integer.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONObject jsonObject = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        jsonObject.put("count",deviceDao.countOnline()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        jsonObject.put("count",count); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.put("response",ConstantUtils.SUCCESS); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.put("msg",jsonObject); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return result; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -498,4 +515,196 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        result.put(ResponseContant.resultMsg,"success"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 获取缺货设备列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param replenishEr 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param address 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @throws Exception 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public JSONObject getOutOfStockDeviceList(String replenishEr, String address) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONObject result = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql = "SELECT\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\tifnull(sum(tmi.qty), 0) AS totalQty,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\tifnull(\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\t\tt.aisles - count(tmi.id),\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\t\tt.aisles\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\t) AS unusedAisles,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\tifnull(\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\t\tt.capacity - sum(tmi.qty),\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\t\tt.capacity\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\t) AS unuserdCapacity,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\tifnull((t.capacity - sum(tmi.qty)) / t.capacity, 0) AS idleRate,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\tt.id as id,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\tt.belong_community as belongCommunity,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\tt.community as community,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\tt.del as del,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\tt.delivery_address as deliveryAddress,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\tt.detail_address as detailAddress,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\tt.equ_area as equArea,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\tt.equ_class as equClass,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\tt.equ_info as equInfo,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\tt.equ_name as equName,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\tt.equ_num as equNum,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\tt.equ_type as equType,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\tt.fbelong_community as fbelongCommunity,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\tt.machine_code as machineCode,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\tt.network_status as networkStatus,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\tt.poweron_test as poweronTest,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\tt.reg_date as regDate,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\tt.sale_status as saleStatus,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\tt.signalintensity as signalintensity,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\tt.upgr_adesit as upgrAdesit,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\tt.`status` as `status`,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\tt.card_status as cardStatus,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\tt.operator as operator,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\tt.pack_age as packAge,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\tt.usage_flow as usageFlow,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\tt.flow as flow,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\tt.create_time as createTime,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\tt.create_user as createUser,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\tt.create_user_name as createUserName,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\tt.update_time as updateTime,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\tt.update_user as updateUser,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\tt.update_user_name as updateUserName,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\tt.aisles as aisles,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\tt.capacity as capacity,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\tt.ratio as ratio,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\tt.cargo_capacity as cargoCapacity\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "FROM\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\tt_mediicine_device t\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "LEFT JOIN t_mediicinecabinet_inventory tmi ON t.id = tmi.id_device\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "WHERE 1=1\n" ; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (!StringUtils.isEmpty(replenishEr)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql +=" AND t.id in (select device_id from t_mediicine_device_user tmdu left join t_mediicine_user tmu on tmdu.user_id = tmu.id where tmdu.del = 1 and CONCAT(tmu.name,tmu.account) like '%" + replenishEr + "%')\n"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (!StringUtils.isEmpty(address)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql += " AND CONCAT(t.detail_address,t.delivery_address) like '%" + address + "%'\n"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       sql += "GROUP BY\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            "\tt.id\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            "HAVING\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            "\tsum(tmi.qty) < t.capacity * t.ratio\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            "OR sum(tmi.qty) IS NULL"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String,Object>> list=null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        list = hibenateUtils.createSQLQuery(sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.put("response", ConstantUtils.SUCCESS); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.put("msg",list); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public JSONObject getDetialOutOfStock(String ids) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONObject result = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql = "SELECT\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    t.id AS id,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    t.belong_community AS belongCommunity,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    t.community AS community,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    t.del AS del,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    t.delivery_address AS deliveryAddress,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    t.detail_address AS detailAddress,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    t.equ_area AS equArea,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    t.equ_class AS equClass,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    t.equ_info AS equInfo,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    t.equ_name AS equName,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    t.equ_num AS equNum,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    t.equ_type AS equType,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    t.fbelong_community AS fbelongCommunity,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    t.machine_code AS machineCode,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    t.network_status AS networkStatus,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    t.poweron_test AS poweronTest,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    t.reg_date AS regDate,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    t.sale_status AS saleStatus,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    t.signalintensity AS signalintensity,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    t.upgr_adesit AS upgrAdesit,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    t.`status` AS `status`,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    t.card_status AS cardStatus,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    t.operator AS operator,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    t.pack_age AS packAge,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    t.usage_flow AS usageFlow,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    t.flow AS flow,\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" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    t.aisles AS aisles,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    t.capacity AS capacity,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    t.ratio AS ratio,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    t.cargo_capacity AS cargoCapacity\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "FROM\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "    t_mediicine_device AS t WHERE id in(" + ids + ",'')"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sencordSql = "SELECT\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\ttmi.layer_no AS layerNo,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\ttmi.wayer_no AS wayerNo,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\ttmi.qty AS qty,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\ttmd.id AS id,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\ttmd.approval_num AS approvalNum,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\ttmd.barcode AS barcode,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\ttmd.brand AS brand,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\ttmd.dos_form AS dosForm,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\ttmd.state AS state,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\ttmd.drug_bar_code AS drugBarCode,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\ttmd.drug_class AS drugClass,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\ttmd.drug_class_code AS drugClassCode,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\ttmd.drug_code AS drugCode,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\ttmd.drug_name AS drugName,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\ttmd.drug_name_alies AS drugNameAlies,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\ttmd.drug_short_code AS drugShortCode,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\ttmd.drug_type_code AS drugTypeCode,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\ttmd.earlywarningcate AS earlywarningcate,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\ttmd.inventory AS inventory,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\ttmd.manufactor AS manufactor,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\ttmd.med_cabinet AS medCabinet,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\ttmd.pic AS pic,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\ttmd.price AS price,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\ttmd.sale_volume AS saleVolume,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\ttmd.self_code AS selfCode,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\ttmd.specif AS specif,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\ttmd.unit AS unit,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\ttmd.create_time AS createTime,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\ttmd.create_user AS createUser,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\ttmd.create_user_name AS createUserName,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\ttmd.update_time AS updateTime,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\ttmd.update_user AS updateUser,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\ttmd.update_user_name AS updateUserName,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\ttmd.drug_sku AS drugSku,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\ttmd.drug_num AS drugNum,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\ttmd.use_num AS useNum,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\ttmd.use_way AS useWay,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\ttmd.use_rate AS useRate,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\ttmd.use_dose AS useDose,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\ttmd.use_way_add AS useWayAdd,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\ttmd.org_code AS orgCode,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\ttmd.org_name AS orgName\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "FROM\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\tt_mediicinecabinet_inventory tmi\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "LEFT JOIN t_mediicine_drugs tmd ON tmi.barcode = tmd.id"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String,Object>> list=null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        list = hibenateUtils.createSQLQuery(sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for (Map<String, Object> stringObjectMap : list) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sencordSql += " where tmi.id_device = " + stringObjectMap.get("id"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<Map<String, Object>> childList = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            childList = hibenateUtils.createSQLQuery(sencordSql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (childList != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                for (Map<String, Object> objectMap : childList) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    objectMap.put("upInventory", Integer.parseInt(stringObjectMap.get("cargoCapacity").toString()) - Integer.parseInt(objectMap.get("qty").toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                stringObjectMap.put("children", childList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.put("response", ConstantUtils.SUCCESS); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.put("msg",list); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				} 
			 |