Index: ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/InvoicePlanManagerImpl.java =================================================================== diff -u -r18354 -r18435 --- ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/InvoicePlanManagerImpl.java (.../InvoicePlanManagerImpl.java) (revision 18354) +++ ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/InvoicePlanManagerImpl.java (.../InvoicePlanManagerImpl.java) (revision 18435) @@ -15,6 +15,7 @@ import java.util.Set; import java.util.stream.Collectors; +import com.forgon.disinfectsystem.recyclingapplication.factory.DeliverManagerFactory; import net.sf.json.JSONArray; import net.sf.json.JSONObject; @@ -486,6 +487,9 @@ boolean isBorrowingApplicationForm = InvoicePlan.TYPE_BORROWINGSINGLE .equals(re.getType()); List applicationItems = re.getApplicationItems(); + + DeliverManager deliverManager = DeliverManagerFactory.createDeliverManager(re); + if (applicationItems != null) { for (TousseItem item : applicationItems) { ApplicationItemVO vo = new ApplicationItemVO(); @@ -498,6 +502,10 @@ } vo.setRecyclingAmount(recyclingAmount); vo.setInvoiceAmount(item.getSendOutAmount()); + + //设置是否已发货状态 + vo.setDelivered(deliverManager.calculateIsDelivered(item)); + if (!item.disposable()) { TousseDefinition definition = tousseDefinitionManager .getTousseDefinitionByTousseItem(item); Index: ssts-basedata/src/main/java/com/forgon/disinfectsystem/vo/ApplicationItemVO.java =================================================================== diff -u -r18318 -r18435 --- ssts-basedata/src/main/java/com/forgon/disinfectsystem/vo/ApplicationItemVO.java (.../ApplicationItemVO.java) (revision 18318) +++ ssts-basedata/src/main/java/com/forgon/disinfectsystem/vo/ApplicationItemVO.java (.../ApplicationItemVO.java) (revision 18435) @@ -35,7 +35,12 @@ */ private String amountDisplay; + /** + * 该物品是否已发货 + */ + private boolean delivered; + public String getName() { return name; } @@ -132,6 +137,14 @@ return amountDisplay; } + public boolean isDelivered() { + return delivered; + } + + public void setDelivered(boolean delivered) { + this.delivered = delivered; + } + @Override public String toString() { return "ApplicationItemVO{" + @@ -146,6 +159,7 @@ ", externalCode='" + externalCode + '\'' + ", material='" + material + '\'' + ", amountDisplay='" + amountDisplay + '\'' + + ", delivered=" + delivered + '}'; } } Index: ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/factory/DeliverManagerFactory.java =================================================================== diff -u --- ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/factory/DeliverManagerFactory.java (revision 0) +++ ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/factory/DeliverManagerFactory.java (revision 18435) @@ -0,0 +1,40 @@ +package com.forgon.disinfectsystem.recyclingapplication.factory; + +import com.forgon.disinfectsystem.entity.invoicemanager.InvoicePlan; +import com.forgon.disinfectsystem.recyclingapplication.service.DeliverManager; +import com.forgon.disinfectsystem.recyclingapplication.service.DeliverOtherManagerImpl; +import com.forgon.disinfectsystem.recyclingapplication.service.DeliverTousseManagerImpl; +import com.forgon.disinfectsystem.recyclingapplication.service.RecycleDeliverManagerImpl; +import org.apache.log4j.Logger; + +/** + * @author zhonghaowen + * @apiNote DeliverManager工厂类 + * @since 2017-06-22 + */ +public class DeliverManagerFactory { + + private static final Logger logger = Logger.getLogger(DeliverManagerFactory.class); + + + /** + * 根据申请单创建对应的实现类 + * + * @param ip 申请单 + */ + public static DeliverManager createDeliverManager(InvoicePlan ip) { + String type = ip.getType(); + logger.debug("申请单类型是:" + type); + if (InvoicePlan.TYPE_COMBO_FORM.equals(type) || InvoicePlan.TYPE_TOUSSE_APPLICATION_FORM.equals(type) || InvoicePlan.TYPE_DISINFECT_GOODS_APPLICATION_FORM.equals(type) || InvoicePlan.TYPE_CUSTOM_TOUSSE_APPLIACTION_FORM.equals(type)) { + logger.debug("构建:deliverTousseManagerImpl"); + return new DeliverTousseManagerImpl(); + } + if (InvoicePlan.TYPE_RECYCLINGCREATE_APPLICATION.equals(type)){ + logger.debug("构建:recycleDeliverManagerImpl"); + return new RecycleDeliverManagerImpl(); + } + logger.debug("构建:deliverOtherManagerImpl"); + //如果不符合默认用DeliverOtherManagerImpl来处理 + return new DeliverOtherManagerImpl(); + } +} Index: ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/DeliverTousseManagerImpl.java =================================================================== diff -u --- ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/DeliverTousseManagerImpl.java (revision 0) +++ ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/DeliverTousseManagerImpl.java (revision 18435) @@ -0,0 +1,42 @@ +package com.forgon.disinfectsystem.recyclingapplication.service; + +import com.forgon.disinfectsystem.basedatamanager.supplyroomconfig.service.SupplyRoomConfigManager; +import com.forgon.disinfectsystem.common.CssdUtils; +import com.forgon.disinfectsystem.entity.assestmanagement.DisposableGoods; +import com.forgon.disinfectsystem.entity.basedatamanager.supplyroomconfig.SupplyRoomConfig; +import com.forgon.disinfectsystem.entity.basedatamanager.toussedefinition.TousseDefinition; +import com.forgon.disinfectsystem.entity.tousseitem.TousseItem; +import com.forgon.tools.SpringBeanManger; +import com.forgon.tools.hibernate.ObjectDao; +import org.apache.log4j.Logger; + +/** + * @author zhonghaowen + * @apiNote 计算对应物品发货状态的接口实现类(适用于器械包申请单, 消毒物品申请单, 自定义器械包申请单, 通用申请单) + * @since 2017-06-22 + */ +public class DeliverTousseManagerImpl implements DeliverManager { + + private static SupplyRoomConfigManager supplyRoomConfigManager = (SupplyRoomConfigManager) SpringBeanManger.getBean("supplyRoomConfigManager"); + + private static ObjectDao objectDao = (ObjectDao) SpringBeanManger.getBean("objectDao"); + + private static DeliverManager deliverOtherManagerImpl = new DeliverOtherManagerImpl(); + + private Logger logger = Logger.getLogger(DeliverTousseManagerImpl.class); + + // 此方法适用于器械包申请单,消毒物品申请单,自定义器械包申请单,通用申请单 + // 如果是通用申请单里面不包括敷料包或者一次性物品,如果是器械包申请单里面不包括敷料包 + @Override + public boolean calculateIsDelivered(TousseItem item) { + String tousseType = item.getTousseType(); + //如果该物品是敷料包或者一次性物品,则调用deliverOtherManagerImpl来处理 + if (TousseDefinition.PACKAGE_TYPE_DRESSING.equals(tousseType) || DisposableGoods.TYPE_NAME.equals(tousseType)) { + logger.debug(String.format("物品[%s]是:%s使用deliverOtherManagerImpl来处理", item.getTousseName(), tousseType)); + return deliverOtherManagerImpl.calculateIsDelivered(item); + } + SupplyRoomConfig config = supplyRoomConfigManager.getSystemParamsObj(); + int waitDeliverAmount = CssdUtils.getWaitDeliverAmount2(item, config.getInvoiceOrigin(), config.getAfterRecyclingTousseDeliver(), false, objectDao); + return this.returnCalculateIsDelivered(item, waitDeliverAmount, item.getSendOutAmount(), logger); + } +} Index: ssts-web/src/main/webapp/disinfectsystem/recyclingApplication/goodsTemplateApplicationView.js =================================================================== diff -u -r18413 -r18435 --- ssts-web/src/main/webapp/disinfectsystem/recyclingApplication/goodsTemplateApplicationView.js (.../goodsTemplateApplicationView.js) (revision 18413) +++ ssts-web/src/main/webapp/disinfectsystem/recyclingApplication/goodsTemplateApplicationView.js (.../goodsTemplateApplicationView.js) (revision 18435) @@ -4360,7 +4360,10 @@ BorrowAmount = "" + voItems[i].alsoAmount+""; } var recyclingAmount = voItems[i].recyclingAmount; - content +=" " + tousseName +"" + voItems[i].amountDisplay+"" + recyclingAmount+"" + voItems[i].invoiceAmount+""+BorrowAmount; + + content += "" : ">"; + content +=" " + tousseName +"" + voItems[i].amountDisplay+"" + recyclingAmount+"" + voItems[i].invoiceAmount+"" + BorrowAmount; // content +=" " + tousseName +"" + voItems[i].amount+"" + recyclingAmount+"" + voItems[i].invoiceAmount+""+BorrowAmount; //一次性物品加编号 if(isDiposableApplicationForm){ Index: ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/DeliverOtherManagerImpl.java =================================================================== diff -u --- ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/DeliverOtherManagerImpl.java (revision 0) +++ ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/DeliverOtherManagerImpl.java (revision 18435) @@ -0,0 +1,21 @@ +package com.forgon.disinfectsystem.recyclingapplication.service; + +import com.forgon.disinfectsystem.entity.tousseitem.TousseItem; +import org.apache.log4j.Logger; + +/** + * @author zhonghaowen + * @apiNote 计算对应物品发货状态的接口实现类(适用于器械包申请单, 消毒物品申请单, 自定义器械包申请单, 通用申请单以外的申请单) + * @since 2017-06-22 + */ +public class DeliverOtherManagerImpl implements DeliverManager { + + + private Logger logger = Logger.getLogger(DeliverOtherManagerImpl.class); + + // 如果是通用申请单,则里面的物品只能是一次性物品或者敷料包 + @Override + public boolean calculateIsDelivered(TousseItem item) { + return this.returnCalculateIsDelivered(item, item.getAmount(), item.getSendOutAmount(), logger); + } +} Index: ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/DeliverManager.java =================================================================== diff -u --- ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/DeliverManager.java (revision 0) +++ ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/DeliverManager.java (revision 18435) @@ -0,0 +1,35 @@ +package com.forgon.disinfectsystem.recyclingapplication.service; + +import com.forgon.disinfectsystem.entity.tousseitem.TousseItem; +import org.apache.log4j.Logger; + +/** + * @author zhonghaowen + * @apiNote 计算对应物品发货状态的接口 + * @since 2017-06-22 + */ +public interface DeliverManager { + + /** + * 计算该物品是否已经发货 + * + * @param item {@link TousseItem} + * @return true表示已发货, false表示未完全发货 + */ + boolean calculateIsDelivered(TousseItem item); + + /** + * 返回计算发货状态的结果 + * + * @param item 申请的物品 + * @param needToSendAmount 要发货的数量 + * @param sendOutAmount 已经发货了的数量 + * @param logger 传logger是为了让日志的记录显示对应的实现类,以便观察调试 + * @return true表示已发货, false表示未完全发货 + */ + default boolean returnCalculateIsDelivered(TousseItem item, Integer needToSendAmount, Integer sendOutAmount, Logger logger) { + int waitDeliverAmount = Math.subtractExact(needToSendAmount, sendOutAmount); + logger.debug(String.format("[%s][%s]待发货的数量是:%s,调用类是[%s]", item.getTousseName(), item.getTousseType(), waitDeliverAmount, logger.getName())); + return waitDeliverAmount == 0; + } +} Index: ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/RecycleDeliverManagerImpl.java =================================================================== diff -u --- ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/RecycleDeliverManagerImpl.java (revision 0) +++ ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/RecycleDeliverManagerImpl.java (revision 18435) @@ -0,0 +1,20 @@ +package com.forgon.disinfectsystem.recyclingapplication.service; + +import com.forgon.disinfectsystem.entity.tousseitem.TousseItem; +import org.apache.log4j.Logger; + +/** + * @author zhonghaowen + * @apiNote 计算对应物品发货状态的接口实现类(适用于回收申请单) + * @since 2017-06-22 + */ +public class RecycleDeliverManagerImpl implements DeliverManager { + + private Logger logger = Logger.getLogger(RecycleDeliverManagerImpl.class); + + //此方法的计算方法仅只用于回收申请单 + @Override + public boolean calculateIsDelivered(TousseItem item) { + return this.returnCalculateIsDelivered(item, item.getRecyclingAmount(), item.getSendOutAmount(), logger); + } +}