|
@ -4607,4 +4607,58 @@ public class MedicinedeviceService extends BaseJpaService<Mediicinedevice, Medi
|
|
|
return collect;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public String batchAddInventory(String json, String userId) throws Exception{
|
|
|
JSONObject result = new JSONObject();
|
|
|
JSONObject jsonObject = JSONObject.parseObject(json);
|
|
|
JSONArray cargoList = jsonObject.getJSONArray("list");
|
|
|
if (cargoList.size() == 0) {
|
|
|
result.put("msg","list is empty");
|
|
|
result.put("response", ConstantUtils.FAIL);
|
|
|
return result.toJSONString();
|
|
|
}
|
|
|
for (Object obj : cargoList) {
|
|
|
InventoryDO inventoryDO = null;
|
|
|
try {
|
|
|
inventoryDO = objectMapper.readValue(obj.toString(), InventoryDO.class);
|
|
|
} catch (IOException e) {
|
|
|
result.put("msg", "convert org jsonObject to InventoryDO failed," + e.getCause());
|
|
|
result.put("response", ConstantUtils.FAIL);
|
|
|
return result.toJSONString();
|
|
|
}
|
|
|
//原货道信息
|
|
|
MediicinecabinetInventory mediicinecabinetInventory = inventoryDao.findOne(inventoryDO.getCargoId());
|
|
|
//没有药品跳过
|
|
|
if (inventoryDO.getDrugId() == null || StringUtils.isEmpty(inventoryDO.getDrugId())) {
|
|
|
if (mediicinecabinetInventory.getOrgCode() != null && !StringUtils.isEmpty(mediicinecabinetInventory.getOrgCode())
|
|
|
&& mediicinecabinetInventory.getDrugCode() != null && !StringUtils.isEmpty(mediicinecabinetInventory.getDrugCode())) {
|
|
|
//下架商品
|
|
|
updateMediicinecabineInventoryInfoById(inventoryDO.getCargoId(), null, null, "0", userId);
|
|
|
}
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
if (mediicinecabinetInventory.getDrugCode() == null && mediicinecabinetInventory.getDrugCode() == null) {
|
|
|
//新增药品
|
|
|
|
|
|
updateMediicinecabineInventoryById(inventoryDO.getCargoId(), inventoryDO.getDrugId(), inventoryDO.getQty() + "", userId);
|
|
|
} else {
|
|
|
Mediicinedrugs mediicinedrugs = mediicinedrugsDao.findOne(inventoryDO.getDrugId());
|
|
|
//更换前后药品相同
|
|
|
if (mediicinecabinetInventory.getDrugCode().equals(mediicinedrugs.getDrugCode()) && mediicinecabinetInventory.getOrgCode().equals(mediicinedrugs.getOrgCode())) {
|
|
|
updateMediicinecabineInventoryInfoById(inventoryDO.getCargoId(), inventoryDO.getQty() + "", null, null, userId);
|
|
|
} else {
|
|
|
//更换药品
|
|
|
updateMediicinecabineInventoryById(inventoryDO.getCargoId(), inventoryDO.getDrugId(), inventoryDO.getQty() + "", userId);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
result.put("response", ConstantUtils.SUCCESS);
|
|
|
result.put("msg", ConstantUtils.SUCCESS);
|
|
|
return result.toJSONString();
|
|
|
}
|
|
|
|
|
|
}
|