|
@ -46,138 +46,6 @@ public class MedicineUserService extends BaseJpaService<Mediicineuser, Mediicine
|
|
|
private HibenateUtils hibenateUtils;
|
|
|
|
|
|
|
|
|
// /**
|
|
|
// * 新增设备
|
|
|
// * @param jsonData
|
|
|
// * @return
|
|
|
// */
|
|
|
// @Transactional(rollbackFor = Exception.class)
|
|
|
// public String createDevice(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 device 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();
|
|
|
//// }
|
|
|
// Mediicinedevice mediicinedevice = null;
|
|
|
// try {
|
|
|
// mediicinedevice = objectMapper.readValue(device.toJSONString(), Mediicinedevice.class);
|
|
|
// } catch (IOException e) {
|
|
|
// result.put("msg", "convert device jsonObject to BaseDoctorDO failed," + e.getCause());
|
|
|
// result.put("response", ConstantUtils.FAIL);
|
|
|
// return result.toJSONString();
|
|
|
// } catch (Exception e) {
|
|
|
// result.put("msg", "convert device birth failed," + e.getCause());
|
|
|
// result.put("response", ConstantUtils.FAIL);
|
|
|
// return result.toJSONString();
|
|
|
// }
|
|
|
// this.save(mediicinedevice);
|
|
|
// result.put("response",ConstantUtils.SUCCESS);
|
|
|
// result.put("msg",mediicinedevice);
|
|
|
// return result.toJSONString();
|
|
|
// }
|
|
|
|
|
|
// /**
|
|
|
// * 修改设备
|
|
|
// * @param jsonData
|
|
|
// * @return
|
|
|
// */
|
|
|
// @Transactional(rollbackFor = Exception.class)
|
|
|
// public String updateDevice(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 device of jsonData is null");
|
|
|
// result.put("response", ConstantUtils.FAIL);
|
|
|
// return result.toJSONString();
|
|
|
// }
|
|
|
// String orgCode="";
|
|
|
// //判断设备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();
|
|
|
// }
|
|
|
// Mediicinedevice mediicinedevice = null;
|
|
|
// try {
|
|
|
// mediicinedevice = objectMapper.readValue(device.toJSONString(), Mediicinedevice.class);
|
|
|
// } catch (IOException e) {
|
|
|
// result.put("msg", "convert device jsonObject to BaseDoctorDO failed," + e.getCause());
|
|
|
// result.put("response", ConstantUtils.FAIL);
|
|
|
// return result.toJSONString();
|
|
|
// } catch (Exception e) {
|
|
|
// result.put("msg", "convert device birth failed," + e.getCause());
|
|
|
// result.put("response", ConstantUtils.FAIL);
|
|
|
// return result.toJSONString();
|
|
|
// }
|
|
|
// this.save(mediicinedevice);
|
|
|
// result.put("response",ConstantUtils.SUCCESS);
|
|
|
// result.put("msg",mediicinedevice);
|
|
|
// return result.toJSONString();
|
|
|
// }
|
|
|
|
|
|
|
|
|
// @Transactional(rollbackFor = Exception.class)
|
|
|
// public String updateDeviceCommunity(String deviceId, String communityId, String community){
|
|
|
// JSONObject result = new JSONObject();
|
|
|
// if(StringUtils.isEmpty(deviceId) && StringUtils.isEmpty(communityId)){
|
|
|
// result.put("msg","deviceId and communityId is null");
|
|
|
// result.put("response", ConstantUtils.FAIL);
|
|
|
// return result.toJSONString();
|
|
|
// }
|
|
|
// Mediicinedevice mediicinedevice = deviceDao.findOne(deviceId);
|
|
|
// if (mediicinedevice == null) {
|
|
|
// result.put("msg","device doesn't exist");
|
|
|
// result.put("response", ConstantUtils.FAIL);
|
|
|
// return result.toJSONString();
|
|
|
// }
|
|
|
// mediicinedevice.setBelongCommunity(communityId);
|
|
|
// mediicinedevice.setCommunity(community);
|
|
|
// this.save(mediicinedevice);
|
|
|
// result.put("response",ConstantUtils.SUCCESS);
|
|
|
// result.put("msg",mediicinedevice);
|
|
|
// return result.toJSONString();
|
|
|
// }
|
|
|
|
|
|
// @Transactional(rollbackFor = Exception.class)
|
|
|
// public String updateDeviceAddress(String deviceId, String address){
|
|
|
// JSONObject result = new JSONObject();
|
|
|
// if(StringUtils.isEmpty(deviceId) && StringUtils.isEmpty(address)){
|
|
|
// result.put("msg","deviceId and address is null");
|
|
|
// result.put("response", ConstantUtils.FAIL);
|
|
|
// return result.toJSONString();
|
|
|
// }
|
|
|
// Mediicinedevice mediicinedevice = deviceDao.findOne(deviceId);
|
|
|
// if (mediicinedevice == null) {
|
|
|
// result.put("msg","device doesn't exist");
|
|
|
// result.put("response", ConstantUtils.FAIL);
|
|
|
// return result.toJSONString();
|
|
|
// }
|
|
|
// mediicinedevice.setDeliveryAddress(address);
|
|
|
// this.save(mediicinedevice);
|
|
|
// result.put("response",ConstantUtils.SUCCESS);
|
|
|
// result.put("msg",mediicinedevice);
|
|
|
// return result.toJSONString();
|
|
|
// }
|
|
|
|
|
|
/**
|
|
|
* 分页查询补货员信息
|
|
|
* @param content
|
|
@ -190,31 +58,72 @@ public class MedicineUserService extends BaseJpaService<Mediicineuser, Mediicine
|
|
|
public JSONObject queryUserListFullInfo(String content,int page, int size,String wechatId) throws Exception {
|
|
|
JSONObject result = new JSONObject();
|
|
|
String sql = "SELECT\n" +
|
|
|
" t.id AS id,\n" +
|
|
|
" t.account AS account,\n" +
|
|
|
" t.belong_community AS belongCommunity,\n" +
|
|
|
" t.bir_date AS birDate,\n" +
|
|
|
" t.confirm_password AS confirmPassword,\n" +
|
|
|
" t.contact_info AS contactInfo,\n" +
|
|
|
" t.`name` AS `name`,\n" +
|
|
|
" t.`password` AS `password`,\n" +
|
|
|
" t.res_med_cabinet AS resMedCabinet,\n" +
|
|
|
" t.res_pon_area AS resPonArea,\n" +
|
|
|
" t.role AS role,\n" +
|
|
|
" t.sex AS sex,\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" +
|
|
|
"\tb.id AS id,\n" +
|
|
|
"\tb.create_time AS createTime,\n" +
|
|
|
"\tb.create_user AS createUser,\n" +
|
|
|
"\tb.create_user_name AS createUserName,\n" +
|
|
|
"\tb.update_time AS updateTime,\n" +
|
|
|
"\tb.update_user AS updateUser,\n" +
|
|
|
"\tb.update_user_name AS updateUserName,\n" +
|
|
|
"\tb.username AS username,\n" +
|
|
|
"\tb.`password` AS `password`,\n" +
|
|
|
"\tb.salt AS salt,\n" +
|
|
|
"\tb.`name` AS `name`,\n" +
|
|
|
"\tb.gender AS gender,\n" +
|
|
|
"\tb.idcard AS idcard,\n" +
|
|
|
"\tb.mobile AS mobile,\n" +
|
|
|
"\tb.ak AS ak,\n" +
|
|
|
"\tb.email AS email,\n" +
|
|
|
"\tb.enabled AS enabled,\n" +
|
|
|
"\tb.locked AS locked,\n" +
|
|
|
"\tb.locked_date AS lockedDate,\n" +
|
|
|
"\tb.login_date AS loginDate,\n" +
|
|
|
"\tb.saas_id AS saasId,\n" +
|
|
|
"\tb.login_failure_count AS loginFailureCount,\n" +
|
|
|
"\tb.last_login_failure_time AS lastLoginFailureTime,\n" +
|
|
|
"\tb.role_id AS roleId\n" +
|
|
|
"FROM\n" +
|
|
|
" t_mediicine_user AS t\n" +
|
|
|
"\tbase_user b\n" +
|
|
|
"WHERE\n" +
|
|
|
" 1=1\n";
|
|
|
"\tb.role_id IN (\n" +
|
|
|
"\t\tSELECT\n" +
|
|
|
"\t\t\tid\n" +
|
|
|
"\t\tFROM\n" +
|
|
|
"\t\t\tbase_role\n" +
|
|
|
"\t\tWHERE\n" +
|
|
|
"\t\t\tcode = 'replenisher'\n" +
|
|
|
"\t\t\tAND status = 1\n" +
|
|
|
"\t)\n" +
|
|
|
"\tAND b.enabled = 1\n" +
|
|
|
"\tAND b.locked = 0\n";
|
|
|
|
|
|
// String sql = "SELECT\n" +
|
|
|
// " t.id AS id,\n" +
|
|
|
// " t.account AS account,\n" +
|
|
|
// " t.belong_community AS belongCommunity,\n" +
|
|
|
// " t.bir_date AS birDate,\n" +
|
|
|
// " t.confirm_password AS confirmPassword,\n" +
|
|
|
// " t.contact_info AS contactInfo,\n" +
|
|
|
// " t.`name` AS `name`,\n" +
|
|
|
// " t.`password` AS `password`,\n" +
|
|
|
// " t.res_med_cabinet AS resMedCabinet,\n" +
|
|
|
// " t.res_pon_area AS resPonArea,\n" +
|
|
|
// " t.role AS role,\n" +
|
|
|
// " t.sex AS sex,\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_mediicine_user AS t\n" +
|
|
|
// "WHERE\n" +
|
|
|
// " 1=1\n";
|
|
|
String conditionSql = "";
|
|
|
if (!StringUtils.isEmpty(content)){
|
|
|
conditionSql += " AND CONCAT(t.account, t.`name`) like '%"+ content +"%'";
|
|
|
// conditionSql += " AND CONCAT(t.account, t.`name`) like '%"+ content +"%'";
|
|
|
conditionSql += "\tAND CONCAT(b.mobile,b.name) like '%"+ content +"%'";
|
|
|
}
|
|
|
|
|
|
sql = sql + conditionSql;
|
|
@ -232,11 +141,11 @@ public class MedicineUserService extends BaseJpaService<Mediicineuser, Mediicine
|
|
|
stringObjectMap.put("deviceQty", deviceDao.countAll());
|
|
|
}
|
|
|
String countSql = " select " +
|
|
|
" COUNT(DISTINCT (t.id)) as count " +
|
|
|
" COUNT(DISTINCT (b.id)) as count " +
|
|
|
" from " +
|
|
|
" t_mediicine_user t " +
|
|
|
" where " +
|
|
|
" 1=1 " +
|
|
|
" base_user b " +
|
|
|
" where 1=1 and b.role_id in (select id from base_role where code = 'replenisher' and status = 1 )" +
|
|
|
" and b.enabled = 1 and b.locked = 0 " +
|
|
|
conditionSql;
|
|
|
Logger.getAnonymousLogger().info("finalCountSql="+countSql);
|
|
|
int count = jdbcTemplate.queryForObject(countSql,Integer.class);
|
|
@ -341,728 +250,6 @@ public class MedicineUserService extends BaseJpaService<Mediicineuser, Mediicine
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public JSONObject getDevicesByMoreContent(String content, String equClass, String belongCommunity,
|
|
|
String networkStatus, String saleStatus, String machineCode, String deviceType, String equArea, String del, String status,String deliveryAddress, String wechatId) 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" +
|
|
|
" t.layer as layer,\n" +
|
|
|
" t.wayer as wayer\n" +
|
|
|
"FROM\n" +
|
|
|
" t_mediicine_device AS t where 1=1\n";
|
|
|
|
|
|
String conditionSql = "";
|
|
|
if (!StringUtils.isEmpty(content)){
|
|
|
conditionSql += " and CONCAT(t.equ_name, t.equ_num) like '%" + content + "%'";
|
|
|
}
|
|
|
if (!StringUtils.isEmpty(equClass)){
|
|
|
conditionSql += " and t.equ_class = '"+equClass + "'";
|
|
|
}
|
|
|
if (!StringUtils.isEmpty(belongCommunity)){
|
|
|
conditionSql += " and t.belong_community = '" + belongCommunity + "'";
|
|
|
}
|
|
|
if (!StringUtils.isEmpty(networkStatus)){
|
|
|
conditionSql += " and t.network_status = '" + networkStatus + "'";
|
|
|
}
|
|
|
if (!StringUtils.isEmpty(saleStatus)){
|
|
|
conditionSql += " and t.sale_status = '" + saleStatus + "'";
|
|
|
}
|
|
|
if (!StringUtils.isEmpty(machineCode)){
|
|
|
conditionSql += " and t.machine_code like '%" + machineCode + "%'";
|
|
|
}
|
|
|
if (!StringUtils.isEmpty(deviceType)){
|
|
|
conditionSql += " and t.equ_type = '"+deviceType + "'";
|
|
|
}
|
|
|
|
|
|
if (!StringUtils.isEmpty(equArea)){
|
|
|
conditionSql += " and t.equ_area = '"+equArea + "'";
|
|
|
}
|
|
|
if (!StringUtils.isEmpty(del)){
|
|
|
conditionSql += " and t.del = '"+del + "'";
|
|
|
}
|
|
|
if (!StringUtils.isEmpty(status)){
|
|
|
conditionSql += " and t.`status` = '"+status + "'";
|
|
|
}
|
|
|
if (!StringUtils.isEmpty(deliveryAddress)){
|
|
|
conditionSql += " and t.delivery_address = '"+deliveryAddress + "'";
|
|
|
}
|
|
|
sql = sql + conditionSql;
|
|
|
|
|
|
List<Map<String,Object>> list=null;
|
|
|
list = hibenateUtils.createSQLQuery(sql);
|
|
|
for (Map<String, Object> stringObjectMap : list) {
|
|
|
if(!StringUtils.isEmpty(stringObjectMap.get("status"))){
|
|
|
if ("1".equals(stringObjectMap.get("status").toString())) {
|
|
|
stringObjectMap.put("statusName", "在线");
|
|
|
}
|
|
|
if ("0".equals(stringObjectMap.get("status").toString())) {
|
|
|
stringObjectMap.put("statusName", "离线");
|
|
|
}
|
|
|
if ("-1".equals(stringObjectMap.get("status").toString())) {
|
|
|
stringObjectMap.put("statusName", "异常");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
String countSql = " select " +
|
|
|
" COUNT(DISTINCT (t.id)) as count " +
|
|
|
" from " +
|
|
|
" t_mediicine_device t " +
|
|
|
" where " +
|
|
|
" 1=1 " +
|
|
|
conditionSql;
|
|
|
Logger.getAnonymousLogger().info("finalCountSql="+countSql);
|
|
|
int count = jdbcTemplate.queryForObject(countSql,Integer.class);
|
|
|
for (Map<String,Object> map:list){
|
|
|
|
|
|
}
|
|
|
result.put("count", count);
|
|
|
result.put("msg", JavaBeanUtils.getInstance().mapListJson(list));
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 根据人员id,查询与之绑定的设备
|
|
|
* @param userId
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public JSONObject getDevices(String userId) throws Exception {
|
|
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
if(StringUtils.isEmpty(userId)){
|
|
|
result.put("msg","parameter userId is null ");
|
|
|
result.put("response",ConstantUtils.FAIL);
|
|
|
return result;
|
|
|
}
|
|
|
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" +
|
|
|
" t.layer as layer,\n" +
|
|
|
" t.wayer as wayer\n" +
|
|
|
"FROM\n" +
|
|
|
" t_mediicine_device AS t where t.del = 1\n";
|
|
|
|
|
|
// String conditionSql = " t.id in (select du.device_id from t_mediicine_device_user du where del = 1 and ',"+userId+",' LIKE CONCAT('%,',du.user_id,',%'))";
|
|
|
String conditionSql = " and t.id in (select du.device_id from t_mediicine_device_user du where del = 1 and du.user_id = '" + userId + "'";
|
|
|
|
|
|
sql = sql + conditionSql;
|
|
|
|
|
|
List<Map<String,Object>> list=null;
|
|
|
list = hibenateUtils.createSQLQuery(sql);
|
|
|
|
|
|
for (Map<String, Object> stringObjectMap : list) {
|
|
|
if(!StringUtils.isEmpty(stringObjectMap.get("status"))){
|
|
|
if ("1".equals(stringObjectMap.get("status").toString())) {
|
|
|
stringObjectMap.put("statusName", "在线");
|
|
|
}
|
|
|
if ("0".equals(stringObjectMap.get("status").toString())) {
|
|
|
stringObjectMap.put("statusName", "离线");
|
|
|
}
|
|
|
if ("-1".equals(stringObjectMap.get("status").toString())) {
|
|
|
stringObjectMap.put("statusName", "异常");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
result.put("msg", JavaBeanUtils.getInstance().mapListJson(list));
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 根据设备id,查询与之绑定的补货员
|
|
|
* @param deviceId
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public JSONObject getUsers(String deviceId) throws Exception {
|
|
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
if(StringUtils.isEmpty(deviceId)){
|
|
|
result.put("msg","parameter deviceId is null ");
|
|
|
result.put("response",ConstantUtils.FAIL);
|
|
|
return result;
|
|
|
}
|
|
|
String sql = "SELECT\n" +
|
|
|
" t.id AS id,\n" +
|
|
|
" t.account AS account,\n" +
|
|
|
" t.belong_community AS belongCommunity,\n" +
|
|
|
" t.bir_date AS birDate,\n" +
|
|
|
" t.confirm_password AS confirmPassword,\n" +
|
|
|
" t.contact_info AS contactInfo,\n" +
|
|
|
" t.`name` AS `name`,\n" +
|
|
|
" t.`password` AS `password`,\n" +
|
|
|
" t.res_med_cabinet AS resMedCabinet,\n" +
|
|
|
" t.res_pon_area AS resPonArea,\n" +
|
|
|
" t.role AS role,\n" +
|
|
|
" t.sex AS sex,\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_mediicine_user AS t where\n";
|
|
|
|
|
|
// String conditionSql = " t.id in (select du.user_id from t_mediicine_device_user du where del = 1 and ',"+deviceId+",' LIKE CONCAT('%,',du.device_id,',%'))";
|
|
|
String conditionSql = " t.id in (select du.user_id from t_mediicine_device_user du where del = 1 and du.device_id = '" + deviceId + "'";
|
|
|
|
|
|
sql = sql + conditionSql;
|
|
|
|
|
|
List<Map<String,Object>> list=null;
|
|
|
list = hibenateUtils.createSQLQuery(sql);
|
|
|
|
|
|
for (Map<String, Object> stringObjectMap : list) {
|
|
|
|
|
|
}
|
|
|
result.put("msg", JavaBeanUtils.getInstance().mapListJson(list));
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
// public JSONObject getOneDeviceInfo(String deviceId) throws Exception{
|
|
|
// JSONObject result = new JSONObject();
|
|
|
// if(StringUtils.isEmpty(deviceId)){
|
|
|
// result.put("msg","parameter deviceId is null ");
|
|
|
// result.put("response",ConstantUtils.FAIL);
|
|
|
// return result;
|
|
|
// }
|
|
|
// Mediicinedevice device = userDao.findOne(deviceId);
|
|
|
// if(null == device){
|
|
|
// result.put("msg","设备不存在:" + deviceId);
|
|
|
// result.put("response",ConstantUtils.FAIL);
|
|
|
// return result;
|
|
|
// }
|
|
|
// JSONObject jsonObject = new JSONObject();
|
|
|
// jsonObject.put("device",device);
|
|
|
// result.put("response",ConstantUtils.SUCCESS);
|
|
|
// result.put("msg",jsonObject);
|
|
|
// return result;
|
|
|
// }
|
|
|
|
|
|
|
|
|
// /**
|
|
|
// * 获取设备总数
|
|
|
// * @return
|
|
|
// * @throws Exception
|
|
|
// */
|
|
|
// public JSONObject countAll() throws Exception{
|
|
|
// JSONObject result = new JSONObject();
|
|
|
//
|
|
|
// JSONObject jsonObject = new JSONObject();
|
|
|
// jsonObject.put("count",deviceDao.countAll());
|
|
|
// result.put("response",ConstantUtils.SUCCESS);
|
|
|
// result.put("msg",jsonObject);
|
|
|
// return result;
|
|
|
// }
|
|
|
|
|
|
/**
|
|
|
* 获取设备总数
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public JSONObject countAll() throws Exception {
|
|
|
JSONObject result = new JSONObject();
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
|
|
|
String sql = "select count(1) from t_mediicine_device a where a.del = 1";
|
|
|
int count = jdbcTemplate.queryForObject(sql,Integer.class);
|
|
|
jsonObject.put("count", count);
|
|
|
result.put("response",ConstantUtils.SUCCESS);
|
|
|
result.put("msg", jsonObject);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
//获取当前设备数量
|
|
|
// public long countAll() {
|
|
|
// return deviceDao.countAll();
|
|
|
// }
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 获取当前设备数量
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public JSONObject countOnline() throws Exception{
|
|
|
JSONObject result = new JSONObject();
|
|
|
String sql = "select count(1) from t_mediicine_device a where a.del = 1 and a.status = 1";
|
|
|
int count = jdbcTemplate.queryForObject(sql,Integer.class);
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
jsonObject.put("count",count);
|
|
|
result.put("response",ConstantUtils.SUCCESS);
|
|
|
result.put("msg",jsonObject);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
//获取当前设备数量
|
|
|
// public long countOnline() {
|
|
|
// return deviceDao.countOnline();
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
public JSONObject saveDmMedicineDevice(String json) throws IOException {
|
|
|
JSONObject result = new JSONObject();
|
|
|
// MedicineDevice device = objectMapper.readValue(json,MedicineDevice.class);
|
|
|
// Integer deviceType = device.getMedicineDeviceType();
|
|
|
// String categoryCode = device.getCategoryCode();
|
|
|
// String name = device.getName();
|
|
|
// String model = device.getCategoryCode();
|
|
|
// String brands = device.getBrands();
|
|
|
// String photo =device.getPhoto();
|
|
|
// String isMultiUser = device.getIsMultiUser();
|
|
|
// if (null==deviceType||StringUtils.isBlank(categoryCode)||StringUtils.isBlank(name)||StringUtils.isBlank(model)||
|
|
|
// StringUtils.isBlank(brands)||StringUtils.isBlank(photo)||StringUtils.isBlank(isMultiUser)){
|
|
|
// result.put(ResponseContant.resultFlag,ResponseContant.fail);
|
|
|
// result.put(ResponseContant.resultMsg,"数据数据错误,必填字段为空");
|
|
|
// return result;
|
|
|
// }
|
|
|
|
|
|
// //判断型号是否重复
|
|
|
// MedicineDevice deviceTmp = deviceDao.findByModel(device.getModel());
|
|
|
// if (null!=deviceTmp){
|
|
|
// if (null==device.getId()){
|
|
|
// result.put(ResponseContant.resultFlag,ResponseContant.fail);
|
|
|
// result.put(ResponseContant.resultMsg,"设备型号已存在");
|
|
|
// return result;
|
|
|
// }else if (deviceTmp.getId().longValue()!=device.getId().longValue()){//
|
|
|
// result.put(ResponseContant.resultFlag,ResponseContant.fail);
|
|
|
// result.put(ResponseContant.resultMsg,"设备型号已存在");
|
|
|
// return result;
|
|
|
// }
|
|
|
// }
|
|
|
// if (null==device.getId()){
|
|
|
// device.setDel("1");
|
|
|
// }
|
|
|
// deviceDao.save(device);
|
|
|
// result.put(ResponseContant.resultFlag,ResponseContant.success);
|
|
|
// 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" +
|
|
|
"\tt.layer as layer,\n" +
|
|
|
"\tt.wayer as wayer\n" +
|
|
|
"FROM\n" +
|
|
|
"\tt_mediicine_device t\n" +
|
|
|
"LEFT JOIN t_mediicinecabinet_inventory tmi ON t.id = tmi.id_device\n" +
|
|
|
"WHERE 1=1 and t.del = 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);
|
|
|
for (Map<String, Object> stringObjectMap : list) {
|
|
|
if(!StringUtils.isEmpty(stringObjectMap.get("status"))){
|
|
|
if ("1".equals(stringObjectMap.get("status").toString())) {
|
|
|
stringObjectMap.put("statusName", "在线");
|
|
|
}
|
|
|
if ("0".equals(stringObjectMap.get("status").toString())) {
|
|
|
stringObjectMap.put("statusName", "离线");
|
|
|
}
|
|
|
if ("-1".equals(stringObjectMap.get("status").toString())) {
|
|
|
stringObjectMap.put("statusName", "异常");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
result.put("response", ConstantUtils.SUCCESS);
|
|
|
result.put("msg",list);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 获取所属id的缺货信息
|
|
|
* @param ids
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
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" +
|
|
|
" t.layer AS layer,\n" +
|
|
|
" t.wayer AS wayer\n" +
|
|
|
"FROM\n" +
|
|
|
" t_mediicine_device AS t WHERE t.del = 1 and ',"+ ids +",' LIKE CONCAT('%,',t.id,',%')";
|
|
|
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) {
|
|
|
String tempStr = "";
|
|
|
// tempStr = sencordSql + " where ',"+stringObjectMap.get("id")+",' LIKE CONCAT('%,',tmi.id_device,',%')";
|
|
|
tempStr = sencordSql + " WHERE tmi.id_device = '" + stringObjectMap.get("id").toString() + "'";
|
|
|
List<Map<String, Object>> childList = null;
|
|
|
childList = hibenateUtils.createSQLQuery(tempStr);
|
|
|
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;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 获取设备库存
|
|
|
* @param belongCommunity
|
|
|
* @param deviceId
|
|
|
* @param netStatus
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public JSONObject getDevInventory(String belongCommunity, String deviceId, String netStatus) 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" +
|
|
|
" t.layer AS layer,\n" +
|
|
|
" t.wayer AS wayer\n" +
|
|
|
"FROM\n" +
|
|
|
" t_mediicine_device AS t WHERE 1=1 and t.del = 1";
|
|
|
|
|
|
if (!StringUtils.isEmpty(deviceId)) {
|
|
|
sql += " AND t.id = '" + deviceId + "'";
|
|
|
}
|
|
|
if (!StringUtils.isEmpty(belongCommunity)) {
|
|
|
sql += " AND t.belong_community = '" + belongCommunity + "'";
|
|
|
}
|
|
|
if (!StringUtils.isEmpty(netStatus)) {
|
|
|
sql += " AND t.network_status = '" + netStatus + "'";
|
|
|
}
|
|
|
|
|
|
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) {
|
|
|
// String tempStr = sencordSql + " where ',"+stringObjectMap.get("id").toString()+",' LIKE CONCAT('%,',tmi.id_device,',%')";
|
|
|
String tempStr = sencordSql + " WHERE tmi.id_device = '" + stringObjectMap.get("id").toString() + "'";
|
|
|
List<Map<String, Object>> childList = null;
|
|
|
childList = hibenateUtils.createSQLQuery(tempStr);
|
|
|
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);
|
|
|
stringObjectMap.put("totalQty", childList.stream().reduce(0, (sum, p) -> sum += Integer.parseInt(p.get("qty").toString()), Integer::sum));
|
|
|
}
|
|
|
//历史订单数
|
|
|
String secondSql = "SELECT COUNT(DISTINCT(t.id)) FROM t_mediicine_order t WHERE t.shipping_equ = '" + stringObjectMap.get("id").toString() + "'";
|
|
|
stringObjectMap.put("orderQty", jdbcTemplate.queryForObject(secondSql, Integer.class));
|
|
|
//总销售额
|
|
|
secondSql = "SELECT SUM(t.amount) FROM t_mediicine_order t WHERE t.shipping_equ = '" + stringObjectMap.get("id").toString() + "'";
|
|
|
stringObjectMap.put("orderTotalAmount", jdbcTemplate.queryForObject(secondSql, Integer.class));
|
|
|
|
|
|
}
|
|
|
|
|
|
result.put("response", ConstantUtils.SUCCESS);
|
|
|
result.put("msg",list);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
}
|