Index: ssts-receiverecord/src/main/java/com/forgon/disinfectsystem/receiverecord/service/ReceiveRecordManagerImpl.java =================================================================== diff -u -r34973 -r39756 --- ssts-receiverecord/src/main/java/com/forgon/disinfectsystem/receiverecord/service/ReceiveRecordManagerImpl.java (.../ReceiveRecordManagerImpl.java) (revision 34973) +++ ssts-receiverecord/src/main/java/com/forgon/disinfectsystem/receiverecord/service/ReceiveRecordManagerImpl.java (.../ReceiveRecordManagerImpl.java) (revision 39756) @@ -9,7 +9,6 @@ import java.math.BigDecimal; import java.sql.ResultSet; import java.sql.SQLException; -import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -35,13 +34,18 @@ import org.apache.poi.hssf.usermodel.HSSFSheet; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.poifs.filesystem.POIFSFileSystem; +import org.springframework.beans.factory.annotation.Autowired; import com.forgon.databaseadapter.service.DateQueryAdapter; import com.forgon.directory.acegi.tools.AcegiHelper; +import com.forgon.directory.model.BarcodeDevice; import com.forgon.directory.model.OrgUnit; +import com.forgon.disinfectsystem.barcode.service.BarcodeManager; import com.forgon.disinfectsystem.basedatamanager.goodsstock.service.GoodsStockManager; +import com.forgon.disinfectsystem.basedatamanager.supplyroomconfig.service.SupplyRoomConfigManager; import com.forgon.disinfectsystem.basedatamanager.warehouse.service.WareHouseManager; import com.forgon.disinfectsystem.common.CssdUtils; +import com.forgon.disinfectsystem.diposablegoods.service.DiposableGoodBatchStockManager; import com.forgon.disinfectsystem.diposablegoods.service.DiposableGoodsManager; import com.forgon.disinfectsystem.entity.assestmanagement.DisposableGoods; import com.forgon.disinfectsystem.entity.assestmanagement.DisposableGoodsBatchStock; @@ -63,6 +67,9 @@ import com.forgon.disinfectsystem.inventorymanagement.dao.WriteBackInventoryDao; import com.forgon.disinfectsystem.inventorymanagement.service.WriteBackInventoryHelper; import com.forgon.disinfectsystem.receiverecord.util.ReceiveRecordUtils; +import com.forgon.disinfectsystem.receiverecord.vo.ReceiveRecordItemVo; +import com.forgon.disinfectsystem.receiverecord.vo.ReceiveRecordVo; +import com.forgon.disinfectsystem.tousse.materialdefinition.service.MaterialDefinitionManager; import com.forgon.disinfectsystem.vo.DisposableGoodsStorageAdjustVo; import com.forgon.exception.SystemException; import com.forgon.log.model.Log; @@ -71,7 +78,7 @@ import com.forgon.tools.db.DatabaseUtil; import com.forgon.tools.excel.ExcelCellStyle; import com.forgon.tools.excel.ExcelHelper; -import com.forgon.tools.hibernate.ObjectDao; +import com.forgon.tools.hibernate.BasePoManagerImpl; import com.forgon.tools.json.JSONUtil; import com.forgon.tools.util.SqlUtils; @@ -80,10 +87,8 @@ * * 2012-11-6 下午5:38:28 */ -public class ReceiveRecordManagerImpl implements ReceiveRecordManager { +public class ReceiveRecordManagerImpl extends BasePoManagerImpl implements ReceiveRecordManager { - private ObjectDao objectDao; - private DiposableGoodsManager diposableGoodsManager; private WriteBackInventoryHelper writeBackInventoryHelper; @@ -101,6 +106,15 @@ private LogManager appLogManager; + private DiposableGoodBatchStockManager diposableGoodBatchStockManager; + + private MaterialDefinitionManager materialDefinitionManager; + + @Autowired + private BarcodeManager barcodeManager; + + private SupplyRoomConfigManager supplyRoomConfigManager; + private Logger logger = Logger.getLogger(ReceiveRecordManagerImpl.class); public void setGoodsStockManager(GoodsStockManager goodsStockManager) { @@ -129,14 +143,20 @@ this.diposableGoodsManager = diposableGoodsManager; } - public void setObjectDao(ObjectDao objectDao) { - this.objectDao = objectDao; - } - public void setAppLogManager(LogManager appLogManager) { this.appLogManager = appLogManager; } + public void setDiposableGoodBatchStockManager( + DiposableGoodBatchStockManager diposableGoodBatchStockManager) { + this.diposableGoodBatchStockManager = diposableGoodBatchStockManager; + } + + public void setMaterialDefinitionManager( + MaterialDefinitionManager materialDefinitionManager) { + this.materialDefinitionManager = materialDefinitionManager; + } + @Override public ReceiveRecord getReceiveRecordById(String id) { return (ReceiveRecord) objectDao.getBySql( @@ -1840,20 +1860,55 @@ @Override public void setReceiveRecordItemsFromParams(ReceiveRecord receiveRecord, JSONArray itemsArray) { + //如果仓库名称、领用时间、操作员为空,则分配赋上默认值 + Long warehouseId = receiveRecord.getWarehouseId(); + if(!DatabaseUtil.isPoIdValid(warehouseId)){ + throw new SystemException("仓库id参数不能为空"); + } + String warehouseName = receiveRecord.getWarehouseName(); + if(StringUtils.isBlank(warehouseName)){ + WareHouse warehouse = wareHouseManager.get(warehouseId); + if(warehouse == null){ + throw new SystemException("未找到仓库id参数值为"+ warehouseId +"的仓库"); + } + receiveRecord.setWarehouseName(warehouse.getName()); + } + String operator = receiveRecord.getOperator(); + if(StringUtils.isBlank(operator)){ + receiveRecord.setOperator(AcegiHelper.getLoginUserFullName()); + } + Date time = receiveRecord.getTime(); + if(time == null){ + receiveRecord.setTime(new Date()); + } // items列表 List receiveRecordItems = receiveRecord.getItems(); int size = itemsArray.size(); for (int i = 0; i < size; ++i) { - JSONObject obj = itemsArray.getJSONObject(i); + JSONObject obj = itemsArray.optJSONObject(i); if (obj != null) { ReceiveRecordItem receiveRecordItem = new ReceiveRecordItem(); //type receiveRecordItem.setType(DisposableGoods.TYPE_NAME); //一次性物品批次库存ID Long disposableGoodsBatchStockId = JSONUtil.optLong(obj, "disposableGoodsBatchStockId", null); - DisposableGoodsBatchStock dgbs = (DisposableGoodsBatchStock) objectDao.getByProperty( - DisposableGoodsBatchStock.class.getSimpleName(), "id",disposableGoodsBatchStockId); + DisposableGoodsBatchStock dgbs = null; + //如果批次库存id为空时,则根据一次性物品定义id,批次号,仓库id查询批次库存信息 + if(DatabaseUtil.isPoIdValid(disposableGoodsBatchStockId)){ + dgbs = (DisposableGoodsBatchStock) objectDao.getByProperty( + DisposableGoodsBatchStock.class.getSimpleName(), "id",disposableGoodsBatchStockId); + }else{ + //一次性物品定义ID + Long disposableGoodsId = JSONUtil.optLong(obj, "disposableGoodsId", null); + //批次号 + String batchNumber = obj.optString("batchNumber"); + String condition = String.format("where warehouseID=%s and diposableGoods.disposableGoodsID=%s and batchNumber='%s'", + receiveRecord.getWarehouseId(),disposableGoodsId,batchNumber); + dgbs = (DisposableGoodsBatchStock) objectDao.getBySql( + DisposableGoodsBatchStock.class.getSimpleName(), condition); + disposableGoodsBatchStockId = dgbs.getId(); + } if (dgbs == null){ throw new SystemException("不存在id=" + disposableGoodsBatchStockId + "的一次性物品批次库存!"); } @@ -1899,4 +1954,211 @@ } } } + + @Override + public Map loadBarcodeDeviceInfo(String barcode, + String warehouseId, boolean selectAll) { + Map returnMsg = new HashMap(); + returnMsg.put("success", false); + + // 需要从发货单和退货记录生成该批次可以退货的价格列表 + try { + if (StringUtils.isBlank(barcode)) { + throw new RuntimeException("条码不能为空!"); + } + BarcodeDevice barcodeDevice = barcodeManager + .getBarcodeByBarcode(barcode); + if (barcodeDevice == null){ + List disposableGoodsList = diposableGoodsManager.getByProperty("barcode", barcode); + if(CollectionUtils.isEmpty(disposableGoodsList)){ + throw new RuntimeException("查无此物品"); + } + List batchStocks = diposableGoodBatchStockManager + .getDisposableGoodsBatchStockByDisposableGoodsId(disposableGoodsList.get(0).getId()+"",warehouseId, selectAll); + String batchs = "[]"; + if(batchStocks != null){ + batchs = JSONUtil.toJSONStringEx(batchStocks,true,DisposableGoodsBatchStock.filterProperties); + } + returnMsg.put("barcodeType", BarcodeDevice.BARCODE_TYPE_DIPOSABLEGOODS); + returnMsg.put("disposablegoodsBatchStock", batchs); + returnMsg.put("disposablegoods", JSONUtil.toJSONString(disposableGoodsList.get(0))); + }else{ + Map disposablegoods = null; + if(barcodeDevice instanceof ExpensiveDisposablegoods){// 高值耗材处理 + disposablegoods = buildExpensiveDisposablegoodsInfo((ExpensiveDisposablegoods)barcodeDevice); + returnMsg.put("barcodeType", BarcodeDevice.BARCODE_TYPE_EXPENSIVEDIPOSABLEGOODS); + returnMsg.put("disposablegoods", disposablegoods); + }else{ + throw new RuntimeException("请扫描高值耗材条码"); + } + } + + returnMsg.put("success", true); + } catch (Exception e) { + e.printStackTrace(); + returnMsg.put("errMsg", e.getMessage()); + throw e; + } + return returnMsg; + } + + private Map buildExpensiveDisposablegoodsInfo(ExpensiveDisposablegoods expensiveDisposablegoods) { + Map diposableGood = new HashMap(); + Double cost = expensiveDisposablegoods.getPrice(); + String orgUnitCoding = AcegiHelper.getCurrentOrgUnitCode(); + String fluctuationPrice = supplyRoomConfigManager.getDisposableGoodsFluctuationPriceDoubleByOrgUnitCoding(orgUnitCoding, cost)+ ""; + DisposableGoodsBatchStock disposableGoodsBatchStock = expensiveDisposablegoods.getDisposableGoodsBatchStock(); + String barcode = expensiveDisposablegoods.getBarcode(); + String batchNumber = disposableGoodsBatchStock.getBatchNumber(); + String showName = disposableGoodsBatchStock.getDiposableGoods() + .getShowNameForSmallestUnit(); + diposableGood.put("disposableGoodsID", disposableGoodsBatchStock.getDisposableGoodsId()); + diposableGood.put("disposableGoodsStockID", disposableGoodsBatchStock.getDiposableGoods().getId()); + diposableGood.put("disposableGoodsBatchID", disposableGoodsBatchStock.getDisposableGoodsBatchId()); + diposableGood.put("disposableGoodsBatchStockID", disposableGoodsBatchStock.getId()); + diposableGood.put("expensiveDisposablegoodsId", expensiveDisposablegoods.getId()); + diposableGood.put("id", disposableGoodsBatchStock.getDiposableGoods().getId()); + diposableGood.put("goodsType", DisposableGoods.TYPE_EXPENSIVEDIPOSABLEGOODS); + diposableGood.put("barcode", barcode); + diposableGood.put("showName", showName); + diposableGood.put("batchNumber", batchNumber); + diposableGood.put("supplierName", disposableGoodsBatchStock.getSupplierName()); + diposableGood.put("cost", cost); + diposableGood.put("price", cost); + diposableGood.put("expDate", disposableGoodsBatchStock.getExpDateStr("yyyy-MM-dd")); + diposableGood.put("fluctuationPrice", fluctuationPrice); + Long storage = disposableGoodsBatchStock.getStorage(); + if (storage == null || storage < 0) { + storage = 0l; + } + diposableGood.put("storage", storage); + return diposableGood; + } + + @Override + public void setReceiveRecordItemsFromParams(ReceiveRecord entry, + String items) { + // items列表 + List receiveRecordItems = entry.getItems(); + JSONArray itemsArray = JSONArray.fromObject(items); + int size = itemsArray.size(); + for (int i = 0; i < size; ++i) { + JSONObject obj = itemsArray.getJSONObject(i); + if (obj != null) { + ReceiveRecordItem receiveRecordItem = new ReceiveRecordItem(); + Long itemId = JSONUtil.optLong(obj, "id", null); + receiveRecordItem.setId(itemId);// itemID + receiveRecordItem.setGoodsName(obj.optString("name")); + + Long disposableGoodsId = JSONUtil.optLong(obj, + "disposableGoodsId", null);// 一次性物品id + Long disposableGoodsStockId = JSONUtil.optLong(obj, + "disposableGoodsStockId", null); + Long disposableGoodsBatchId = JSONUtil.optLong(obj, + "disposableGoodsBatchId", null); + Long disposableGoodsBatchStockId = JSONUtil.optLong(obj, + "disposableGoodsBatchStockId", null); + receiveRecordItem.setDisposableGoodsId(disposableGoodsId); + receiveRecordItem.setDisposableGoodsStockId(disposableGoodsStockId); + receiveRecordItem.setDisposableGoodsBatchId(disposableGoodsBatchId); + receiveRecordItem.setDisposableGoodsBatchStockId(disposableGoodsBatchStockId); + + Long objID = JSONUtil.optLong(obj, "objID", null);// objID, 批次或者材料id + Long expensiveDisposablegoodsId = JSONUtil.optLong(obj, "expensiveDisposablegoodsId", null);// 高值耗材id + receiveRecordItem.setObjID(objID); + receiveRecordItem.setExpensiveDisposablegoodsId(expensiveDisposablegoodsId); + + int amount = Integer.valueOf(obj.optString("amount"));// 数量 + receiveRecordItem.setAmount(amount); + + String priceStr = obj.optString("price"); + if(StringUtils.isBlank(priceStr)){ + throw new SystemException(obj.optString("name") + "的价格为空,不能保存,请检查材料定义的设置!"); + } + double price = Double.valueOf(priceStr);// 价格 + receiveRecordItem.setPrice(price); + + String type = obj.optString("type");// type + receiveRecordItem.setType(type); + + //设置diposableGoodBatchStock_id + if (DisposableGoods.TYPE_NAME.equals(type) && disposableGoodsBatchStockId != null){ + DisposableGoodsBatchStock dgbs = diposableGoodBatchStockManager.getDiposableGoodBatchStockById(disposableGoodsBatchStockId.toString()); + if (dgbs != null){ + receiveRecordItem.setDiposableGoodBatchStock(dgbs); + } + } + //设置materialDefinition_id + if (MaterialDefinition.TYPE_NAME.equals(type) && objID != null){ + MaterialDefinition materialDefinition = materialDefinitionManager.get(objID); + if (materialDefinition != null){ + receiveRecordItem.setMaterialDefinition(materialDefinition); + } + } + + receiveRecordItem.setReceiveRecord(entry); + + receiveRecordItems.add(receiveRecordItem); + } + } + } + + @Override + public ReceiveRecordVo loadReceiveRecord(String id) { + ReceiveRecordVo recordVo = new ReceiveRecordVo(); + ReceiveRecord receiveRecord = null; + if (StringUtils.isNotBlank(id) && !id.equals("0")) { + receiveRecord = getReceiveRecordById(id); + if(receiveRecord == null){ + return recordVo; + } + }else{ + return recordVo; + } + recordVo.setId(receiveRecord.getId()); + recordVo.setOperator(receiveRecord.getOperator()); + recordVo.setTime(receiveRecord.getTime()); + recordVo.setRemark(receiveRecord.getRemark()); + recordVo.setWarehouseId(receiveRecord.getWarehouseId()); + recordVo.setWarehouseName(receiveRecord.getWarehouseName()); + + List voItems = new ArrayList(); + List items = receiveRecord.getItems(); + for (ReceiveRecordItem item : items) { + ReceiveRecordItemVo vo = new ReceiveRecordItemVo(); + vo.setId(item.getId()); + vo.setType(item.getType()); + vo.setAmount(item.getAmount()); + if (item.getType().equals(InventoryRecord.TYPE_DISPOSABLEGOOD)) { + vo.setDiposableGoodsID(item.getDisposableGoodsStockId()); + vo.setObjID(item.getObjID()); + + DisposableGoodsBatchStock disposableGoodsBatchStock = + diposableGoodBatchStockManager.getDiposableGoodBatchStockById(String.valueOf(item.getDisposableGoodsBatchStockId())); + String name = disposableGoodsBatchStock.getDiposableGoods().getName(); + String specification = disposableGoodsBatchStock.getDiposableGoods().getSpecification(); + if (StringUtils.isNotBlank(specification)) { + name = name + "[" + specification + "]"; + } + vo.setName(name); + vo.setBatchNumber(disposableGoodsBatchStock.getBatchNumber()); + vo.setCost(item.getPrice()); + vo.setExpDate(disposableGoodsBatchStock.getExpDateStr("yyyy-MM-dd")); + vo.setSupplierName(disposableGoodsBatchStock.getSupplierName()); + } else if (item.getType().equals(InventoryRecord.TYPE_MATERIALENTRY)) { + vo.setObjID(item.getMaterialDefinition().getId()); + String name = item.getMaterialDefinition().getName(); + String specification = item.getMaterialDefinition().getSpecification(); + if (StringUtils.isNotBlank(specification)) { + name = name + "[" + specification + "]"; + } + vo.setName(name); + vo.setCost(item.getMaterialDefinition().getCost()); + } + voItems.add(vo); + } + recordVo.setItems(voItems); + return recordVo; + } + } Index: ssts-webservice/src/main/java/com/forgon/disinfectsystem/webservice/service/ServiceManagerImpl.java =================================================================== diff -u -r39729 -r39756 --- ssts-webservice/src/main/java/com/forgon/disinfectsystem/webservice/service/ServiceManagerImpl.java (.../ServiceManagerImpl.java) (revision 39729) +++ ssts-webservice/src/main/java/com/forgon/disinfectsystem/webservice/service/ServiceManagerImpl.java (.../ServiceManagerImpl.java) (revision 39756) @@ -20,6 +20,7 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.Optional; import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -86,6 +87,7 @@ import com.forgon.disinfectsystem.common.CSSDConstants; import com.forgon.disinfectsystem.common.CssdUtils; import com.forgon.disinfectsystem.departmentapplicationtemplate.service.DepartmentAppTemplateManager; +import com.forgon.disinfectsystem.diposablegoods.service.DiposableGoodBatchStockManager; import com.forgon.disinfectsystem.diposablegoods.service.DiposableGoodsManager; import com.forgon.disinfectsystem.entity.assestmanagement.DisposableGoods; import com.forgon.disinfectsystem.entity.assestmanagement.DisposableGoodsBatch; @@ -127,6 +129,7 @@ import com.forgon.disinfectsystem.entity.qualitymonitoringmanager.qualitymonitoring.QualityMonitoringInstance; import com.forgon.disinfectsystem.entity.recall.RecallRecord; import com.forgon.disinfectsystem.entity.recall.RecallRecordItem; +import com.forgon.disinfectsystem.entity.receiverecord.ReceiveRecord; import com.forgon.disinfectsystem.entity.recycledepartmentgroup.DepartmentGroup; import com.forgon.disinfectsystem.entity.recyclingapplication.RecyclingApplication; import com.forgon.disinfectsystem.entity.returngoodsrecord.ReturnGoodsItem; @@ -159,6 +162,8 @@ import com.forgon.disinfectsystem.qualitymonitoring.instance.service.QualityMonitoringInstanceManager; import com.forgon.disinfectsystem.recall.service.RecallRecordManager; import com.forgon.disinfectsystem.recall.vo.RecalledTousseVO; +import com.forgon.disinfectsystem.receiverecord.service.ReceiveRecordManager; +import com.forgon.disinfectsystem.receiverecord.vo.ReceiveRecordVo; import com.forgon.disinfectsystem.recyclingapplication.result.LoadTousseLeaseItemsResultBuilder; import com.forgon.disinfectsystem.recyclingapplication.service.InvoicePlanManager; import com.forgon.disinfectsystem.recyclingapplication.service.RecyclingApplicationManager; @@ -409,6 +414,8 @@ @Autowired private DiposableGoodsManager diposableGoodsManager; @Autowired + private DiposableGoodBatchStockManager diposableGoodBatchStockManager; + @Autowired private ApplicationLogManager applicationLogManager; @Autowired private OperationRoomManager operationRoomManager; @@ -452,6 +459,8 @@ private ThirdPartyTousseReceiveRecordManager thirdPartyTousseReceiveRecordManager; @Autowired private LaoKenThirdPartyTousseReceiveRecordManager laoKenThirdPartyTousseReceiveRecordManager; + @Autowired + private ReceiveRecordManager receiveRecordManager; /** * 新的独立事务manager */ @@ -8978,8 +8987,8 @@ public String loadThirdPartyTousseReceiveRecordList(JSONObject params){ JSONObject result = JSONUtil.buildJsonObject(false); PageEntity page = new PageEntity(); - page.setLimit(params.optInt("firstIndex", 10)); - page.setStart(params.optInt("maxResultCount", 0)); + page.setLimit(params.optInt("maxResultCount", 10)); + page.setStart(params.optInt("firstIndex", 0)); //开始时间起止范围条件(格式为yyyy-MM-dd HH:mm:ss;yyyy-MM-dd HH:mm:ss) String receiveDateTimeParam = params.optString("startDate"); Date receiveDateTimeStart = null; @@ -9165,4 +9174,128 @@ return result.toString(); } + /** + * 分页展示消毒供应室中心物品领用记录(HNSETYY-8) + * @return + */ + public String loadReceiveRecordList(JSONObject params){ + JSONObject result = JSONUtil.buildJsonObject(false); + int first = params.optInt("firstIndex", 0); + int maxResult = params.optInt("maxResultCount", 10); + //开始时间起止范围条件(格式为yyyy-MM-dd HH:mm:ss;yyyy-MM-dd HH:mm:ss) + String dateTimeParam = params.optString("startDate"); + Date dateTimeStart = null; + Date dateTimeEnd = null; + String dateTimeCondition = "1=1"; + if(StringUtils.isNotBlank(dateTimeParam)){ + String[] receiveDateTimeArray = StringUtils.split(dateTimeParam, ";"); + if(receiveDateTimeArray.length < 2){ + throw new SystemException("接收时间参数有误"); + } + dateTimeStart = ForgonDateUtils.safelyParseDate(receiveDateTimeArray[0]); + dateTimeEnd = ForgonDateUtils.safelyParseDate(receiveDateTimeArray[1]); + dateTimeCondition = dateQueryAdapter.dateAreaSql("time", receiveDateTimeArray[0], receiveDateTimeArray[1]); + } + List list = receiveRecordManager.getByHql(dateTimeCondition, first, maxResult, "time desc"); + JSONUtil.addSuccess(result, true); + JSONUtil.addProperty(result,"receiveRecords", JSONUtil.toJsonArraytWithSimpleProperty(list,DateTools.COMMON_DATE_HM)); + return result.toString(); + } + + /** + * 查询消毒供应室中心物品领用记录明细(HNSETYY-8) + * @return + */ + public String loadReceiveRecordDetail(JSONObject params){ + JSONObject result = JSONUtil.buildJsonObject(false); + try { + //对vo进行请求参数赋值 + String receiveRecordId = params.optString("receiveRecordId"); + ReceiveRecordVo receiveRecordVo = receiveRecordManager.loadReceiveRecord(receiveRecordId); + if(receiveRecordVo != null){ + JSONUtil.addSuccess(result, true); + JSONUtil.addProperty(result,"receiveRecord", JSONUtil.toJsonObjecttWithSimpleProperty(receiveRecordVo,DateTools.COMMON_DATE_HM)); + JSONUtil.addProperty(result, "receiveRecordItems", JSONUtil.toJsonArraytWithSimpleProperty(receiveRecordVo.getItems(),DateTools.COMMON_DATE_HM)); + } + } catch (Exception e) { + e.printStackTrace(); + result = JSONUtil.buildJsonObject(false, "查询失败:" + e.getMessage()); + } + return result.toString(); + } + + /** + * 在消毒供应室中心物品领用记录模块的上下文,根据条码获取信息(HNSETYY-8) + * @param params + * @return + */ + public String getInfoByBarcode_ReceiveRecord(JSONObject params) { + JSONObject result = JSONUtil.buildJsonObject(true); + String barcode = params.optString("barcode"); + String wareHouseId = params.optString("wareHouseId"); + boolean notShowZeroStorage = CssdUtils.getSystemSetConfigByNameBool("notShowZeroStorage"); + boolean selectAll = !notShowZeroStorage; + Map returnMsg = receiveRecordManager.loadBarcodeDeviceInfo(barcode, wareHouseId, selectAll); + JSONUtil.addDataProperty(result, returnMsg.get("disposablegoods")); + JSONUtil.addProperty(result, "type", DisposableGoods.class.getSimpleName()); + return result.toString(); + } + + /** + * 搜索一次性物品 + * @param params 包括的参数有搜索关键字、仓库id、所属模块 + * @return + */ + public String searchDisposableGoodsData(JSONObject params){ + JSONObject result = JSONUtil.buildJsonObject(false); + String spell = params.optString("spell"); + Long wareHouseId = params.optLong("wareHouseId"); + String moduleName = params.optString("moduleName"); + String spellCondition = ""; + if(StringUtils.isNotBlank(spell)){ + spellCondition = "(spelling like '%"+ spell +"%' or wbCode like '%"+ spell +"%' or name like '%"+ spell +"%')"; + } + String condition = String.format(" where %s and id in (select disposableGoodsID from %s where warehouseID=%s %s)", + spellCondition,DisposableGoodsStock.class.getSimpleName(),wareHouseId,""/*" and amount > 0"*/); + List dgList = diposableGoodsManager.getDisposableGoodsBySql(condition); + JSONUtil.addDataProperty(result, JSONUtil.toJsonArraytWithSimpleProperty(dgList)); + JSONUtil.addSuccess(result, true); + return result.toString(); + } + + /** + * 搜索一次性物品批次信息 + * @param params 包括的参数有一次性物品定义id、仓库id、所属模块 + * @return + */ + public String searchDisposableGoodsBatchData(JSONObject params){ + JSONObject result = JSONUtil.buildJsonObject(false); + String disposableGoodsId = params.optString("disposableGoodsId"); + String wareHouseId = params.optString("wareHouseId"); + String moduleName = params.optString("moduleName"); + boolean notShowZeroStorage = CssdUtils.getSystemSetConfigByNameBool("notShowZeroStorage"); + boolean selectAll = !notShowZeroStorage; + List batchStockList = diposableGoodBatchStockManager.getDisposableGoodsBatchStockByDisposableGoodsId(disposableGoodsId, wareHouseId, selectAll); + JSONUtil.addDataProperty(result, JSONUtil.toJsonArraytWithSimpleProperty(batchStockList,"yyyy-MM-dd")); + JSONUtil.addSuccess(result, true); + return result.toString(); + } + + /** + * 消毒供应室中心物品领用记录保存(HNSETYY-8) + * @return + */ + public String submitReceiveRecord(JSONObject params){ + JSONObject result = JSONUtil.buildJsonObject(false); + ReceiveRecord receiveRecord = new ReceiveRecord(); + JSONObject formParams = params.optJSONObject("formParams"); + JSONArray items = params.optJSONArray("items"); + receiveRecord.setId(formParams.optLong("id")); + receiveRecord.setWarehouseId(formParams.optLong("wareHouseId")); + receiveRecordManager.setReceiveRecordItemsFromParams(receiveRecord, items); + receiveRecordManager.saveReceiveRecord_TRANS_REQUIRED(receiveRecord, null); + JSONUtil.addSuccess(result, true); + return result.toString(); + } + } Index: forgon-tools/src/main/java/com/forgon/tools/json/JSONUtil.java =================================================================== diff -u -r38138 -r39756 --- forgon-tools/src/main/java/com/forgon/tools/json/JSONUtil.java (.../JSONUtil.java) (revision 38138) +++ forgon-tools/src/main/java/com/forgon/tools/json/JSONUtil.java (.../JSONUtil.java) (revision 39756) @@ -547,6 +547,17 @@ * @return */ public static JSONObject toJsonObjecttWithSimpleProperty(T obj) { + return toJsonObjecttWithSimpleProperty(obj,"yyyy-MM-dd HH:mm:ss"); + } + + + /** + * 仅将基本类型的属性进行json对象的转换(对上一个方法进行重载,增加日期类型转换格式,支持动态传日期类型转换格式的参数) + * @param obj 转换的对象 + * @param dateFormatPattern 日期转换格式 + * @return + */ + public static JSONObject toJsonObjecttWithSimpleProperty(T obj,String dateFormatPattern) { // JsonConfig不设为全局变量,避免并发访问导致问题,以后可考虑采用ThreadLocal方式 JsonConfig config = new JsonConfig(); // 这段代码可以解决Integer、Double类型的被默认转换为0的问题,这样null将替换0成为默认转换值.其它类型的设置类似. @@ -571,7 +582,7 @@ return JSONNull.getInstance(); } }); - config.registerJsonValueProcessor(Date.class, new DateJsonValueProcessor("yyyy-MM-dd HH:mm:ss")); + config.registerJsonValueProcessor(Date.class, new DateJsonValueProcessor(dateFormatPattern)); PropertyFilter propertyFilter = new SimpleTypeJsonPropertyFilter(); config.setJsonPropertyFilter(propertyFilter); config.setCycleDetectionStrategy(CycleDetectionStrategy.LENIENT); @@ -584,6 +595,16 @@ * @return */ public static JSONArray toJsonArraytWithSimpleProperty(Collection objs) { + return toJsonArraytWithSimpleProperty(objs, "yyyy-MM-dd HH:mm:ss"); + } + + /** + * 仅将基本类型的属性进行json数组的转换(对上一个方法进行重载,增加日期类型转换格式,支持动态传日期类型转换格式的参数) + * @param objs 集合对象 + * @param dateFormatPattern 日期转换格式 + * @return + */ + public static JSONArray toJsonArraytWithSimpleProperty(Collection objs,String dateFormatPattern) { // JsonConfig不设为全局变量,避免并发访问导致问题,以后可考虑采用ThreadLocal方式 JsonConfig config = new JsonConfig(); // 这段代码可以解决Integer、Double类型的被默认转换为0的问题,这样null将替换0成为默认转换值.其它类型的设置类似. @@ -608,7 +629,7 @@ return JSONNull.getInstance(); } }); - config.registerJsonValueProcessor(Date.class, new DateJsonValueProcessor("yyyy-MM-dd HH:mm:ss")); + config.registerJsonValueProcessor(Date.class, new DateJsonValueProcessor(dateFormatPattern)); PropertyFilter propertyFilter = new SimpleTypeJsonPropertyFilter(); config.setJsonPropertyFilter(propertyFilter); config.setCycleDetectionStrategy(CycleDetectionStrategy.LENIENT); Index: ssts-receiverecord/src/main/java/com/forgon/disinfectsystem/receiverecord/action/ReceiveRecordAction.java =================================================================== diff -u -r36172 -r39756 --- ssts-receiverecord/src/main/java/com/forgon/disinfectsystem/receiverecord/action/ReceiveRecordAction.java (.../ReceiveRecordAction.java) (revision 36172) +++ ssts-receiverecord/src/main/java/com/forgon/disinfectsystem/receiverecord/action/ReceiveRecordAction.java (.../ReceiveRecordAction.java) (revision 39756) @@ -121,77 +121,9 @@ } // items列表 - setReceiveRecordItemsFromParams(entry, items); + receiveRecordManager.setReceiveRecordItemsFromParams(entry, items); } - // 设置items参数 - private void setReceiveRecordItemsFromParams(ReceiveRecord entry, - String items) { - // items列表 - List receiveRecordItems = entry.getItems(); - JSONArray itemsArray = JSONArray.fromObject(items); - int size = itemsArray.size(); - for (int i = 0; i < size; ++i) { - JSONObject obj = itemsArray.getJSONObject(i); - if (obj != null) { - ReceiveRecordItem receiveRecordItem = new ReceiveRecordItem(); - Long itemId = JSONUtil.optLong(obj, "id", null); - receiveRecordItem.setId(itemId);// itemID - receiveRecordItem.setGoodsName(obj.optString("name")); - - Long disposableGoodsId = JSONUtil.optLong(obj, - "disposableGoodsId", null);// 一次性物品id - Long disposableGoodsStockId = JSONUtil.optLong(obj, - "disposableGoodsStockId", null); - Long disposableGoodsBatchId = JSONUtil.optLong(obj, - "disposableGoodsBatchId", null); - Long disposableGoodsBatchStockId = JSONUtil.optLong(obj, - "disposableGoodsBatchStockId", null); - receiveRecordItem.setDisposableGoodsId(disposableGoodsId); - receiveRecordItem.setDisposableGoodsStockId(disposableGoodsStockId); - receiveRecordItem.setDisposableGoodsBatchId(disposableGoodsBatchId); - receiveRecordItem.setDisposableGoodsBatchStockId(disposableGoodsBatchStockId); - - Long objID = JSONUtil.optLong(obj, "objID", null);// objID, 批次或者材料id - Long expensiveDisposablegoodsId = JSONUtil.optLong(obj, "expensiveDisposablegoodsId", null);// 高值耗材id - receiveRecordItem.setObjID(objID); - receiveRecordItem.setExpensiveDisposablegoodsId(expensiveDisposablegoodsId); - - int amount = Integer.valueOf(obj.optString("amount"));// 数量 - receiveRecordItem.setAmount(amount); - - String priceStr = obj.optString("price"); - if(StringUtils.isBlank(priceStr)){ - throw new SystemException(obj.optString("name") + "的价格为空,不能保存,请检查材料定义的设置!"); - } - double price = Double.valueOf(priceStr);// 价格 - receiveRecordItem.setPrice(price); - - String type = obj.optString("type");// type - receiveRecordItem.setType(type); - - //设置diposableGoodBatchStock_id - if (DisposableGoods.TYPE_NAME.equals(type) && disposableGoodsBatchStockId != null){ - DisposableGoodsBatchStock dgbs = diposableGoodBatchStockManager.getDiposableGoodBatchStockById(disposableGoodsBatchStockId.toString()); - if (dgbs != null){ - receiveRecordItem.setDiposableGoodBatchStock(dgbs); - } - } - //设置materialDefinition_id - if (MaterialDefinition.TYPE_NAME.equals(type) && objID != null){ - MaterialDefinition materialDefinition = materialDefinitionManager.get(objID); - if (materialDefinition != null){ - receiveRecordItem.setMaterialDefinition(materialDefinition); - } - } - - receiveRecordItem.setReceiveRecord(entry); - - receiveRecordItems.add(receiveRecordItem); - } - } - } - // 构造更新参数 private void buildReceiveRecordParamsForUpdate(ReceiveRecord original, ReceiveRecord entry) { @@ -209,12 +141,6 @@ setReceiveRecordPropertiesFromParams(entry, null, items); } - // 构造保存参数 - private void buildReceiveRecordParamsForSave(ReceiveRecord record) { - String items = StrutsParamUtils.getPraramValue("itemsStr", ""); - setReceiveRecordItemsFromParams(record, items); - } - // 加了并发控制 public String saveReceiveRecord() { String result = "保存成功"; @@ -239,8 +165,8 @@ } else { // 保存入库单,里面的item一定都是新建标识号对象,并且需要更新批次属性。 modified = receiveRecord; - buildReceiveRecordParamsForSave(modified); - + String items = StrutsParamUtils.getPraramValue("itemsStr", ""); + receiveRecordManager.setReceiveRecordItemsFromParams(modified, items); receiveRecordManager.saveReceiveRecord_TRANS_REQUIRED(modified, returnMsg); } @@ -273,93 +199,25 @@ // } // } -public String loadBarcodeDeviceInfo() { + public String loadBarcodeDeviceInfo() { String barcode = StrutsParamUtils.getPraramValue("barcode", ""); String warehouseId = StrutsParamUtils.getPraramValue("warehouseId", ""); boolean selectAll = StrutsParamUtils.getBoolPraramValue("selectAll", true); - Map returnMsg = new HashMap(); - returnMsg.put("success", false); + Map returnMsg = null; + // 需要从发货单和退货记录生成该批次可以退货的价格列表 try { - if (StringUtils.isBlank(barcode)) { - throw new RuntimeException("条码不能为空!"); - } - BarcodeDevice barcodeDevice = barcodeManager - .getBarcodeByBarcode(barcode); - if (barcodeDevice == null){ - List disposableGoodsList = diposableGoodsManager.getByProperty("barcode", barcode); - if(CollectionUtils.isEmpty(disposableGoodsList)){ - throw new RuntimeException("查无此物品"); - } - List batchStocks = diposableGoodBatchStockManager - .getDisposableGoodsBatchStockByDisposableGoodsId(disposableGoodsList.get(0).getId()+"",warehouseId, selectAll); - String batchs = "[]"; - if(batchStocks != null){ - batchs = JSONUtil.toJSONStringEx(batchStocks,true,DisposableGoodsBatchStock.filterProperties); - } - returnMsg.put("barcodeType", BarcodeDevice.BARCODE_TYPE_DIPOSABLEGOODS); - returnMsg.put("disposablegoodsBatchStock", batchs); - returnMsg.put("disposablegoods", JSONUtil.toJSONString(disposableGoodsList.get(0))); - }else{ - Map disposablegoods = null; - if(barcodeDevice instanceof ExpensiveDisposablegoods){// 高值耗材处理 - disposablegoods = buildExpensiveDisposablegoodsInfo((ExpensiveDisposablegoods)barcodeDevice); - returnMsg.put("barcodeType", BarcodeDevice.BARCODE_TYPE_EXPENSIVEDIPOSABLEGOODS); - returnMsg.put("disposablegoods", disposablegoods); - }else{ - throw new RuntimeException("请扫描高值耗材条码"); - } - } - - returnMsg.put("success", true); + returnMsg = receiveRecordManager.loadBarcodeDeviceInfo(barcode, warehouseId, selectAll); } catch (Exception e) { e.printStackTrace(); returnMsg.put("errMsg", e.getMessage()); + }finally{ + StrutsResponseUtils.output(JSONUtil.toJSONString(returnMsg,true)); } - try { - StrutsParamUtils.getResponse().setCharacterEncoding("UTF-8"); - String jsonStr = JSONUtil.toJSONString(returnMsg,true); - StrutsParamUtils.getResponse().getWriter().print(jsonStr); - } catch (IOException e) { - e.printStackTrace(); - } return null; } - -private Map buildExpensiveDisposablegoodsInfo(ExpensiveDisposablegoods expensiveDisposablegoods) { - Map diposableGood = new HashMap(); - Double cost = expensiveDisposablegoods.getPrice(); - String orgUnitCoding = AcegiHelper.getCurrentOrgUnitCode(); - String fluctuationPrice = supplyRoomConfigManager.getDisposableGoodsFluctuationPriceDoubleByOrgUnitCoding(orgUnitCoding, cost)+ ""; - DisposableGoodsBatchStock disposableGoodsBatchStock = expensiveDisposablegoods.getDisposableGoodsBatchStock(); - String barcode = expensiveDisposablegoods.getBarcode(); - String batchNumber = disposableGoodsBatchStock.getBatchNumber(); - String showName = disposableGoodsBatchStock.getDiposableGoods() - .getShowNameForSmallestUnit(); - diposableGood.put("disposableGoodsID", disposableGoodsBatchStock.getDisposableGoodsId()); - diposableGood.put("disposableGoodsStockID", disposableGoodsBatchStock.getDiposableGoods().getId()); - diposableGood.put("disposableGoodsBatchID", disposableGoodsBatchStock.getDisposableGoodsBatchId()); - diposableGood.put("disposableGoodsBatchStockID", disposableGoodsBatchStock.getId()); - diposableGood.put("expensiveDisposablegoodsId", expensiveDisposablegoods.getId()); - diposableGood.put("id", disposableGoodsBatchStock.getDiposableGoods().getId()); - diposableGood.put("goodsType", DisposableGoods.TYPE_EXPENSIVEDIPOSABLEGOODS); - diposableGood.put("barcode", barcode); - diposableGood.put("showName", showName); - diposableGood.put("batchNumber", batchNumber); - diposableGood.put("supplierName", disposableGoodsBatchStock.getSupplierName()); - diposableGood.put("cost", cost); - diposableGood.put("price", cost); - diposableGood.put("expDate", disposableGoodsBatchStock.getExpDateStr("yyyy-MM-dd")); - diposableGood.put("fluctuationPrice", fluctuationPrice); - Long storage = disposableGoodsBatchStock.getStorage(); - if (storage == null || storage < 0) { - storage = 0l; - } - diposableGood.put("storage", storage); - return diposableGood; - } public void loadReceiveRecord() { String id = StrutsParamUtils.getPraramValue("id", ""); if (StringUtils.isNotBlank(id) && !id.equals("0")) { Index: build.gradle =================================================================== diff -u -r39741 -r39756 --- build.gradle (.../build.gradle) (revision 39741) +++ build.gradle (.../build.gradle) (revision 39756) @@ -1258,6 +1258,7 @@ compile (project(":ssts-qualitymon")) compile (project(":ssts-recallrecord")) compile (project(":ssts-storagelocation")) + compile (project(":ssts-receiverecord")) } } Index: ssts-receiverecord/src/main/java/com/forgon/disinfectsystem/receiverecord/service/ReceiveRecordManager.java =================================================================== diff -u -r34671 -r39756 --- ssts-receiverecord/src/main/java/com/forgon/disinfectsystem/receiverecord/service/ReceiveRecordManager.java (.../ReceiveRecordManager.java) (revision 34671) +++ ssts-receiverecord/src/main/java/com/forgon/disinfectsystem/receiverecord/service/ReceiveRecordManager.java (.../ReceiveRecordManager.java) (revision 39756) @@ -11,13 +11,15 @@ import com.forgon.disinfectsystem.entity.basedatamanager.instrumentinstance.InstrumentInstance; import com.forgon.disinfectsystem.entity.receiverecord.ReceiveRecord; +import com.forgon.disinfectsystem.receiverecord.vo.ReceiveRecordVo; +import com.forgon.tools.hibernate.BasePoManager; /** * @author JamZhou * * 2012-11-6 下午5:38:05 */ -public interface ReceiveRecordManager { +public interface ReceiveRecordManager extends BasePoManager { public ReceiveRecord getReceiveRecordById(String id); @@ -49,4 +51,22 @@ * @param itemsArray 明细 disposableGoodsBatchStockId和amount必须的 */ public void setReceiveRecordItemsFromParams(ReceiveRecord receiveRecord, JSONArray itemsArray); + + /** + * 扫描条码 + * @param barcode 条码 + * @param warehouseId 仓库id + * @param selectAll 是否选择全部 + * @return + */ + public Map loadBarcodeDeviceInfo(String barcode,String warehouseId,boolean selectAll); + + /** + * 设置items参数 + * @param entry 领用记录实体对象 + * @param items 领用物品明细信息 + */ + public void setReceiveRecordItemsFromParams(ReceiveRecord entry, String items); + + public ReceiveRecordVo loadReceiveRecord(String id); } Index: ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/receiverecord/ReceiveRecord.java =================================================================== diff -u -r39244 -r39756 --- ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/receiverecord/ReceiveRecord.java (.../ReceiveRecord.java) (revision 39244) +++ ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/receiverecord/ReceiveRecord.java (.../ReceiveRecord.java) (revision 39756) @@ -3,9 +3,11 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; +import java.util.Optional; import javax.persistence.Entity; +import org.apache.commons.collections.CollectionUtils; import org.hibernate.annotations.DynamicInsert; import org.hibernate.annotations.DynamicUpdate; @@ -23,6 +25,7 @@ import org.hibernate.annotations.CascadeType; import com.fasterxml.jackson.annotation.JsonIgnore; +import com.forgon.tools.MathTools; /** * 供应室领用物品记录 @@ -91,7 +94,14 @@ */ @JsonIgnore private List items = new ArrayList(); + + /** + * 领用物品总数量-(HNSETYY-8) + */ + private Long amount; + + /** * 回写记录id */ private Long inventoryWriteBackEntryId; @@ -167,6 +177,24 @@ this.totalPrice = totalPrice; } + @Transient + public Long getAmount() { + Long totalAmount = 0L; + /*Optional.of(items).orElse(new ArrayList()).stream().forEach(item -> { + totalAmount = MathTools.add(totalAmount, item.getAmount()).longValue(); + });*/ + if(CollectionUtils.isNotEmpty(items)){ + for(ReceiveRecordItem item : items){ + totalAmount = MathTools.add(totalAmount, item.getAmount()).longValue(); + } + } + return totalAmount; + } + + public void setAmount(Long amount) { + this.amount = amount; + } + public Long getInventoryWriteBackEntryId() { return inventoryWriteBackEntryId; }