|
@ -2340,20 +2340,20 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
}
|
|
|
}
|
|
|
String tempSql = "SELECT\n" +
|
|
|
"\tIFNULL(\n" +
|
|
|
"\t\t(\n" +
|
|
|
"\t\t\tSELECT\n" +
|
|
|
"\t\t\t\tsum(t.qty)\n" +
|
|
|
"\t\t\tFROM\n" +
|
|
|
"\t\t\t\tt_mediicinecabinet_inventory t\n" +
|
|
|
"\t\t\tWHERE\n" +
|
|
|
"\t\t\t\tt.id_device = '"+stringObjectMap.get("id").toString()+"'\n" +
|
|
|
"\t\t\tAND (t.state = '1' OR t.state = '21')\n" +
|
|
|
"\t\t\tAND t.shelf_status = '1'\n" +
|
|
|
"\t\t),\n" +
|
|
|
"\t\t0\n" +
|
|
|
"\t)";
|
|
|
int inStock = jdbcTemplate.queryForObject(tempSql, Integer.class);
|
|
|
"\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);
|
|
|
//商品庫存
|
|
@ -2373,7 +2373,13 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
"\t\t),\n" +
|
|
|
"\t\t0\n" +
|
|
|
"\t) AS qty";
|
|
|
Integer inventoryNum = jdbcTemplate.queryForObject(tempSqlTwo, Integer.class);
|
|
|
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") + ""));
|
|
@ -2635,9 +2641,9 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
//获取了所有缺货的药品id
|
|
|
for (MedicineWarrayRule rule : rules) {
|
|
|
for (Map<String, Object> stringObjectMap : collect) {
|
|
|
Integer ratedInventory = Integer.parseInt(stringObjectMap.get("ratedInventory") + "");
|
|
|
Integer ratedInventory = (int) Double.parseDouble(stringObjectMap.get("ratedInventory") + "");
|
|
|
if (ratedInventory > rule.getLower() && ratedInventory < rule.getUpper()) {
|
|
|
Integer tempQty = Integer.parseInt(stringObjectMap.get("qty") + "");
|
|
|
Integer tempQty = (int) Double.parseDouble(stringObjectMap.get("qty") + "");
|
|
|
if ("%".equals(rule.getMatchUnit())) {
|
|
|
Integer matchValue = (int) Math.ceil((rule.getUpper() * rule.getMatchValue()) / 100.0);
|
|
|
if (tempQty <= matchValue) {
|
|
@ -3865,9 +3871,9 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
mediicinedevice.setStatus("1");
|
|
|
quit:for (MedicineWarrayRule rule : rules) {
|
|
|
for (Map<String, Object> stringObjectMap : collect) {
|
|
|
Integer ratedInventory = Integer.parseInt(stringObjectMap.get("ratedInventory") + "");
|
|
|
Integer ratedInventory = (int) Double.parseDouble(stringObjectMap.get("ratedInventory") + "");
|
|
|
if (ratedInventory > rule.getLower() && ratedInventory < rule.getUpper()) {
|
|
|
Integer tempQty = Integer.parseInt(stringObjectMap.get("qty") + "");
|
|
|
Integer tempQty = (int) Double.parseDouble(stringObjectMap.get("qty") + "");
|
|
|
if ("%".equals(rule.getMatchUnit())) {
|
|
|
Integer matchValue = (int) Math.ceil((rule.getUpper() * rule.getMatchValue()) / 100.0);
|
|
|
if (tempQty <= matchValue) {
|
|
@ -3968,13 +3974,21 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
if (cargoCapacityChanged) {
|
|
|
Mediicinedevice mediicinedevice = deviceDao.findOne(inventory.getIdDevice());
|
|
|
String tempSql = "SELECT\n" +
|
|
|
"\tsum(t.cargo_capacity)\n" +
|
|
|
"\tifnull(sum(t.cargo_capacity), 0) as cargoCapacity\n" +
|
|
|
"FROM\n" +
|
|
|
"\tt_mediicinecabinet_inventory t\n" +
|
|
|
"WHERE\n" +
|
|
|
"\tt.id_device = '"+inventory.getIdDevice()+"'\n" +
|
|
|
"AND (t.state = '1' OR t.state = '21')";
|
|
|
mediicinedevice.setCapacity(String.valueOf(jdbcTemplate.queryForObject(tempSql, Integer.class)));
|
|
|
|
|
|
Map<String,Object> totalMap = jdbcTemplate.queryForMap(tempSql);
|
|
|
Integer noOnlineTotal1 = 0;
|
|
|
if (totalMap!=null){
|
|
|
if (totalMap.get("cargoCapacity") != null) {
|
|
|
noOnlineTotal1 = (int) Double.parseDouble(totalMap.get("cargoCapacity").toString());
|
|
|
}
|
|
|
}
|
|
|
mediicinedevice.setCapacity(String.valueOf(noOnlineTotal1));
|
|
|
deviceDao.save(mediicinedevice);
|
|
|
}
|
|
|
return inventory;
|