|
@ -737,7 +737,7 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
* @param isMerge
|
|
|
* @return
|
|
|
*/
|
|
|
public String mergeAndSplitCargo(String cargoIds, Boolean isMerge){
|
|
|
public String mergeAndSplitCargo(String cargoIds, Boolean isMerge, String userId){
|
|
|
JSONObject result = new JSONObject();
|
|
|
if(StringUtils.isEmpty(cargoIds)){
|
|
|
result.put("msg","cargoIds is null");
|
|
@ -748,12 +748,13 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
String[] cargoIdsArray = cargoIds.split(",");
|
|
|
|
|
|
String deviceID = "";
|
|
|
//true,标识合并货道
|
|
|
if (isMerge) {
|
|
|
Boolean isFirst = true;
|
|
|
//合并的所有货道集合
|
|
|
String wayerNos = "";
|
|
|
for (String deviceId : cargoIds.split(",")) {
|
|
|
if(!StringUtils.isEmpty(deviceId)){
|
|
|
MediicinecabinetInventory inventory = inventoryDao.findOne(deviceId);
|
|
|
for (String cargoId : cargoIds.split(",")) {
|
|
|
if(!StringUtils.isEmpty(cargoId)){
|
|
|
MediicinecabinetInventory inventory = inventoryDao.findOne(cargoId);
|
|
|
if (StringUtils.isEmpty(wayerNos)) {
|
|
|
wayerNos += inventory.getWayerNo();
|
|
|
}else {
|
|
@ -761,39 +762,50 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
MediicinecabinetInventory copyInventory = new MediicinecabinetInventory();
|
|
|
for (String deviceId : cargoIds.split(",")) {
|
|
|
if(!StringUtils.isEmpty(deviceId)){
|
|
|
|
|
|
boolean isFirst = true;
|
|
|
for (String cargoId : cargoIds.split(",")) {
|
|
|
if(!StringUtils.isEmpty(cargoId)){
|
|
|
MediicinecabinetInventory inventory = inventoryDao.findOne(cargoId);
|
|
|
//有药品记录下架操作
|
|
|
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.setMerge(wayerNos);
|
|
|
//清空药品
|
|
|
inventory.setQty("0");
|
|
|
inventory.setDrugId(null);
|
|
|
inventory.setDrugName(null);
|
|
|
inventory.setDrugCode(null);
|
|
|
inventory.setOrgCode(null);
|
|
|
inventory.setPrice(null);
|
|
|
//额定库存
|
|
|
inventory.setRatedInventory(0);
|
|
|
//清空药品
|
|
|
if (isFirst) {
|
|
|
MediicinecabinetInventory inventory = inventoryDao.findOne(deviceId);
|
|
|
deviceID = inventory.getIdDevice();
|
|
|
copyInventory = inventory;
|
|
|
inventory.setMerge(wayerNos);
|
|
|
inventory.setState("21");
|
|
|
inventoryDao.save(inventory);
|
|
|
isFirst = false;
|
|
|
} else {
|
|
|
MediicinecabinetInventory inventory = inventoryDao.findOne(deviceId);
|
|
|
deviceID = inventory.getIdDevice();
|
|
|
inventory.setMerge(wayerNos);
|
|
|
// inventory.setCargoCapacity(copyInventory.getCargoCapacity());
|
|
|
// inventory.setState(copyInventory.getState());
|
|
|
// 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);
|
|
|
}
|
|
|
inventoryDao.save(inventory);
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
@ -801,6 +813,32 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
MediicinecabinetInventory inventory = inventoryDao.findOne(cargoIds);
|
|
|
List<MediicinecabinetInventory> list = inventoryDao.findMediicinecabinetInventoriesByLayerNoAndMerge(inventory.getLayerNo(), inventory.getMerge());
|
|
|
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);
|
|
|
}
|
|
|
//清空药品
|
|
|
inventory.setQty("0");
|
|
|
inventory.setDrugName(null);
|
|
|
inventory.setDrugCode(null);
|
|
|
inventory.setOrgCode(null);
|
|
|
inventory.setPrice(null);
|
|
|
//额定库存
|
|
|
inventory.setRatedInventory(0);
|
|
|
//清空药品
|
|
|
inventory.setState("1");
|
|
|
inventoryDao.save(inventory);
|
|
|
for (MediicinecabinetInventory mediicinecabinetInventory : list) {
|
|
@ -818,6 +856,7 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
// }
|
|
|
// }
|
|
|
}
|
|
|
//重算货道数
|
|
|
Mediicinedevice mediicinedevice = deviceDao.findOne(deviceID);
|
|
|
if (mediicinedevice != null) {
|
|
|
String tempSql = "SELECT\n" +
|