|
@ -782,6 +782,16 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
// inventory.setNum(copyInventory.getNum());
|
|
|
// inventory.setShelfStatus(copyInventory.getShelfStatus());
|
|
|
inventory.setState("20");
|
|
|
//副货道内容操作-start-------》bug:13570
|
|
|
inventory.setQty("0");
|
|
|
inventory.setDrugName(null);
|
|
|
inventory.setDrugCode(null);
|
|
|
inventory.setOrgCode(null);
|
|
|
inventory.setPrice(null);
|
|
|
//额定库存
|
|
|
inventory.setRatedInventory(0);
|
|
|
inventory.setShelfStatus("0");
|
|
|
//内容操作end
|
|
|
inventoryDao.save(inventory);
|
|
|
}
|
|
|
}
|
|
@ -2494,6 +2504,219 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public JSONObject getDeviceListByReplenishEr(String content,String networkStatus, String community,
|
|
|
String saleStatus,String equType,String userIds, int page, int size) throws Exception {
|
|
|
JSONObject result = new JSONObject();
|
|
|
if (StringUtils.isEmpty(userIds)) {
|
|
|
throw new Exception("未选择补货员");
|
|
|
}
|
|
|
String belongCommunitys = "";
|
|
|
//统计补货员数量
|
|
|
int length = 0;
|
|
|
List<String> communityList = new ArrayList<>();
|
|
|
for (String userId : userIds.split(",")) {
|
|
|
if (!StringUtils.isEmpty(userId)) {
|
|
|
length++;
|
|
|
String sql = "SELECT DISTINCT\n" +
|
|
|
"\t(hospital)\n" +
|
|
|
"FROM\n" +
|
|
|
"\twlyy_user_area\n" +
|
|
|
"WHERE\n" +
|
|
|
"\tuser_id = '" + userId + "'";
|
|
|
List<Map<String, Object>> communitys = null;
|
|
|
communitys = hibenateUtils.createSQLQuery(sql);
|
|
|
List<String> tempList = new ArrayList<>();
|
|
|
if (communitys != null) {
|
|
|
for (Map<String, Object> stringObjectMap : communitys) {
|
|
|
if (stringObjectMap != null && !StringUtils.isEmpty(stringObjectMap.get("hospital") + "")) {
|
|
|
if (tempList.indexOf(stringObjectMap.get("hospital") + "") == -1) {
|
|
|
tempList.add(stringObjectMap.get("hospital") + "");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (communityList.size() == 0) {
|
|
|
communityList.addAll(tempList);
|
|
|
} else {
|
|
|
communityList.retainAll(tempList);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (communityList.size() == 0) {
|
|
|
if (length > 1) {
|
|
|
throw new Exception("补货员之间不存在交叉社区");
|
|
|
} else {
|
|
|
throw new Exception("补货员未分配社区");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
String conditionSql = "AND ',"+ String.join(",", communityList) +",' LIKE CONCAT('%,',t.belong_community,',%')\n";
|
|
|
String sql = "";
|
|
|
{
|
|
|
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\n" +
|
|
|
"WHERE 1=1 AND t.del = 1\n";
|
|
|
}
|
|
|
if (!StringUtils.isEmpty(content)) {
|
|
|
conditionSql += "AND CONCAT(IFNULL(t.`equ_num`, ''), IFNULL(t.`equ_name`, '')) like '%" + content +"%'\n";
|
|
|
}
|
|
|
if (!StringUtils.isEmpty(networkStatus)) {
|
|
|
conditionSql += "AND t.network_status = '" + networkStatus +"'\n";
|
|
|
}
|
|
|
if (!StringUtils.isEmpty(community)) {
|
|
|
conditionSql += "AND t.belong_community = '" + community +"'\n";
|
|
|
}
|
|
|
if (!StringUtils.isEmpty(saleStatus)) {
|
|
|
conditionSql += "AND t.sale_status = '" + saleStatus +"'\n";
|
|
|
}
|
|
|
if (!StringUtils.isEmpty(equType)) {
|
|
|
conditionSql += "AND t.equ_type = '" + equType +"'\n";
|
|
|
}
|
|
|
conditionSql += "AND t.belong_community IS NOT NULL\n";
|
|
|
sql = sql + conditionSql;
|
|
|
List<Map<String, Object>> deviceList = null;
|
|
|
deviceList = hibenateUtils.createSQLQuery(sql, page, size);
|
|
|
Map<String, String> equTypeMap = new HashMap<>();
|
|
|
equTypeMap.put("1", "测试类型1");
|
|
|
equTypeMap.put("2", "测试类型2");
|
|
|
equTypeMap.put("3", "测试类型3");
|
|
|
for (Map<String, Object> stringObjectMap : deviceList) {
|
|
|
if(!StringUtils.isEmpty(stringObjectMap.get("equType"))){
|
|
|
stringObjectMap.put("equTypeName", equTypeMap.get(stringObjectMap.get("equType")));
|
|
|
}
|
|
|
if(!StringUtils.isEmpty(stringObjectMap.get("networkStatus"))){
|
|
|
if ("1".equals(stringObjectMap.get("networkStatus").toString())) {
|
|
|
stringObjectMap.put("networkStatusName", "在线");
|
|
|
}
|
|
|
if ("0".equals(stringObjectMap.get("networkStatus").toString())) {
|
|
|
stringObjectMap.put("networkStatusName", "离线");
|
|
|
}
|
|
|
}
|
|
|
if(!StringUtils.isEmpty(stringObjectMap.get("saleStatus"))){
|
|
|
if ("1".equals(stringObjectMap.get("saleStatus").toString())) {
|
|
|
stringObjectMap.put("saleStatusName", "在售");
|
|
|
}
|
|
|
if ("2".equals(stringObjectMap.get("saleStatus").toString())) {
|
|
|
stringObjectMap.put("saleStatusName", "停售");
|
|
|
}
|
|
|
if ("3".equals(stringObjectMap.get("saleStatus").toString())) {
|
|
|
stringObjectMap.put("saleStatusName", "故障");
|
|
|
}
|
|
|
}
|
|
|
if(!StringUtils.isEmpty(stringObjectMap.get("cardStatus"))){
|
|
|
if ("1".equals(stringObjectMap.get("cardStatus").toString())) {
|
|
|
stringObjectMap.put("cardStatusName", "正常");
|
|
|
}
|
|
|
if ("2".equals(stringObjectMap.get("cardStatus").toString())) {
|
|
|
stringObjectMap.put("cardStatusName", "到期");
|
|
|
}
|
|
|
if ("3".equals(stringObjectMap.get("cardStatus").toString())) {
|
|
|
stringObjectMap.put("cardStatusName", "未知");
|
|
|
}
|
|
|
}
|
|
|
String tempSql = "SELECT\n" +
|
|
|
"\tifnull(sum(t.qty), 0) AS qty\n" +
|
|
|
"FROM\n" +
|
|
|
"\tt_mediicinecabinet_inventory t\n" +
|
|
|
"WHERE\n" +
|
|
|
"\tt.id_device = '"+ stringObjectMap.get("id") + "" +"'\n" +
|
|
|
"AND (t.state = '1' OR t.state = '21')\n" +
|
|
|
"AND t.shelf_status = '1'";
|
|
|
Map<String, Object> tempMap = jdbcTemplate.queryForMap(tempSql);
|
|
|
int inStock = 0;
|
|
|
if (tempMap != null) {
|
|
|
if (tempMap.get("qty") != null) {
|
|
|
inStock = (int) Double.parseDouble(tempMap.get("qty") + "");
|
|
|
}
|
|
|
}
|
|
|
//在架库存数
|
|
|
stringObjectMap.put("shangPinKuCun", inStock);
|
|
|
//商品庫存
|
|
|
// Integer inventoryNum = inventoryDao.sumInventoryWithEquNum(stringObjectMap.get("equNum")+"", "1", "21");
|
|
|
String tempSqlTwo = "SELECT\n" +
|
|
|
"\tifnull(\n" +
|
|
|
"\t\t(\n" +
|
|
|
"\t\t\tSELECT\n" +
|
|
|
"\t\t\t\tsum(qty) AS qty\n" +
|
|
|
"\t\t\tFROM\n" +
|
|
|
"\t\t\t\tt_mediicinecabinet_inventory\n" +
|
|
|
"\t\t\tWHERE\n" +
|
|
|
"\t\t\t\tequ_num = '"+stringObjectMap.get("equNum")+""+"'\n" +
|
|
|
"\t\t\tAND (state = '1' OR state = '21')\n" +
|
|
|
"\t\t\tAND drug_code IS NOT NULL\n" +
|
|
|
"\t\t\tAND org_code IS NOT NULL\n" +
|
|
|
"\t\t),\n" +
|
|
|
"\t\t0\n" +
|
|
|
"\t) AS qty";
|
|
|
Map<String, Object> tempMapTwo = jdbcTemplate.queryForMap(tempSqlTwo);
|
|
|
Integer inventoryNum = 0;
|
|
|
if (tempMapTwo != null) {
|
|
|
if (tempMapTwo.get("qty") != null) {
|
|
|
inventoryNum = (int) Double.parseDouble(tempMapTwo.get("qty") + "");
|
|
|
}
|
|
|
}
|
|
|
if(inventoryNum == null) inventoryNum = 0;
|
|
|
stringObjectMap.put("inventoryNum", inventoryNum);
|
|
|
stringObjectMap.put("warningNum", getEarlyWaringNum(stringObjectMap.get("equNum") + ""));
|
|
|
|
|
|
}
|
|
|
String countSql = " select " +
|
|
|
" COUNT(DISTINCT (t.id)) as count " +
|
|
|
" from " +
|
|
|
" t_mediicine_device t " +
|
|
|
" where " +
|
|
|
" 1=1 and t.del = 1 " +
|
|
|
conditionSql;
|
|
|
Logger.getAnonymousLogger().info("finalCountSql="+countSql);
|
|
|
int count = jdbcTemplate.queryForObject(countSql,Integer.class);
|
|
|
|
|
|
result.put("count", count);
|
|
|
result.put("msg", JavaBeanUtils.getInstance().mapListJson(deviceList));
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
public JSONObject getDeviceInventoryRecordListWithUserId(String type,String deviceId, String userId, int page, int size) throws Exception {
|
|
|
JSONObject result = new JSONObject();
|
|
|
|