Index: ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/dwr/table/RecyclingApplicationTableManager.java =================================================================== diff -u -r20868 -r21435 --- ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/dwr/table/RecyclingApplicationTableManager.java (.../RecyclingApplicationTableManager.java) (revision 20868) +++ ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/dwr/table/RecyclingApplicationTableManager.java (.../RecyclingApplicationTableManager.java) (revision 21435) @@ -22,7 +22,6 @@ import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.Transformer; -import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.math.NumberUtils; import org.apache.commons.lang3.time.DateUtils; @@ -887,8 +886,84 @@ return items; } - /** + * 判断是否有当天已经打印过的物品 + * @param jsonParams + * @return + */ + public String haveTodayPrintedTousseItem(String jsonParams){ + JSONObject jsonObject = null; + String shiftName = ""; + try { + jsonObject = JSONObject.fromObject(jsonParams); + } catch (JSONException e) { + logger.error("转化成JSON对象时出错:\r\n请求参数:" + jsonParams, + e); + return JSONUtil.buildJsonObject(false,"参数非JSON格式").toString(); + } + if (jsonObject == null) { + return JSONUtil.buildJsonObject(false,"参数非JSON格式").toString(); + } + + boolean have = false; + + String action = jsonObject.optString("action"); + if ("batchPrint".equalsIgnoreCase(action)){ + + String batchId = jsonObject.optString("ids"); + + JSONObject printScope = jsonObject.optJSONObject("printScope"); + + PrintConfig config = printConfigManager.get(batchId); + + if(config != null){ + shiftName = config.getShift();//批量打印发货计划的班次名称 + String departCodes = config.getDepartCodes(); + if (departCodes.length() > 0){ + String[] depts = departCodes.split(";"); + // 同一科室的多张申请单是否合并在一起打印 + boolean isMergePrintMultiApplicationsOfSameDepart = true; + if (PrintConfig.MERGE_PRINT_NO.equals(config + .getIsAppMergePrint())) { + isMergePrintMultiApplicationsOfSameDepart = false; + } + + boolean mergePrintTousseAndDiposable = true; + if (PrintConfig.MERGE_PRINT_NO.equals(config.getIsMergePrintTousseAndDisposa())){ + mergePrintTousseAndDiposable = false; + } + + printScope.put("mergePrintTousseAndDiposable", mergePrintTousseAndDiposable); + printScope.put("disinfectGoodsPrintMode", config.getDisinfectGoodsPrintMode()); + printScope.put("printOrder", config.getPrintOrder()); + printScope.put("applicationFormType", config.getApplicationFormType()); + printScope.put("isMergePrintMultipleSelectedApplications", isMergePrintMultiApplicationsOfSameDepart); + printScope.put("shiftName", shiftName); + + String printConfig2 = config.getPrintConfig2(); + if (StringUtils.isNotBlank(printConfig2)){ + printScope.put("isSupportTousseGroup", true); + printScope.put("printConfig2", printConfig2); + } + else{ + printScope.put("isSupportTousseGroup", false); + } + + have = recyclingApplicationManager.haveTodayPrintedTousseItems(depts, printScope); + } + else{ + return JSONUtil.buildJsonObject(false, "未设置属于【" + shiftName + "】的科室,请设置后再打印!").toString(); + } + } + else{ + return JSONUtil.buildJsonObject(false,"未找到打印分组定义,请检查打印分组设置").toString(); + } + } + JSONObject json = JSONUtil.buildJsonObject(true); + json.put("haveTodayPrinted", have); + return json.toString(); + } + /** * 批量打印申请单,id为打印批次的id,根据此id可以找到属于该批次的科室名单(只打印未终止的申请物品) * 返回打印内容的JSON字符串 * @param jsonParams Index: ssts-web/src/main/webapp/disinfectsystem/config/zsyy/config.js =================================================================== diff -u -r21278 -r21435 --- ssts-web/src/main/webapp/disinfectsystem/config/zsyy/config.js (.../config.js) (revision 21278) +++ ssts-web/src/main/webapp/disinfectsystem/config/zsyy/config.js (.../config.js) (revision 21435) @@ -233,5 +233,7 @@ // 发货计划列表界面是否显示一次性物品类型 invoicePlanExtractedView_showDisposableGoodsType:true, //一次性物品入库单页面是否显示hrp入库时间 : true为启用,false为不启用 - godownEntryShowHrpTime : true + godownEntryShowHrpTime : true, + //科室申领中,是否重复打印当天已经打印的申领物品 + reprintTodayPrintedTousseItem : true } \ No newline at end of file Index: ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/RecyclingApplicationManager.java =================================================================== diff -u -r21236 -r21435 --- ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/RecyclingApplicationManager.java (.../RecyclingApplicationManager.java) (revision 21236) +++ ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/RecyclingApplicationManager.java (.../RecyclingApplicationManager.java) (revision 21435) @@ -23,7 +23,6 @@ import com.forgon.disinfectsystem.inventorymanagement.model.HrpTousseItem; import com.forgon.disinfectsystem.print.vo.PrintSummaryVo; import com.forgon.disinfectsystem.recyclingapplication.vo.ReturnGoodVo; -import com.forgon.disinfectsystem.vo.ApplicationItemVO; import com.forgon.disinfectsystem.vo.RecyclingApplicationVo; import com.forgon.disinfectsystem.vo.TousseItemVo; import com.forgon.tools.hibernate.BasePoManager; @@ -118,6 +117,13 @@ public void getPrintObjectOfDept(JSONObject printScope, String departCode, String printUser, List summaryList); + /** + * 是否有当天打印的申请物品 + * @param departCode + * @param printScope + * @return + */ + public boolean haveTodayPrintedTousseItems(String[] departCode,JSONObject printScope); /** * 根据发货计划及器械包分组及打印配置,获取发货计划的打印数据 Index: ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/RecyclingApplicationManagerImpl.java =================================================================== diff -u -r21411 -r21435 --- ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/RecyclingApplicationManagerImpl.java (.../RecyclingApplicationManagerImpl.java) (revision 21411) +++ ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/RecyclingApplicationManagerImpl.java (.../RecyclingApplicationManagerImpl.java) (revision 21435) @@ -1331,6 +1331,44 @@ populatePrintSummaryVoList(printScope, printUser,allTousseItems, summaryList); } + @Override + public boolean haveTodayPrintedTousseItems(String[] departCode,JSONObject printScope){ + List tousseTypes = getPrintTousseTypes(printScope); + int count = countTodayPrintedTousseItems(tousseTypes,departCode,printScope); + return count > 0; + } + public int countTodayPrintedTousseItems(Collection tousseTypes,String[] departCode,JSONObject printScope){ + String date = ForgonDateUtils.safelyFormatDate(new Date(), com.forgon.Constants.SIMPLEDATEFORMAT_YYYYMMDD, ""); + String todaySql = dateQueryAdapter.dateAreaSql("po.invoicePlan.printTime", date, date, true); + + List types = PrintConfig.buildApplicationType(printScope != null?printScope.optString("applicationFormType"):null); + if(CollectionUtils.isEmpty(types)){ + types = Arrays.asList( + InvoicePlan.TYPE_COMBO_FORM, + InvoicePlan.TYPE_TOUSSE_APPLICATION_FORM, + InvoicePlan.TYPE_DIPOSABLE_GOODS_APPLICATION_FORM, + InvoicePlan.TYPE_RECYCLINGCREATE_APPLICATION, + InvoicePlan.TYPE_CUSTOM_TOUSSE_APPLIACTION_FORM, + InvoicePlan.TYPE_DISINFECT_GOODS_APPLICATION_FORM); + } + String tousseTypeSql = SqlUtils.getStringFieldInCollectionsPredicate("po.tousseType", tousseTypes); + String departSql = SqlUtils.getStringFieldInLargeCollectionsPredicate("po.invoicePlan.departCoding", Arrays.asList(departCode)); + String deliverStatusSql = SqlUtils.getStringFieldInCollectionsPredicate("po.invoicePlan.deliverStatus", Arrays.asList( + InvoicePlan.DELIVERSTATUS_AWAITDELIVER, + InvoicePlan.DELIVERSTATUS_PARTDELIVERED)); + String invoicePlanTypeSql = SqlUtils.getStringFieldInCollectionsPredicate("po.invoicePlan.type", types); + // 按照申请物品的先后顺序排序 + String where = tousseTypeSql + + " AND po.invoicePlan.committedStatus = 1" + + " AND (po.isPrinted = true and "+todaySql+")" + + " AND (po.isTerminated is null or po.isTerminated <> true)" + + " AND (po.invoicePlan.recyclingStatus != '"+InvoicePlan.STATUS_END+"' OR po.invoicePlan.recyclingStatus is null)" + + " AND " + deliverStatusSql + + " AND " + departSql + + " AND po.invoicePlan.handleDepartCoding = '" + AcegiHelper.getCurrentOrgUnitCode() + "'" + + " AND "+invoicePlanTypeSql; + return tousseItemManager.count(where); + } /** * 根据发货计划打印配置,获取发货计划的打印数据 @@ -2914,6 +2952,12 @@ } private List getTousseItems(List tousseTypes, String departCode,JSONObject printScope) { + boolean repeatTodayPrintTousseItem = printScope != null?printScope.optBoolean("reprintTodayPrintedTousseItem"):false;//是否重复打印当天已经打印的包 + String repeatSql = "1=2"; + String date = ForgonDateUtils.safelyFormatDate(new Date(), com.forgon.Constants.SIMPLEDATEFORMAT_YYYYMMDD, ""); + if(repeatTodayPrintTousseItem){ + repeatSql = dateQueryAdapter.dateAreaSql("po.invoicePlan.printTime", date, date, true); + } List types = PrintConfig.buildApplicationType(printScope != null?printScope.optString("applicationFormType"):null); if(CollectionUtils.isEmpty(types)){ types = Arrays.asList( @@ -2928,7 +2972,7 @@ String sql = "SELECT po FROM TousseItem po" + " WHERE po.tousseType in (:tousseTypes)" + " AND po.invoicePlan.committedStatus = 1" - + " AND po.isPrinted = false" + + " AND (po.isPrinted = false or (po.isPrinted = true and "+repeatSql+"))" + " AND (po.isTerminated is null or po.isTerminated <> true)" + " AND (po.invoicePlan.recyclingStatus != :recyclingStatus OR po.invoicePlan.recyclingStatus is null)" + " AND po.invoicePlan.deliverStatus IN (:deliverStatus)" Index: forgon-tools/src/main/java/com/forgon/tools/util/SqlUtils.java =================================================================== diff -u -r19036 -r21435 --- forgon-tools/src/main/java/com/forgon/tools/util/SqlUtils.java (.../SqlUtils.java) (revision 19036) +++ forgon-tools/src/main/java/com/forgon/tools/util/SqlUtils.java (.../SqlUtils.java) (revision 21435) @@ -1,11 +1,15 @@ package com.forgon.tools.util; +import java.util.ArrayList; +import java.util.Collection; import java.util.LinkedList; import java.util.List; +import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang.StringUtils; import com.forgon.tools.Constants; +import com.forgon.tools.MyCollectionUtils; import com.forgon.tools.db.InitDbConnection; import com.forgon.tools.string.StringTools; @@ -83,6 +87,26 @@ return String.format(" %s IN (%s) ", field, s); } /** + * 获取字符串集合的sql条件,集合对象可以是大集合 + * @param field + * @param p + * @return + */ + public static String getStringFieldInLargeCollectionsPredicate(String field, + Collection p) { + List> list = MyCollectionUtils.split(p); + if(CollectionUtils.isNotEmpty(list)){ + List itemSqls = new ArrayList<>(); + for(List item : list){ + String itemSql = getStringFieldInCollectionsPredicate(field,item); + itemSqls.add(String.format("(%s)",itemSql)); + } + return String.join(" or ", itemSqls); + } + return " 1=0 "; + + } + /** * 获取字符串集合的sql条件 * @param field * @param p Index: ssts-web/src/main/webapp/disinfectsystem/recyclingApplication/goodsApplicationView.js =================================================================== diff -u -r21392 -r21435 --- ssts-web/src/main/webapp/disinfectsystem/recyclingApplication/goodsApplicationView.js (.../goodsApplicationView.js) (revision 21392) +++ ssts-web/src/main/webapp/disinfectsystem/recyclingApplication/goodsApplicationView.js (.../goodsApplicationView.js) (revision 21435) @@ -1922,45 +1922,63 @@ var config = printConfig.invoicePlan; var printParams = getPrintJsonParams("batchPrint", id , config); - var mask; - if (!isIE6OrIE7){ - createMask.call(objMask,'printMask','正在处理批量打印请求,请稍候...',Ext.getBody(),true); - objMask.printMask.show(); - }else{ - mask = new Ext.LoadMask(Ext.getBody(), { msg: '正在处理批量打印请求,请稍候...'}); - mask.show(); - } - - - - RecyclingApplicationTableManager.findPrintRecyclingGoods(JSON.stringify(printParams) , function(result){ - var obj = JSON.parse(result); + function doBatchPrintService(repeat){ + var mask; if (!isIE6OrIE7){ - objMask.printMask.hide(); + createMask.call(objMask,'printMask','正在处理批量打印请求,请稍候...',Ext.getBody(),true); + objMask.printMask.show(); + }else{ + mask = new Ext.LoadMask(Ext.getBody(), { msg: '正在处理批量打印请求,请稍候...'}); + mask.show(); } - else { - mask.hide(); - } - - if (obj.success){ - if (sstsConfig.isShowNoPrintList && obj.noPrintList){ - showResult("如下科室未填写申请单:【" + obj.noPrintList + "】","",-1); + printParams.printScope.reprintTodayPrintedTousseItem = repeat; + RecyclingApplicationTableManager.findPrintRecyclingGoods(JSON.stringify(printParams) , function(result){ + var obj = JSON.parse(result); + if (!isIE6OrIE7){ + objMask.printMask.hide(); } - var newP = top.Ext.MessageBox.show({ - title:'请等待', - msg:'打印中……', - width:350, - progress:true, - closable:false - }); + else { + mask.hide(); + } - formTypeOfPrinted = "invoicePlan"; - printByJsonPrintObject(obj, newP,false,0,true); - } - else{ - showResult(obj.error); - } - }); + if (obj.success){ + if (sstsConfig.isShowNoPrintList && obj.noPrintList){ + showResult("如下科室未填写申请单:【" + obj.noPrintList + "】","",-1); + } + var newP = top.Ext.MessageBox.show({ + title:'请等待', + msg:'打印中……', + width:350, + progress:true, + closable:false + }); + + formTypeOfPrinted = "invoicePlan"; + printByJsonPrintObject(obj, newP,false,0,true); + } + else{ + showResult(obj.error); + } + }); + } + if(sstsConfig.reprintTodayPrintedTousseItem){ + RecyclingApplicationTableManager.haveTodayPrintedTousseItem(JSON.stringify(printParams),function(result){ + var obj = JSON.parse(result); + if(obj.haveTodayPrinted){ + top.Ext.MessageBox.confirm("请确认","部分申请单已打印,是否重复打印", + function(button, text) { + if ("yes" == button){ + doBatchPrintService(true); + } + } + ); + }else{ + doBatchPrintService(false); + } + }); + }else{ + doBatchPrintService(false); + } } /**