Index: ssts-diposablegoods/src/main/java/com/forgon/disinfectsystem/diposablegoods/service/DiposableGoodBatchStockManager.java =================================================================== diff -u -r13551 -r13906 --- ssts-diposablegoods/src/main/java/com/forgon/disinfectsystem/diposablegoods/service/DiposableGoodBatchStockManager.java (.../DiposableGoodBatchStockManager.java) (revision 13551) +++ ssts-diposablegoods/src/main/java/com/forgon/disinfectsystem/diposablegoods/service/DiposableGoodBatchStockManager.java (.../DiposableGoodBatchStockManager.java) (revision 13906) @@ -24,7 +24,7 @@ public DisposableGoodsBatchStock getDiposableGoodBatchStock( String disposableGoodsStockId, String batchNumber); - public String getDiposableGoodBatchByName(String goodsName, String expDate); + public String getEarliestNonExpiredDisposableGoodsBatchStock(Long disposableGoodsStockId, String startDate); public DisposableGoodsBatchStock getDiposableGoodBatchStockById(String id); Index: ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/assestmanagement/DisposableGoodsBatch.java =================================================================== diff -u -r12968 -r13906 --- ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/assestmanagement/DisposableGoodsBatch.java (.../DisposableGoodsBatch.java) (revision 12968) +++ ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/assestmanagement/DisposableGoodsBatch.java (.../DisposableGoodsBatch.java) (revision 13906) @@ -38,7 +38,7 @@ private String producingArea;// 产地 - + public static final String EXP_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss"; public static final String[] filterProperties = { "identifications","goodsBatchs","ColumnNameAndPoPropertyNameMap"}; public DisposableGoodsBatch() { Index: ssts-invoice/src/main/java/com/forgon/disinfectsystem/invoicemanager/service/InvoiceManagerImpl.java =================================================================== diff -u -r13904 -r13906 --- ssts-invoice/src/main/java/com/forgon/disinfectsystem/invoicemanager/service/InvoiceManagerImpl.java (.../InvoiceManagerImpl.java) (revision 13904) +++ ssts-invoice/src/main/java/com/forgon/disinfectsystem/invoicemanager/service/InvoiceManagerImpl.java (.../InvoiceManagerImpl.java) (revision 13906) @@ -2998,10 +2998,11 @@ return buildErrorMsgJsonResult(String.format("[%s]库存不足!", name)); } // ***验证一次性物品*** - Date expDate = disposableGoodsBatch.getExpDate(); - String expDateStr = DateFormatUtils.format(expDate, + Date scannedExpDate = disposableGoodsBatch.getExpDate(); + Date curDate = new Date(); + String scannedExpDateStr = DateFormatUtils.format(scannedExpDate, "yyyy-MM-dd HH:mm:ss"); - if (new Date().after(expDate)) {// 一次性物品失效 + if (curDate.after(scannedExpDate)) {// 一次性物品失效 return buildErrorMsgJsonResult(String.format("[%s]已过期", name)); } @@ -3038,7 +3039,7 @@ data.addProperty("fluctuationPrice", fluctuationPrice); data.addProperty("typeInfoOnScanned", typeInfoOnScanned.toString()); String batchNumber = diposableGoodBatchStockManager - .getDiposableGoodBatchByName(name, expDateStr); + .getEarliestNonExpiredDisposableGoodsBatchStock(disposableGoodsBatchStock.getDisposableGoodsStockId(), scannedExpDateStr); if (StringUtils.isNotBlank(batchNumber)) { String tipsStr = String.format("批次为[%s]的[%s]快到失效期,请优先发货", Index: ssts-diposablegoods/src/main/java/com/forgon/disinfectsystem/diposablegoods/service/DiposableGoodBatchStockManagerImpl.java =================================================================== diff -u -r13551 -r13906 --- ssts-diposablegoods/src/main/java/com/forgon/disinfectsystem/diposablegoods/service/DiposableGoodBatchStockManagerImpl.java (.../DiposableGoodBatchStockManagerImpl.java) (revision 13551) +++ ssts-diposablegoods/src/main/java/com/forgon/disinfectsystem/diposablegoods/service/DiposableGoodBatchStockManagerImpl.java (.../DiposableGoodBatchStockManagerImpl.java) (revision 13906) @@ -7,22 +7,26 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; +import java.util.Date; import java.util.List; import java.util.Set; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.time.DateFormatUtils; import org.apache.log4j.Logger; import com.forgon.databaseadapter.service.DateQueryAdapter; import com.forgon.disinfectsystem.barcode.service.BarcodeManager; import com.forgon.disinfectsystem.basedatamanager.warehouse.service.WareHouseManager; import com.forgon.disinfectsystem.entity.assestmanagement.DisposableGoods; +import com.forgon.disinfectsystem.entity.assestmanagement.DisposableGoodsBatch; import com.forgon.disinfectsystem.entity.assestmanagement.DisposableGoodsBatchStock; import com.forgon.disinfectsystem.entity.assestmanagement.DisposableGoodsIdentification; import com.forgon.disinfectsystem.entity.assestmanagement.DisposableGoodsStock; import com.forgon.disinfectsystem.vo.DiposableGoodsStorageVo; import com.forgon.serialnumber.service.SerialNumManager; +import com.forgon.tools.Constants; import com.forgon.tools.db.DatabaseUtil; import com.forgon.tools.db.InitDbConnection; import com.forgon.tools.hibernate.ObjectDao; @@ -144,11 +148,15 @@ @SuppressWarnings("unchecked") @Override - public String getDiposableGoodBatchByName(String goodsName, String expDate) { - if (StringUtils.isNotBlank(goodsName)) { - String sql = " where po.diposableGoods.name = '" + goodsName - + "' and po.storage > 0 and po.expDate < " - + dateQueryAdapter.dateAdapter(expDate) + public String getEarliestNonExpiredDisposableGoodsBatchStock(Long disposableGoodsStockId, String startDate){ + if (DatabaseUtil.isPoIdValid(disposableGoodsStockId)) { + Date curDate = new Date(); + String curDateStr = DateFormatUtils.format(curDate, + DisposableGoodsBatch.EXP_DATE_FORMAT); + String sql = " where po.diposableGoods.id = " + disposableGoodsStockId + + " and po.storage > 0 and po.expDate < " + + dateQueryAdapter.dateAdapter(startDate) + +" and po.expDate > "+dateQueryAdapter.dateAdapter(curDateStr) + " order by po.expDate asc"; List disposableGoodsBatchStockList = objectDao .findBySql(DisposableGoodsBatchStock.class.getSimpleName(), Index: ssts-webservice/src/main/java/com/forgon/disinfectsystem/webservice/security/service/WebServiceManagerImpl.java =================================================================== diff -u -r13424 -r13906 --- ssts-webservice/src/main/java/com/forgon/disinfectsystem/webservice/security/service/WebServiceManagerImpl.java (.../WebServiceManagerImpl.java) (revision 13424) +++ ssts-webservice/src/main/java/com/forgon/disinfectsystem/webservice/security/service/WebServiceManagerImpl.java (.../WebServiceManagerImpl.java) (revision 13906) @@ -830,278 +830,7 @@ // return invoiceManager.getInfoByBarcode(params).toString(); return invoiceManager.getInfoByBarcodeForInvoiceScan(params).toString(); } - public String loadGoodsByBarcode_old(String barcode,String orgUnitCoding) { - if (StringUtils.isBlank(barcode)) { - return buildErrorMsgJsonResult("无此物品!"); - } - BarcodeDevice barcodeDevice = barcodeManager.getBarcodeByBarcode(barcode); - if(barcodeDevice == null){ - return buildErrorMsgJsonResult("无此物品!"); - } - - if (barcodeDevice instanceof TousseInstance) { - InvoiceGoodsVo vo = new InvoiceGoodsVo(); - vo.setBarcode(barcode); - TousseInstance tousseInstance = (TousseInstance) barcodeDevice; - TousseDefinition tousseDefinition = tousseInstance.getTousseDefinition(); - String name = tousseDefinition.getName(); - - SupplyRoomConfig cofig = supplyRoomConfigManager.getSystemParamsObj(); - Boolean warningTousseWhetherDelivery = cofig.getWarningTousseWhetherDelivery(); - - // 消毒物品不追溯,发货扫描固定条码 - if (tousseInstance.getUnTraceableTousse() - && TousseDefinition.PACKAGE_TYPE_DISINFECTION - .equals(tousseDefinition.getTousseType())) { - - Collection resultTousseInstanceList = invoiceManager - .getDisinfectionTousseInstance(orgUnitCoding, - tousseDefinition); - // 过滤 - resultTousseInstanceList = CollectionUtils.select( - resultTousseInstanceList, AllPredicate.allPredicate( - InvoiceManagerImpl.checkStatusForInvoice, - TousseInstanceManagerImpl - .isNotExpire(new Date()), - tousseInstanceManager - .checkTousseInstanceHasNotRecall())); - - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); - JSONArray data = new JSONArray(); - for(TousseInstance disinfectionTousseInstance : resultTousseInstanceList){ - InvoiceGoodsVo vo2 = new InvoiceGoodsVo(); - - // 验证是否超过预警期 - Date validUntil = tousseInstance.getValidUntil(); - Date warningUntil = tousseInstance.getWarningUntil(); - if (DateTools.isDuringWarningPeriod(validUntil, warningUntil, new Date())) { - if(!warningTousseWhetherDelivery) - continue; - // 器械包通过batchNumber来传递预警期 - vo2.setBatchNumber(sdf.format(warningUntil)); - } - - vo2.setBarcode(barcode); - vo2.setName(disinfectionTousseInstance.getTousseName()); - vo2.setShowTousseName(disinfectionTousseInstance.getShowTousseName()); - vo2.setIsTracable("否"); - vo2.setStorage(""+1); - vo2.setPrice(""+disinfectionTousseInstance.getPrice()); - vo2.setFluctuationPrice(""+disinfectionTousseInstance.getFluctuationPrice()); - vo2.setEndDate(""); - vo2.setBatchNumber(""); - vo2.setTousseType(disinfectionTousseInstance.getTousseDefinition().getTousseType()); - vo2.setSterilizerName(""); - vo2.setFrequency(""); - vo2.setDiposable("否"); - vo2.setBarcode(disinfectionTousseInstance.getBarcode()); - vo2.setTousseDefinitionId(""+disinfectionTousseInstance.getTousseDefinition().getId()); - - data.add(JSONObject.fromObject(vo2)); - } - - if (data.isEmpty()) - return buildErrorMsgJsonResult("没有可发货的此类消毒物品"); - - return new JSONStringer().object() - .key("success").value(true) - .key("type").value("tousseInstanceList") - .key("data").value(data) - .endObject().toString(); - } - - // 到达此处即为非消毒物品 - - // 验证器械包状态是否能发货 - if (!InvoiceManagerImpl.checkStatusForInvoice.evaluate(tousseInstance)) { - return buildErrorMsgJsonResult("器械包状态异常:" + tousseInstance.getStatus()); - } - Date validUntil = tousseInstance.getValidUntil(); - if(DateTools.isExpire(validUntil, new Date())){ - return buildErrorMsgJsonResult("器械包已过期"); - } - if(!tousseInstanceManager.checkTousseInstanceHasNotRecall().evaluate(tousseInstance)){ - return buildErrorMsgJsonResult("器械包已被召回"); - } - - // 验证是否超过预警期 - Date warningUntil = tousseInstance.getWarningUntil(); - if (DateTools.isDuringWarningPeriod(validUntil, warningUntil, new Date())) { - if(warningTousseWhetherDelivery){ - // 器械包通过batchNumber来传递预警期 - vo.setBatchNumber(new SimpleDateFormat("yyyy-MM-dd").format(warningUntil)); - }else{ - return buildErrorMsgJsonResult("处于预警期不能发货"); - } - - } - - String showTousseName = tousseInstance.getShowTousseName(); - String tousseDefinitionId = tousseInstance - .getTousseDefinition().getId().toString(); - - // 获取灭菌成功的灭菌记录 - String sterilizerName = tousseInstance.getSterilizerName(); - String frequency = tousseInstance.getSterileFrequency(); - - vo.setName(name); - vo.setShowTousseName(showTousseName); - vo.setIsTracable("否"); - vo.setStorage(""+1); - vo.setPrice(""+tousseInstance.getPrice()); - vo.setFluctuationPrice(""+tousseInstance.getFluctuationPrice()); - vo.setEndDate(tousseInstance.getSterileEndTime()); - vo.setBatchNumber(""); - vo.setTousseType(tousseDefinition.getTousseType()); - vo.setSterilizerName(sterilizerName); - vo.setFrequency(frequency); - vo.setDiposable("否"); - vo.setTousseDefinitionId(tousseDefinitionId); - - JSONObject data = JSONObject.fromObject(vo); - return new JSONStringer().object() - .key("success").value(true) - .key("type").value("tousseInstance") - .key("data").value(data) - .endObject().toString(); - - } else if (barcodeDevice instanceof DisposableGoodsBatch) { - // 一次性物品 - String tips = StringUtils.EMPTY; - InvoiceGoodsVo vo = new InvoiceGoodsVo(); - vo.setBarcode(barcode); - DisposableGoodsBatch diposableGoodBatch = (DisposableGoodsBatch) barcodeDevice; - DisposableGoods diposableGoods = diposableGoodBatch.getDiposableGoods(); - String name = diposableGoods.getName(); - String displayName = name; - String specification = diposableGoods.getSpecification(); - if (StringUtils.isNotBlank(specification)) { - displayName = String.format("%s[%s]", name, specification); - } - Date date = diposableGoodBatch.getExpDate(); - if (new Date().after(date)) {// 一次性物品失效 - return buildErrorMsgJsonResult(String.format("[%s]已过期!", displayName)); - } - String expDate = new SimpleDateFormat( - "yyyy-MM-dd HH:mm:ss").format(date); - String batchNumber = diposableGoodBatchStockManager - .getDiposableGoodBatchByName(name, expDate); - if (StringUtils.isNotBlank(batchNumber)) { - tips = "有更早的批次可用"; - } - - // 拿到不同价格标识号的库存 - Map storages = new LinkedHashMap(); - DisposableGoodsBatchStock disposableGoodsBatchStock = null; - List identifications = disposableGoodsBatchStock.getIdentifications() ; - Collections.sort(identifications); - for (DisposableGoodsIdentification identity :identifications) { - if (identity.getAmount() > 0) { - if (storages.get(identity.getPrice()) != null) { - storages.put(identity.getPrice(), - storages.get(identity.getPrice()) - + identity.getAmount()); - } else { - storages.put(identity.getPrice(), - identity.getAmount()); - } - } - } - String price = null; - String fluctuationPrice = null; - String storage = null; - for (Map.Entry storageOfPrice : storages - .entrySet()) { - Double tempPrice = storageOfPrice.getKey(); - SupplyRoomConfig config = supplyRoomConfigManager.getSystemParamsObj(); - double f = config.getDiposablePriceFluctuation();//浮动价格 - if(f <= 0){ - if (StringUtils.isBlank(fluctuationPrice)) { - fluctuationPrice = tempPrice.toString(); - } else { - fluctuationPrice += "#%" + tempPrice.toString(); - } - }else{ - double fPrice = MathTools.mul(tempPrice, f, 2); - if (StringUtils.isBlank(fluctuationPrice)) { - fluctuationPrice = "" + fPrice; - } else { - fluctuationPrice += "#%" + fPrice; - } - } - - if (StringUtils.isBlank(price)) { - price = tempPrice.toString(); - } else { - price += "#%" + tempPrice.toString(); - } - - if (StringUtils.isBlank(storage)) { - storage = storageOfPrice.getValue().toString(); - } else { - storage += "#%" - + storageOfPrice.getValue().toString(); - } - } - vo.setName(displayName); - vo.setShowTousseName(displayName); - vo.setDiposable("是"); - vo.setPrice(price); - vo.setFluctuationPrice(fluctuationPrice); - vo.setStorage(storage); - vo.setBatchNumber(diposableGoodBatch.getBatchNumber()); - vo.setTousseType("一次性物品"); - vo.setSterilizerName("-"); - vo.setFrequency("-"); - String externalCode = diposableGoodBatch - .getDiposableGoods().getExternalCode(); - externalCode = externalCode == null ? "" : externalCode; - vo.setExternalCode(externalCode); - - JSONObject data = JSONObject.fromObject(vo); - return new JSONStringer().object() - .key("success").value(true) - .key("tips").array().value(tips).endArray() - .key("type").value("diposable") - .key("data").value(data) - .endObject().toString(); - - } else if (barcodeDevice instanceof User) { - // 用户 - JSONObject data = new JSONObject(); - data.put("fullName", ((User)barcodeDevice).getFullName()); - return new JSONStringer().object() - .key("success").value(true) - .key("type").value("user") - .key("data").value(data) - .endObject().toString(); - - }else if(barcodeDevice instanceof Container){ - //发货扫描篮筐条码 - Map multiResult = invoiceManager - .loadSterilizeBasketInsideTousse(barcode, orgUnitCoding); - boolean success = (Boolean)multiResult.get("success"); - if(!success){ - String errorMsg = (String)multiResult.get("error"); - return buildErrorMsgJsonResult(errorMsg); - } - - Collection vos = (Collection) multiResult.get("data"); - Collection tipsList = (Collection) multiResult.get("tips"); - - return new JSONStringer().object().key("success").value(true) - .key("barcode").value(barcode).key("type") - .value("tousseInstancesInContainer") - .key("data").value(JSONArray.fromObject(vos)) - .key("tips").value(JSONArray.fromObject(tipsList)) - .endObject().toString(); - - } else { - return buildErrorMsgJsonResult("无此物品!"); - } - } - private static String buildErrorMsgJsonResult(String errorMsg) { return new JSONStringer().object().key("success").value(false) .key("error").value(errorMsg).endObject().toString(); Index: ssts-web/src/main/webapp/disinfectsystem/invoice/invoiceView.js =================================================================== diff -u -r13902 -r13906 --- ssts-web/src/main/webapp/disinfectsystem/invoice/invoiceView.js (.../invoiceView.js) (revision 13902) +++ ssts-web/src/main/webapp/disinfectsystem/invoice/invoiceView.js (.../invoiceView.js) (revision 13906) @@ -796,25 +796,7 @@ clicksToEdit : 1,// 设置点击几次才可编辑 selModel : new top.Ext.grid.RowSelectionModel({ singleSelect : false - }), - tbar : [{ - text : '扫描条码 :' - },{ - xtype : 'textfield', - id : 'depart1', - name : 'depart1', - width : 185, - enableKeyEvents : true, - listeners : { - render : function(c) { - c.getEl().on('keypress',function(e) { - if (e.getKey() == 13) {// 输入;号键,grid重新加载 - loadTousseInstance(id,type); - } - }); - } - } - }] + }) })] },{ layout : 'form', Index: ssts-invoice/src/main/java/com/forgon/disinfectsystem/invoicemanager/action/InvoiceAction.java =================================================================== diff -u -r13899 -r13906 --- ssts-invoice/src/main/java/com/forgon/disinfectsystem/invoicemanager/action/InvoiceAction.java (.../InvoiceAction.java) (revision 13899) +++ ssts-invoice/src/main/java/com/forgon/disinfectsystem/invoicemanager/action/InvoiceAction.java (.../InvoiceAction.java) (revision 13906) @@ -784,100 +784,6 @@ return; } - } else if (barcodeDevice != null - && barcodeDevice instanceof DisposableGoodsBatch) {// 一次性物品 - DisposableGoodsBatch diposableGoodBatch = (DisposableGoodsBatch) barcodeDevice; - DisposableGoods diposableGoods = diposableGoodBatch - .getDiposableGoods(); - String name = diposableGoods.getName(); - String specification = diposableGoods.getSpecification(); - if (StringUtils.isNotBlank(specification)) { - name += "[" + specification + "]"; - } - Date date = diposableGoodBatch.getExpDate(); - // 拿到不同价格标识号的库存 - Map storages = new LinkedHashMap(); - DisposableGoodsBatchStock disposableGoodsBatchStock = null; - List identifications = disposableGoodsBatchStock - .getIdentifications(); - Collections.sort(identifications); - for (DisposableGoodsIdentification identity : identifications) { - if (identity.getAmount() > 0) { - if (storages.get(identity.getPrice()) != null) { - storages.put(identity.getPrice(), - storages.get(identity.getPrice()) - + identity.getAmount()); - } else { - storages.put(identity.getPrice(), - identity.getAmount()); - } - } - } - String price = null; - String fluctuationPrice = null; - String storage = null; - for (Map.Entry storageOfPrice : storages - .entrySet()) { - Double tempPrice = storageOfPrice.getKey(); - SupplyRoomConfig config = supplyRoomConfigManager - .getSystemParamsObj(); - double f = config.getDiposablePriceFluctuation();// 浮动价格 - if (f <= 0) { - if (StringUtils.isBlank(fluctuationPrice)) { - fluctuationPrice = tempPrice.toString(); - } else { - fluctuationPrice += "#%" + tempPrice.toString(); - } - } else { - double fPrice = new BigDecimal(tempPrice) - .multiply(new BigDecimal(f)) - .setScale(2, BigDecimal.ROUND_HALF_UP) - .doubleValue(); - if (StringUtils.isBlank(fluctuationPrice)) { - fluctuationPrice = "" + fPrice; - } else { - fluctuationPrice += "#%" + fPrice; - } - } - - if (StringUtils.isBlank(price)) { - price = tempPrice.toString(); - } else { - price += "#%" + tempPrice.toString(); - } - - if (StringUtils.isBlank(storage)) { - storage = storageOfPrice.getValue().toString(); - } else { - storage += "#%" + storageOfPrice.getValue().toString(); - } - } - vo.setName(name); - vo.setDiposable("是"); - vo.setPrice(price); - vo.setFluctuationPrice(fluctuationPrice); - vo.setStorage(storage); - vo.setBatchNumber(diposableGoodBatch.getBatchNumber()); - vo.setTousseType("一次性物品"); - vo.setSterilizerName("-"); - vo.setFrequency("-"); - String externalCode = diposableGoodBatch - .getDiposableGoods().getExternalCode(); - externalCode = externalCode == null ? "" : externalCode; - vo.setExternalCode(externalCode); - if (new Date().after(date)) {// 一次性物品失效 - validateNotPass("[" + name + "] 已过期!"); - return; - } else { - String expDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss") - .format(date); - String batchNumber = diposableGoodBatchStockManager - .getDiposableGoodBatchByName(name, expDate); - if (StringUtils.isNotBlank(batchNumber)) { - vo.setShowResult("&#批次为 [" + batchNumber + "] 的 [" - + name + "] 快到失效期,请优先发货!"); - } - } } } else { vo.setValidatePass(InvoiceGoodsVo.VALIDATE_PASS_FALSE);