|
@ -2357,7 +2357,23 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
//在架库存数
|
|
|
stringObjectMap.put("shangPinKuCun", inStock);
|
|
|
//商品庫存
|
|
|
Integer inventoryNum = inventoryDao.sumInventoryWithEquNum(stringObjectMap.get("equNum")+"", "1", "21");
|
|
|
// 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";
|
|
|
Integer inventoryNum = jdbcTemplate.queryForObject(tempSqlTwo, Integer.class);
|
|
|
if(inventoryNum == null) inventoryNum = 0;
|
|
|
stringObjectMap.put("inventoryNum", inventoryNum);
|
|
|
stringObjectMap.put("warningNum", getEarlyWaringNum(stringObjectMap.get("equNum") + ""));
|
|
@ -2597,7 +2613,24 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
//
|
|
|
List<Map<String, Integer>> drugIds = new ArrayList<>();
|
|
|
//设备中所有药品列表
|
|
|
List<Map<String, Object>> collect = inventoryDao.selectsomethingBysomeConditionWithEquNum(equNum, "1", "21");
|
|
|
String sql = "SELECT\n" +
|
|
|
"\tsum(qty) AS qty,\n" +
|
|
|
"\tdrug_id AS drugId,\n" +
|
|
|
"\tdrug_code AS drugCode,\n" +
|
|
|
"\torg_code AS orgCode,\n" +
|
|
|
"\tsum(rated_inventory) AS ratedInventory\n" +
|
|
|
"FROM\n" +
|
|
|
"\tt_mediicinecabinet_inventory\n" +
|
|
|
"WHERE\n" +
|
|
|
"\tequ_num = '"+equNum+"'\n" +
|
|
|
"AND (state = '1' OR state = '21')\n" +
|
|
|
"AND drug_code IS NOT NULL\n" +
|
|
|
"AND org_code IS NOT NULL\n" +
|
|
|
"GROUP BY\n" +
|
|
|
"\tdrug_code,\n" +
|
|
|
"\torg_code";
|
|
|
// List<Map<String, Object>> collect = inventoryDao.selectsomethingBysomeConditionWithEquNum(equNum, "1", "21");
|
|
|
List<Map<String, Object>> collect = hibenateUtils.createSQLQuery(sql);
|
|
|
Integer number = 0;
|
|
|
//获取了所有缺货的药品id
|
|
|
for (MedicineWarrayRule rule : rules) {
|
|
@ -3756,8 +3789,24 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
public void updateDeviceState(String cargoId) {
|
|
|
//包含原来药品信息
|
|
|
MediicinecabinetInventory inventory = inventoryDao.findOne(cargoId);
|
|
|
// List<MediicinecabinetInventory> list = inventoryDao.findMediicinecabinetInventoriesByIdDeviceAndStateInAndDrugCodeNotNullAndAndOrgCodeNotNull(inventory.getIdDevice(), new String[]{"1", "21"});
|
|
|
List<Map<String, Object>> collect = inventoryDao.selectsomethingBysomeCondition(inventory.getIdDevice(), "1", "21");
|
|
|
String sql = "SELECT\n" +
|
|
|
"\tsum(qty) AS qty,\n" +
|
|
|
"\tdrug_id AS drugId,\n" +
|
|
|
"\tdrug_code AS drugCode,\n" +
|
|
|
"\torg_code AS orgCode,\n" +
|
|
|
"\tsum(rated_inventory) AS ratedInventory\n" +
|
|
|
"FROM\n" +
|
|
|
"\tt_mediicinecabinet_inventory\n" +
|
|
|
"WHERE\n" +
|
|
|
"\tid_device = '"+inventory.getIdDevice()+"'\n" +
|
|
|
"AND (state = '1' OR state = '21')\n" +
|
|
|
"AND drug_code IS NOT NULL\n" +
|
|
|
"AND org_code IS NOT NULL\n" +
|
|
|
"GROUP BY\n" +
|
|
|
"\tdrug_code,\n" +
|
|
|
"\torg_code";
|
|
|
// List<Map<String, Object>> collect = inventoryDao.selectsomethingBysomeCondition(inventory.getIdDevice(), "1", "21");
|
|
|
List<Map<String, Object>> collect = hibenateUtils.createSQLQuery(sql);
|
|
|
// //药品变更
|
|
|
// if (drugChanged) {
|
|
|
// //变更的目标药品
|
|
@ -4602,10 +4651,55 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
// List<Map<String, Object>> collect = inventoryDao.selectsomethingBysomeCondition(deviceId, new String[]{"1", "21"});
|
|
|
List<Map<String, Object>> collect = hibenateUtils.createSQLQuery(sql);
|
|
|
for (Map<String, Object> stringObjectMap : collect) {
|
|
|
stringObjectMap.put("detail", inventoryDao.getMediicinecabinetInventoriesByOrgCodeAndDurgCode(
|
|
|
stringObjectMap.get("orgCode") + "",
|
|
|
stringObjectMap.get("drugCode") + "",
|
|
|
deviceId, "1", "21"));
|
|
|
String tempSql = "SELECT\n" +
|
|
|
"\ta.id AS id,\n" +
|
|
|
"\ta.id_device AS idDevice,\n" +
|
|
|
"\ta.num AS num,\n" +
|
|
|
"\ta.sku AS sku,\n" +
|
|
|
"\ta.state AS state,\n" +
|
|
|
"\ta.longtime AS longtime,\n" +
|
|
|
"\ta.drug_id AS drugId,\n" +
|
|
|
"\ta.drug_sku AS drugSku,\n" +
|
|
|
"\ta.drug_code AS drugCode,\n" +
|
|
|
"\ta.org_code AS orgCode,\n" +
|
|
|
"\ta.layer_no AS layerNo,\n" +
|
|
|
"\ta.wayer_no AS wayerNo,\n" +
|
|
|
"\ta.qty AS qty,\n" +
|
|
|
"\ta.create_time AS createTime,\n" +
|
|
|
"\ta.create_user AS createUser,\n" +
|
|
|
"\ta.create_user_name AS createUserName,\n" +
|
|
|
"\ta.update_time AS updateTime,\n" +
|
|
|
"\ta.update_user AS updateUser,\n" +
|
|
|
"\ta.update_user_name AS updateUserName,\n" +
|
|
|
"\ta.drug_name AS drugName,\n" +
|
|
|
"\ta.cargo_capacity AS cargoCapacity,\n" +
|
|
|
"\ta.shelf_status AS shelfStatus,\n" +
|
|
|
"\ta.price AS price,\n" +
|
|
|
"\ta.pic AS pic,\n" +
|
|
|
"\ta.equ_num AS equNum,\n" +
|
|
|
"\ta.`merge` AS `merge`,\n" +
|
|
|
"\ta.cargo_state AS cargoState,\n" +
|
|
|
"\ta.fault_state AS faultState,\n" +
|
|
|
"\ta.rated_inventory AS ratedInventory\n" +
|
|
|
"FROM\n" +
|
|
|
"\tt_mediicinecabinet_inventory a\n" +
|
|
|
"WHERE\n" +
|
|
|
"\ta.org_code = '"+stringObjectMap.get("orgCode") + ""+"'\n" +
|
|
|
"AND a.drug_code = '"+stringObjectMap.get("drugCode") + ""+"'\n" +
|
|
|
"AND a.id_device = '"+deviceId+"'\n" +
|
|
|
"AND (a.state = '1' OR a.state = '21')\n" +
|
|
|
"AND a.org_code IS NOT NULL\n" +
|
|
|
"AND a.drug_code IS NOT NULL";
|
|
|
|
|
|
List<Map<String, Object>> list = hibenateUtils.createSQLQuery(tempSql);
|
|
|
|
|
|
// stringObjectMap.put("detail", inventoryDao.getMediicinecabinetInventoriesByOrgCodeAndDurgCode(
|
|
|
// stringObjectMap.get("orgCode") + "",
|
|
|
// stringObjectMap.get("drugCode") + "",
|
|
|
// deviceId, "1", "21"));
|
|
|
|
|
|
|
|
|
stringObjectMap.put("detail", list);
|
|
|
}
|
|
|
return collect;
|
|
|
}
|
|
@ -4895,14 +4989,37 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
|
|
|
Date startDate = null;
|
|
|
String timeCondition = "";
|
|
|
|
|
|
String endTime = DateUtil.getStringDate();
|
|
|
if (day != null) {
|
|
|
if (day == 1) {
|
|
|
startDate = DateUtil.strToDateLong(DateUtil.getStringDateShort() + " 00:00:00");
|
|
|
} else {
|
|
|
startDate = DateUtil.getPreDays(new Date(), -day);
|
|
|
}
|
|
|
String endTime = DateUtil.getStringDate();
|
|
|
timeCondition = " and o.shipping_time >='" + DateUtil.dateToStrLong(startDate) + "' and o.shipping_time <= '" + endTime + "' ";
|
|
|
} else {
|
|
|
// startDate = DateUtil.strToDateLong(DateUtil.getStringDateShort() + " 00:00:00");
|
|
|
String sql = "SELECT\n" +
|
|
|
"\to.shipping_time AS shippingTime\n" +
|
|
|
"FROM\n" +
|
|
|
"\tt_mediicine_order o\n" +
|
|
|
"WHERE\n" +
|
|
|
"\t1 = 1\n" +
|
|
|
"AND o.shipping_time IS NOT NULL\n" +
|
|
|
"ORDER BY\n" +
|
|
|
"\to.shipping_time ASC LIMIT 1";
|
|
|
|
|
|
Map<String,Object> totalMap = jdbcTemplate.queryForMap(sql);
|
|
|
if (totalMap != null) {
|
|
|
if (totalMap.get("shippingTime") != null) {
|
|
|
startDate = (Date) totalMap.get("shippingTime");
|
|
|
} else {
|
|
|
startDate = DateUtil.getNowDate();
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
startDate = DateUtil.getNowDate();
|
|
|
}
|
|
|
timeCondition = " and o.shipping_time >='" + DateUtil.dateToStrLong(startDate) + "' and o.shipping_time <= '" + endTime + "' ";
|
|
|
}
|
|
|
String sql = "SELECT SUM(o.order_amount) as \"amount\" FROM t_mediicine_order o WHERE o.sell_state=1 "+condition+ timeCondition;
|