|
@ -46,6 +46,9 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
@Autowired
|
|
@Autowired
|
|
private MedicineDeviceDeliveryDao deviceDeliveryDao;
|
|
private MedicineDeviceDeliveryDao deviceDeliveryDao;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
private MediicinecabinetInventoryDao inventoryDao;
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private ObjectMapper objectMapper;
|
|
private ObjectMapper objectMapper;
|
|
|
|
|
|
@ -61,8 +64,6 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
@Autowired
|
|
@Autowired
|
|
private HibenateUtils hibenateUtils;
|
|
private HibenateUtils hibenateUtils;
|
|
|
|
|
|
@Autowired
|
|
|
|
private MediicinecabinetInventoryDao inventoryDao;
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private MediicinedrugsDao mediicinedrugsDao;
|
|
private MediicinedrugsDao mediicinedrugsDao;
|
|
@ -77,11 +78,34 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
result.put("response", ConstantUtils.FAIL);
|
|
result.put("response", ConstantUtils.FAIL);
|
|
return result.toJSONString();
|
|
return result.toJSONString();
|
|
}
|
|
}
|
|
|
|
String countSql = " select " +
|
|
|
|
" COUNT(DISTINCT (t.id)) as count " +
|
|
|
|
" from " +
|
|
|
|
" t_mediicine_device t " +
|
|
|
|
" where " +
|
|
|
|
" 1=1 and t.del = 1 and t.equ_num = ' " + deviceId + "' ";
|
|
|
|
int count = jdbcTemplate.queryForObject(countSql,Integer.class);
|
|
|
|
if (count > 0) {
|
|
|
|
result.put("msg","deviceId is exist");
|
|
|
|
result.put("response", ConstantUtils.FAIL);
|
|
|
|
return result.toJSONString();
|
|
|
|
}
|
|
Mediicinedevice mediicinedevice = new Mediicinedevice();
|
|
Mediicinedevice mediicinedevice = new Mediicinedevice();
|
|
mediicinedevice.setEquNum(deviceId);
|
|
mediicinedevice.setEquNum(deviceId);
|
|
mediicinedevice.setLayer(layer);
|
|
mediicinedevice.setLayer(layer);
|
|
mediicinedevice.setWayer(wayer);
|
|
mediicinedevice.setWayer(wayer);
|
|
mediicinedevice.setCargoCapacity("5");
|
|
mediicinedevice.setCargoCapacity("5");
|
|
|
|
mediicinedevice.setCapacity(String.valueOf(5 * Integer.parseInt(layer) * Integer.parseInt(wayer)));
|
|
|
|
mediicinedevice.setAisles(String.valueOf(Integer.parseInt(layer) * Integer.parseInt(wayer)));
|
|
|
|
//缺货状态0缺货
|
|
|
|
mediicinedevice.setStatus("0");
|
|
|
|
//停售状态
|
|
|
|
mediicinedevice.setSaleStatus("2");
|
|
|
|
//网络状态
|
|
|
|
mediicinedevice.setNetworkStatus("1");
|
|
|
|
mediicinedevice.setRegDate(new Date());
|
|
|
|
mediicinedevice.setEquType("03");
|
|
|
|
mediicinedevice.setDel("1");
|
|
deviceDao.save(mediicinedevice);
|
|
deviceDao.save(mediicinedevice);
|
|
for (int i = 0; i < Integer.parseInt(layer); i++) {
|
|
for (int i = 0; i < Integer.parseInt(layer); i++) {
|
|
for (int i1 = 0; i1 < Integer.parseInt(wayer); i1++) {
|
|
for (int i1 = 0; i1 < Integer.parseInt(wayer); i1++) {
|
|
@ -1278,7 +1302,7 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* 获取缺货设备,夹带userId,用于数据隔离
|
|
|
|
|
|
* 获取缺货设备列表,夹带userId,用于数据隔离
|
|
* @param userId
|
|
* @param userId
|
|
* @param content
|
|
* @param content
|
|
* @return
|
|
* @return
|
|
@ -1359,14 +1383,10 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
" t_mediicine_device AS t\n" +
|
|
" t_mediicine_device AS t\n" +
|
|
"WHERE\n" +
|
|
"WHERE\n" +
|
|
"t.del = 1 AND \n" +
|
|
"t.del = 1 AND \n" +
|
|
|
|
"CONCAT(t.equ_num, t.equ_name) like '" + content +"' AND \n" +
|
|
"t.`status` = 0 and ',"+ deviceIds +",' LIKE CONCAT('%,',a.id,',%')";
|
|
"t.`status` = 0 and ',"+ deviceIds +",' LIKE CONCAT('%,',a.id,',%')";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
deviceList = hibenateUtils.createSQLQuery(sencodSql);
|
|
deviceList = hibenateUtils.createSQLQuery(sencodSql);
|
|
|
|
|
|
} else {
|
|
} else {
|
|
|
|
|
|
String belongCommunitys = "";
|
|
String belongCommunitys = "";
|
|
String sql = "";
|
|
String sql = "";
|
|
//市管理员
|
|
//市管理员
|
|
@ -1400,7 +1420,6 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
"t.user_id = '" + userId + "'\n" +
|
|
"t.user_id = '" + userId + "'\n" +
|
|
"AND t.del = 1";
|
|
"AND t.del = 1";
|
|
}
|
|
}
|
|
|
|
|
|
List<Map<String, Object>> list = hibenateUtils.createSQLQuery(sql);
|
|
List<Map<String, Object>> list = hibenateUtils.createSQLQuery(sql);
|
|
for (Map<String, Object> stringObjectMap : list) {
|
|
for (Map<String, Object> stringObjectMap : list) {
|
|
if (stringObjectMap.get("community") != null && !StringUtils.isEmpty(stringObjectMap.get("community").toString())) {
|
|
if (stringObjectMap.get("community") != null && !StringUtils.isEmpty(stringObjectMap.get("community").toString())) {
|
|
@ -1412,16 +1431,81 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
String sencodSql = "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\n" +
|
|
|
|
"WHERE\n" +
|
|
|
|
"t.del = 1 AND \n" +
|
|
|
|
"CONCAT(t.equ_num, t.equ_name) like '" + content +"' AND \n" +
|
|
|
|
"t.`status` = 0 and ',"+ belongCommunitys +",' LIKE CONCAT('%,',a.belong_community,',%')";
|
|
|
|
|
|
// sencodSql = "SELECT\n" +
|
|
|
|
// "\tcount(DISTINCT(id))\n" +
|
|
|
|
// "FROM\n" +
|
|
|
|
// "\tt_mediicine_device\n" +
|
|
|
|
// "WHERE\n" +
|
|
|
|
// "\tdel = 1\n" +
|
|
|
|
// "AND `status` = 0 and ',"+ belongCommunitys +",' LIKE CONCAT('%,',a.belong_community,',%')";
|
|
|
|
//
|
|
|
|
// outCount = jdbcTemplate.queryForObject(sencodSql, Integer.class);
|
|
|
|
|
|
|
|
|
|
deviceList = hibenateUtils.createSQLQuery(sencodSql);
|
|
|
|
}
|
|
|
|
for (Map<String, Object> stringObjectMap : deviceList) {
|
|
|
|
//库存
|
|
|
|
Integer qty = jdbcTemplate.queryForObject("SELECT\n" +
|
|
|
|
"\tsum(t.qty)\n" +
|
|
|
|
"FROM\n" +
|
|
|
|
"\tt_mediicinecabinet_inventory t\n" +
|
|
|
|
"WHERE\n" +
|
|
|
|
"\tt.id_device = '" + stringObjectMap.get("equNum") +"'\n" +
|
|
|
|
"AND t.shelf_status = 1", Integer.class);
|
|
|
|
|
|
|
|
stringObjectMap.put("daibuQty", Integer.parseInt(stringObjectMap.get("capacity").toString()) - qty);
|
|
|
|
stringObjectMap.put("xiajiaQty", jdbcTemplate.queryForObject("SELECT\n" +
|
|
|
|
"\tCOUNT(DISTINCT(id))\n" +
|
|
|
|
"FROM\n" +
|
|
|
|
"\tt_mediicinecabinet_inventory t\n" +
|
|
|
|
"WHERE\n" +
|
|
|
|
"\tt.id_device = ''\n" +
|
|
|
|
"AND t.shelf_status = 0", Integer.class));
|
|
|
|
Date buhuoDate = jdbcTemplate.queryForObject("SELECT\n" +
|
|
|
|
"\tcreate_time\n" +
|
|
|
|
"FROM\n" +
|
|
|
|
"\tt_mediicine_stockrecord_detail\n" +
|
|
|
|
"ORDER BY\n" +
|
|
|
|
"\tcreate_time DESC\n" +
|
|
|
|
"LIMIT 1", Date.class);
|
|
|
|
stringObjectMap.put("buhuoTime", DateUtil.dateToStr(buhuoDate, "yyyy-MM-dd HH:mm:ss" ));
|
|
}
|
|
}
|
|
|
|
|
|
result.put("response", ConstantUtils.SUCCESS);
|
|
result.put("response", ConstantUtils.SUCCESS);
|