Index: ssts-web/src/main/resources/config/zsykzx/mybatis/syncFromHERP_Mapper.xml =================================================================== diff -u -r12554 -r18787 --- ssts-web/src/main/resources/config/zsykzx/mybatis/syncFromHERP_Mapper.xml (.../syncFromHERP_Mapper.xml) (revision 12554) +++ ssts-web/src/main/resources/config/zsykzx/mybatis/syncFromHERP_Mapper.xml (.../syncFromHERP_Mapper.xml) (revision 18787) @@ -30,7 +30,7 @@ ORDER BY make_date @@ -114,7 +114,7 @@ ORDER BY make_date @@ -153,7 +153,7 @@ ORDER BY make_date Index: ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/inventorymanagement/service/InventoryManagerImpl.java =================================================================== diff -u -r18137 -r18787 --- ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/inventorymanagement/service/InventoryManagerImpl.java (.../InventoryManagerImpl.java) (revision 18137) +++ ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/inventorymanagement/service/InventoryManagerImpl.java (.../InventoryManagerImpl.java) (revision 18787) @@ -252,6 +252,7 @@ */ @Override public JsonObject prepareSyncInEntry(String jsonParamStr, Collection outParam_inEntrys) { + JsonObject jsonResult = new JsonObject(); JsonObject jsonParam = (JsonObject)new JsonParser().parse(jsonParamStr); Collection inEntrySerialNumbers = new Gson().fromJson( jsonParam.getAsJsonArray("entrySerialNumbers"), @@ -284,6 +285,9 @@ Collection items = findStorageEntryItemsImpl(inEntrySerialNumber, GodownEntry.TYPE_IN); JsonArray needFixItems = new JsonArray(); + //根据单号判断该入库单是否在系统中已经存在,如果已经存在则给予提示 + boolean includeDiposable = false;//是否包含一次性物品 + boolean includeMaterial = false;//是否包含材料 for(StorageEntryItem item : items){ Inventory inventory = item.getInventory(); @@ -435,6 +439,21 @@ // 到达此处代表此物品校验成功 inEntry.getItems().add(item); + + //如果入库物品是一次性物品 + if(inventory.getDisposableGoods() != null){ + includeDiposable = true; + }else if(inventory.getMaterialDefinition() != null){ + //如果入库物品是材料 + includeMaterial = true; + } + + boolean result = validateStorageEntryHasSyned(inEntry , GodownEntry.TYPE_IN , includeDiposable, includeMaterial); + if(result){ + jsonResult.addProperty("success", false); + jsonResult.addProperty("error", "单号为" + inEntry.getSerialNumber() + "的" + GodownEntry.TYPE_IN + "已经同步过,请不要重复同步!"); + return jsonResult; + } } if(needFixItems.size() > 0 ){ @@ -445,7 +464,6 @@ } } - JsonObject jsonResult = new JsonObject(); if(errors.isEmpty()){ jsonResult.addProperty("success", true); } else { @@ -460,6 +478,7 @@ // 检测待同步的退库单的数据是否正确 @Override public JsonObject prepareSyncOutEntry(String jsonParamStr, Collection outParam_outEntrys) { + JsonObject jsonResult = new JsonObject(); JsonObject jsonParam = (JsonObject)new JsonParser().parse(jsonParamStr); Collection outEntrySerialNumbers = new Gson().fromJson( @@ -478,6 +497,9 @@ outParam_outEntrys.add(outEntry); Collection items = findStorageEntryItemsImpl(outEntrySerialNumber, GodownEntry.TYPE_OUT); + //根据单号判断该入库单是否在系统中已经存在,如果已经存在则给予提示 + boolean includeDiposable = false;//是否包含一次性物品 + boolean includeMaterial = false;//是否包含材料 for(StorageEntryItem item : items){ // 一旦检测出任一物品明细项有问题,则可立即报错 @@ -550,10 +572,24 @@ // 到达此处代表此物品校验成功 outEntry.getItems().add(item); + + //如果退库物品是一次性物品 + if(inventory.getDisposableGoods() != null){ + includeDiposable = true; + }else if(inventory.getMaterialDefinition() != null){ + //如果退库物品是材料 + includeMaterial = true; + } + + boolean result = validateStorageEntryHasSyned(outEntry , GodownEntry.TYPE_OUT , includeDiposable, includeMaterial); + if(result){ + jsonResult.addProperty("success", false); + jsonResult.addProperty("error", "单号为" + outEntry.getSerialNumber() + "的" + GodownEntry.TYPE_OUT + "已经同步过,请不要重复同步!"); + return jsonResult; + } } } - JsonObject jsonResult = new JsonObject(); jsonResult.addProperty("success", true); return jsonResult; @@ -569,6 +605,7 @@ */ @Override public JsonObject prepareSyncReturnEntry(String jsonParamStr, Collection outParam_returnEntrys) { + JsonObject jsonResult = new JsonObject(); JsonObject jsonParam = (JsonObject)new JsonParser().parse(jsonParamStr); Collection returnEntrySerialNumbers = new Gson().fromJson( @@ -587,6 +624,9 @@ outParam_returnEntrys.add(returnEntry); Collection items = findStorageEntryItemsImpl(returnEntrySerialNumber, GodownEntry.TYPE_RETURN); + //根据单号判断该入库单是否在系统中已经存在,如果已经存在则给予提示 + boolean includeDiposable = false;//是否包含一次性物品 + boolean includeMaterial = false;//是否包含材料 for(StorageEntryItem item : items){ // 一旦检测出任一物品明细项有问题,则可立即报错 @@ -666,20 +706,57 @@ // 到达此处代表此物品校验成功 returnEntry.getItems().add(item); + + //如果退货物品是一次性物品 + if(inventory.getDisposableGoods() != null){ + includeDiposable = true; + }else if(inventory.getMaterialDefinition() != null){ + //如果退货物品是材料 + includeMaterial = true; + } + boolean result = validateStorageEntryHasSyned(returnEntry , GodownEntry.TYPE_RETURN , includeDiposable, includeMaterial); + if(result){ + jsonResult.addProperty("success", false); + jsonResult.addProperty("error", "单号为" + returnEntry.getSerialNumber() + "的" + GodownEntry.TYPE_RETURN + "已经同步过,请不要重复同步!"); + return jsonResult; + } } //生成退货申请单及退货明细 createReturnGoodsApplication(returnEntry); //生成godownEntry及godownEntryItem createGodownEntryData(returnEntry); } - JsonObject jsonResult = new JsonObject(); jsonResult.addProperty("success", true); return jsonResult; } /** + * 判断该同步单(入库单、退库单或退货单)等是否已经同步过 + * @param entry + * @param type + * @param includeDiposable + * @param includeMaterial + * @return + */ + private boolean validateStorageEntryHasSyned(StorageEntry entry , String type , boolean includeDiposable , boolean includeMaterial){ + if(includeDiposable){ + if(objectDao.getBySql(GodownEntry.class.getSimpleName(), + String.format(" where type='%s' and serialNumber='%s'",type,entry.getSerialNumber())) != null){ + return true; + } + } + if(includeMaterial){ + if(objectDao.getBySql(MaterialEntry.class.getSimpleName(), + String.format(" where type='%s' and serialNumber='%s'",type,entry.getSerialNumber())) != null){ + return true; + } + } + return false; + } + + /** * 生成退货单及明细(ReturnGoodsRecord,ReturnGoodsItem) * @param returnEntry */ @@ -702,14 +779,14 @@ for(StorageEntryItem item : returnEntry.getItems()){ if(StringUtils.isNotBlank(item.getInvCode())){ ReturnGoodsItem returnGoodsItem = new ReturnGoodsItem(); - DisposableGoodsStock disposableGoodsStock = - (DisposableGoodsStock)objectDao.getByProperty("DiposableGoods", "inventorySerialNumber", item.getInvCode()); - if(disposableGoodsStock != null){ + DisposableGoods disposableGoods = + (DisposableGoods)objectDao.getByProperty(DisposableGoods.class.getSimpleName(), "inventorySerialNumber", item.getInvCode()); + if(disposableGoods != null){ DisposableGoodsBatchStock disposableGoodsBatchStock = (DisposableGoodsBatchStock)objectDao.getBySql(DisposableGoodsBatchStock.class.getSimpleName(), - " where batchNumber='" + item.getBatchNumber() + "' and diposableGoods.id="+disposableGoodsStock.getId()); + " where batchNumber='" + item.getBatchNumber() + "' and disposableGoodsId="+disposableGoods.getId()); if(disposableGoodsBatchStock != null){ - returnGoodsItem.setTousseName(disposableGoodsStock.getName()); + returnGoodsItem.setTousseName(disposableGoods.getName()); returnGoodsItem.setAmount(item.getAmount() == null ? null : item.getAmount().intValue()); returnGoodsItem.setReturnedAmount(item.getAmount()); returnGoodsItem.setPrice(item.getUnitPrice()); @@ -724,7 +801,7 @@ returnGoodsItem.setBarcode(disposableGoodsBatchStock.getBarcode()); returnGoodsItem.setDiposableGoodBatchStock(disposableGoodsBatchStock); returnGoodsItem.setDisposableGoodsBatchStockID(disposableGoodsBatchStock.getId()); - returnGoodsItem.setDisposableGoodsID(disposableGoodsStock.getId()); + returnGoodsItem.setDisposableGoodsID(disposableGoods.getId()); settlementPriceOfRecord = settlementPriceOfRecord.add(returnGoodsItem.getSettlementPrice()); objectDao.saveOrUpdate(returnGoodsItem);