|
@ -1215,13 +1215,19 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
//设备容量
|
|
|
jsonObject.put("deviceCapacity", device.getCapacity());
|
|
|
String tempSql = "SELECT\n" +
|
|
|
"\tsum(t.qty)\n" +
|
|
|
"FROM\n" +
|
|
|
"\tt_mediicinecabinet_inventory t\n" +
|
|
|
"WHERE\n" +
|
|
|
"\tt.id_device = '"+device.getId()+"'\n" +
|
|
|
"AND (t.state = '1' OR t.state = '21')\n" +
|
|
|
"AND t.shelf_status = '1'";
|
|
|
"\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 = '"+device.getId()+"'\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);
|
|
|
//在架库存数
|
|
|
jsonObject.put("inStock", inStock);
|
|
@ -3135,13 +3141,29 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
inventory.setSku(mediicinedrugs.getDrugSku());
|
|
|
inventory.setShelfStatus("1");
|
|
|
inventory.setDrugId(drugId);
|
|
|
inventory.setQty(qty);
|
|
|
inventory.setPic(mediicinedrugs.getPic());
|
|
|
boolean cargoCapacityChanged = false;
|
|
|
//更换药品,货道容量跟着药品数量变动
|
|
|
if (Integer.parseInt(qty) > Integer.parseInt(inventory.getCargoCapacity())) {
|
|
|
cargoCapacityChanged = true;
|
|
|
inventory.setCargoCapacity(qty);
|
|
|
}
|
|
|
inventory.setQty(qty);
|
|
|
inventory.setPic(mediicinedrugs.getPic());
|
|
|
return inventoryDao.save(inventory);
|
|
|
inventoryDao.save(inventory);
|
|
|
if (cargoCapacityChanged) {
|
|
|
//重算设备容量
|
|
|
Mediicinedevice mediicinedevice = deviceDao.findOne(inventory.getIdDevice());
|
|
|
String tempSql = "SELECT\n" +
|
|
|
"\tsum(t.cargo_capacity)\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)));
|
|
|
deviceDao.save(mediicinedevice);
|
|
|
}
|
|
|
return inventory;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@ -3165,6 +3187,7 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
*/
|
|
|
public MediicinecabinetInventory updateMediicinecabineInventoryInfoById(String id,String qty,String cargoCapacity,String status,String userId) throws Exception {
|
|
|
MediicinecabinetInventory inventory = inventoryDao.findOne(id);
|
|
|
boolean cargoCapacityChanged = false;
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(qty)){
|
|
|
//有药品时的补货
|
|
|
MedicineDrugInventoryRecord inventoryRecord = new MedicineDrugInventoryRecord();
|
|
@ -3183,12 +3206,14 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
inventoryRecordDao.save(inventoryRecord);
|
|
|
//提升容量至库存数(修改的库存数大于容量时)
|
|
|
if (Integer.parseInt(qty) > Integer.parseInt(inventory.getCargoCapacity())) {
|
|
|
cargoCapacityChanged = true;
|
|
|
inventory.setCargoCapacity(qty);
|
|
|
}
|
|
|
inventory.setQty(qty);
|
|
|
}
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(cargoCapacity)){
|
|
|
inventory.setCargoCapacity(cargoCapacity);
|
|
|
cargoCapacityChanged = true;
|
|
|
}
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(status)){
|
|
|
//下架时,清空库存
|
|
@ -3212,7 +3237,21 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
inventoryRecordDao.save(inventoryRecord);
|
|
|
}
|
|
|
inventory.setUpdateTime(new Date());
|
|
|
return inventoryDao.save(inventory);
|
|
|
inventoryDao.save(inventory);
|
|
|
if (cargoCapacityChanged) {
|
|
|
//重算设备容量
|
|
|
Mediicinedevice mediicinedevice = deviceDao.findOne(inventory.getIdDevice());
|
|
|
String tempSql = "SELECT\n" +
|
|
|
"\tsum(t.cargo_capacity)\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)));
|
|
|
deviceDao.save(mediicinedevice);
|
|
|
}
|
|
|
return inventory;
|
|
|
}
|
|
|
|
|
|
}
|