|
@ -776,13 +776,12 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
String deviceID = "";
|
|
|
|
|
|
//true,标识当前操作为合并货道操作
|
|
|
|
|
|
MedicineDrugInventoryRecord inventoryModifyRecord = null;
|
|
|
boolean modifyRecordFlag = false;
|
|
|
List<String> mergeCargoS = new ArrayList<>();
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(cargoIds)){
|
|
|
modifyRecordFlag = true;
|
|
|
inventoryModifyRecord = new MedicineDrugInventoryRecord();
|
|
|
|
|
|
/**货到状态操作日志**/
|
|
|
|
|
|
if (isMerge) {//合并
|
|
|
MedicineDrugInventoryRecord inventoryModifyRecord = new MedicineDrugInventoryRecord();
|
|
|
inventoryModifyRecord.setOldDrugId(null);
|
|
|
inventoryModifyRecord.setDrugId(null);
|
|
|
inventoryModifyRecord.setMergeState(isMerge?"2":"1");
|
|
@ -791,10 +790,7 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
inventoryModifyRecord.setCreateUser(userId);
|
|
|
inventoryModifyRecord.setCreateTime(new Date());
|
|
|
inventoryModifyRecord.setType("5");
|
|
|
}
|
|
|
/**货到状态操作日志**/
|
|
|
|
|
|
if (isMerge) {
|
|
|
String[] cargoIdArray = cargoIds.split(",");
|
|
|
changedCargoNumber = cargoIdArray.length - 1;
|
|
|
//合并的所有货道列编号--->集合
|
|
@ -814,12 +810,11 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
if(!StringUtils.isEmpty(cargoId)){
|
|
|
MediicinecabinetInventory inventory = inventoryDao.findOne(cargoId);
|
|
|
mergeCargoS.add(inventory.getWayerNo());
|
|
|
if (modifyRecordFlag){
|
|
|
inventoryModifyRecord.setDeviceId(inventory.getIdDevice());
|
|
|
inventoryModifyRecord.setEquNum(inventory.getEquNum());
|
|
|
inventoryModifyRecord.setLayerNo(inventory.getLayerNo());
|
|
|
inventoryModifyRecord.setWayerNo(inventory.getWayerNo());
|
|
|
}
|
|
|
|
|
|
inventoryModifyRecord.setDeviceId(inventory.getIdDevice());
|
|
|
inventoryModifyRecord.setEquNum(inventory.getEquNum());
|
|
|
inventoryModifyRecord.setLayerNo(inventory.getLayerNo());
|
|
|
inventoryModifyRecord.setWayerNo(inventory.getWayerNo());
|
|
|
|
|
|
//有药品记录下架操作
|
|
|
if (inventory.getOrgCode() != null && inventory.getDrugCode() != null) {
|
|
@ -866,62 +861,78 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
inventoryDao.save(inventory);
|
|
|
}
|
|
|
}
|
|
|
inventoryModifyRecord.setMergeCargo(mergeCargoS.stream().map(String::valueOf).collect(Collectors.joining(",")));
|
|
|
inventoryRecordDao.save(inventoryModifyRecord);
|
|
|
} else {
|
|
|
MediicinecabinetInventory inventory = inventoryDao.findOne(cargoIds);
|
|
|
mergeCargoS.add(inventory.getWayerNo());
|
|
|
if (modifyRecordFlag){
|
|
|
//多个拆分
|
|
|
String[] cargoIdArray = cargoIds.split(",");
|
|
|
List<MedicineDrugInventoryRecord> inventoryModifyRecords = new ArrayList<>();
|
|
|
|
|
|
for (String cargoIdTmp:cargoIdArray){
|
|
|
MediicinecabinetInventory inventory = inventoryDao.findOne(cargoIdTmp);
|
|
|
//所有有关分解的货道列表
|
|
|
List<MediicinecabinetInventory> list = inventoryDao.findMediicinecabinetInventoryByIdDeviceAndLayerNoAndMerge(inventory.getIdDevice(),inventory.getLayerNo(), inventory.getMerge());
|
|
|
|
|
|
MedicineDrugInventoryRecord inventoryModifyRecord = new MedicineDrugInventoryRecord();
|
|
|
inventoryModifyRecord.setOldDrugId(null);
|
|
|
inventoryModifyRecord.setDrugId(null);
|
|
|
inventoryModifyRecord.setMergeState(isMerge?"2":"1");
|
|
|
inventoryModifyRecord.setOldQuantity(null);
|
|
|
inventoryModifyRecord.setQuantity(null);
|
|
|
inventoryModifyRecord.setCreateUser(userId);
|
|
|
inventoryModifyRecord.setCreateTime(new Date());
|
|
|
inventoryModifyRecord.setType("5");
|
|
|
inventoryModifyRecord.setDeviceId(inventory.getIdDevice());
|
|
|
inventoryModifyRecord.setEquNum(inventory.getEquNum());
|
|
|
inventoryModifyRecord.setLayerNo(inventory.getLayerNo());
|
|
|
inventoryModifyRecord.setWayerNo(inventory.getWayerNo());
|
|
|
}
|
|
|
|
|
|
//所有有关分解的货道列表
|
|
|
List<MediicinecabinetInventory> list = inventoryDao.findMediicinecabinetInventoryByIdDeviceAndLayerNoAndMerge(inventory.getIdDevice(),inventory.getLayerNo(), inventory.getMerge());
|
|
|
|
|
|
changedCargoNumber = list.size() - 1;
|
|
|
//主货道拆解
|
|
|
inventory.setMerge(inventory.getWayerNo());
|
|
|
//有药品记录下架操作
|
|
|
if (inventory.getOrgCode() != null && inventory.getDrugCode() != null) {
|
|
|
MedicineDrugInventoryRecord inventoryRecord = new MedicineDrugInventoryRecord();
|
|
|
inventoryRecord.setDeviceId(inventory.getIdDevice());
|
|
|
inventoryRecord.setEquNum(inventory.getEquNum());
|
|
|
inventoryRecord.setOldDrugId(inventory.getDrugId());
|
|
|
inventoryRecord.setDrugId(inventory.getDrugId());
|
|
|
inventoryRecord.setLayerNo(inventory.getLayerNo());
|
|
|
inventoryRecord.setWayerNo(inventory.getWayerNo());
|
|
|
inventoryRecord.setMergeState(inventory.getState());
|
|
|
inventoryRecord.setMergeCargo(inventory.getMerge());
|
|
|
inventoryRecord.setOldQuantity(inventory.getQty());
|
|
|
inventoryRecord.setQuantity("0");
|
|
|
inventoryRecord.setCreateUser(userId);
|
|
|
inventoryRecord.setType("4");
|
|
|
inventoryRecordDao.save(inventoryRecord);
|
|
|
}
|
|
|
deviceID = inventory.getIdDevice();
|
|
|
//清空药品
|
|
|
inventory.setQty("0");
|
|
|
inventory.setDrugName(null);
|
|
|
inventory.setDrugCode(null);
|
|
|
inventory.setOrgCode(null);
|
|
|
inventory.setPrice(null);
|
|
|
//bug:13630,新增
|
|
|
inventory.setShelfStatus("0");
|
|
|
//额定库存
|
|
|
inventory.setRatedInventory(0);
|
|
|
//清空药品
|
|
|
inventory.setState("1");
|
|
|
inventoryDao.save(inventory);
|
|
|
boolean jumpFirst = false;
|
|
|
for (MediicinecabinetInventory mediicinecabinetInventory : list) {
|
|
|
if(jumpFirst) {
|
|
|
changedCapacity += Integer.parseInt(mediicinecabinetInventory.getCargoCapacity());
|
|
|
List<String> mergeCargos = list.stream().map(MediicinecabinetInventory::getWayerNo).collect(Collectors.toList());
|
|
|
inventoryModifyRecord.setMergeCargo(mergeCargos.stream().map(String::valueOf).collect(Collectors.joining("','")));
|
|
|
inventoryModifyRecords.add(inventoryModifyRecord);
|
|
|
changedCargoNumber += list.size() - 1;
|
|
|
//主货道拆解
|
|
|
inventory.setMerge(inventory.getWayerNo());
|
|
|
//有药品记录下架操作
|
|
|
if (inventory.getOrgCode() != null && inventory.getDrugCode() != null) {
|
|
|
MedicineDrugInventoryRecord inventoryRecord = new MedicineDrugInventoryRecord();
|
|
|
inventoryRecord.setDeviceId(inventory.getIdDevice());
|
|
|
inventoryRecord.setEquNum(inventory.getEquNum());
|
|
|
inventoryRecord.setOldDrugId(inventory.getDrugId());
|
|
|
inventoryRecord.setDrugId(inventory.getDrugId());
|
|
|
inventoryRecord.setLayerNo(inventory.getLayerNo());
|
|
|
inventoryRecord.setWayerNo(inventory.getWayerNo());
|
|
|
inventoryRecord.setMergeState(inventory.getState());
|
|
|
inventoryRecord.setMergeCargo(inventory.getMerge());
|
|
|
inventoryRecord.setOldQuantity(inventory.getQty());
|
|
|
inventoryRecord.setQuantity("0");
|
|
|
inventoryRecord.setCreateUser(userId);
|
|
|
inventoryRecord.setType("4");
|
|
|
inventoryRecordDao.save(inventoryRecord);
|
|
|
}
|
|
|
deviceID = inventory.getIdDevice();
|
|
|
//清空药品
|
|
|
inventory.setQty("0");
|
|
|
inventory.setDrugName(null);
|
|
|
inventory.setDrugCode(null);
|
|
|
inventory.setOrgCode(null);
|
|
|
inventory.setPrice(null);
|
|
|
//bug:13630,新增
|
|
|
inventory.setShelfStatus("0");
|
|
|
//额定库存
|
|
|
inventory.setRatedInventory(0);
|
|
|
//清空药品
|
|
|
inventory.setState("1");
|
|
|
inventoryDao.save(inventory);
|
|
|
boolean jumpFirst = false;
|
|
|
for (MediicinecabinetInventory mediicinecabinetInventory : list) {
|
|
|
if(jumpFirst) {
|
|
|
changedCapacity += Integer.parseInt(mediicinecabinetInventory.getCargoCapacity());
|
|
|
}
|
|
|
jumpFirst = true;
|
|
|
mediicinecabinetInventory.setMerge(mediicinecabinetInventory.getWayerNo());
|
|
|
mediicinecabinetInventory.setState("1");
|
|
|
inventoryDao.save(mediicinecabinetInventory);
|
|
|
}
|
|
|
jumpFirst = true;
|
|
|
mediicinecabinetInventory.setMerge(mediicinecabinetInventory.getWayerNo());
|
|
|
mediicinecabinetInventory.setState("1");
|
|
|
inventoryDao.save(mediicinecabinetInventory);
|
|
|
}
|
|
|
}
|
|
|
//计算货道数和货道容量
|
|
@ -937,10 +948,7 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
}
|
|
|
deviceDao.save(mediicinedevice);
|
|
|
}
|
|
|
if (null!=inventoryModifyRecord){
|
|
|
inventoryModifyRecord.setMergeCargo(mergeCargoS.stream().map(String::valueOf).collect(Collectors.joining(",")));
|
|
|
inventoryRecordDao.save(inventoryModifyRecord);
|
|
|
}
|
|
|
|
|
|
result.put("response",ConstantUtils.SUCCESS);
|
|
|
return result.toJSONString();
|
|
|
}
|
|
@ -1016,6 +1024,22 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
return result.toJSONString();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 货道故障状态更改
|
|
|
* @param cargoIds
|
|
|
* @param faultState
|
|
|
* @return
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public boolean updateDeviceCargoStateApp(String cargoIds, String faultState){
|
|
|
JSONObject result = new JSONObject();
|
|
|
StringBuilder cargoIdsSql = new StringBuilder("");
|
|
|
cargoIdsSql.append(" and a.category_code in ('").append(cargoIds.replace(",","','")).append("')");
|
|
|
String sql = " update t_mediicinecabinet_inventory set fault_state='"+faultState+"' where id in ("+cargoIdsSql+") ";
|
|
|
jdbcTemplate.execute(sql);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
|
|
|
// public String updateDeviceInventoryNum(String cargoIds, String cargoState){
|
|
|
// JSONObject result = new JSONObject();
|