Index: ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/InvoicePlanManager.java =================================================================== diff -u -r19154 -r19642 --- ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/InvoicePlanManager.java (.../InvoicePlanManager.java) (revision 19154) +++ ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/InvoicePlanManager.java (.../InvoicePlanManager.java) (revision 19642) @@ -5,6 +5,7 @@ import java.util.Collection; import java.util.List; +import java.util.Map; import java.util.Set; import net.sf.json.JSONArray; @@ -237,4 +238,10 @@ * @param invoicePlan */ public RecyclingApplicationVo invoicePlan2RecyclingApplicationVo(InvoicePlan invoicePlan,boolean sort); + /** + * 根据科室编码分组 + * @param invoicePlans 待分组的申请单 + * @return + */ + public Map> groupByDepartCoding(List invoicePlans); } Index: ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/InvoicePlanManagerImpl.java =================================================================== diff -u -r19509 -r19642 --- ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/InvoicePlanManagerImpl.java (.../InvoicePlanManagerImpl.java) (revision 19509) +++ ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/InvoicePlanManagerImpl.java (.../InvoicePlanManagerImpl.java) (revision 19642) @@ -2432,4 +2432,21 @@ } return vo; } + + @Override + public Map> groupByDepartCoding( + List invoicePlans) { + Map> map = new HashMap>(); + if(CollectionUtils.isNotEmpty(invoicePlans)){ + invoicePlans.forEach(invoicePlan->{ + List list = map.get(invoicePlan.getDepartCoding()); + if(list == null){ + list = new ArrayList<>(); + map.put(invoicePlan.getDepartCoding(), list); + } + list.add(invoicePlan); + }); + } + return map; + } } Index: ssts-web/src/main/webapp/disinfectsystem/packing/printRecyclingDetailWin.js =================================================================== diff -u -r16114 -r19642 --- ssts-web/src/main/webapp/disinfectsystem/packing/printRecyclingDetailWin.js (.../printRecyclingDetailWin.js) (revision 16114) +++ ssts-web/src/main/webapp/disinfectsystem/packing/printRecyclingDetailWin.js (.../printRecyclingDetailWin.js) (revision 19642) @@ -414,6 +414,39 @@ return html; } +function buildRemarkTable(remarks,model){ + if(remarks){ + var html =""; + html += ""; + var totalRows = 0; + var remarkTable = ""; + for(var departCoding in remarks){ + var departName = ""; + for(var i = 0;i < remarks[departCoding].length;++i){ + if(totalRows > 0){ + remarkTable += "" + } + var item = remarks[departCoding][i]; + if(departName == ""){ + departName=item.depart; + remarkTable += ""; + } + remarkTable += "" + ""; + remarkTable += ""; + ++totalRows; + } + } + html += ""; + if(remarkTable==""){ + remarkTable += "" + } + html += remarkTable + html += "
" + departName + "" +item.serialNumber+ "" +item.remark+ "
" + model + "   
"; + return html; + } + return ""; +} + function dongGuangZhongYiYuanRecyclingDetailPrint(printType,startDateTime,endDateTime,printUser,recyclingDetail){ var LODOP = getLodop(document.getElementById('LODOP'), document.getElementById('LODOP_EM')); LODOP.SET_PRINT_STYLE("FontSize",17); @@ -451,7 +484,12 @@ htmlTable += ""; htmlTable += buildDepartTable(recyclingDetail,"其他"); htmlTable += ""; + //备注 + htmlTable += ""; + htmlTable += buildRemarkTable(recyclingDetail.remarks,"备注"); + htmlTable += ""; + htmlContent = "" + htmlTable + ""; LODOP.ADD_PRINT_HTM(55,5,"100%","100%",htmlContent); Index: forgon-tools/src/main/java/com/forgon/tools/json/DateJsonValueProcessor.java =================================================================== diff -u -r12331 -r19642 --- forgon-tools/src/main/java/com/forgon/tools/json/DateJsonValueProcessor.java (.../DateJsonValueProcessor.java) (revision 12331) +++ forgon-tools/src/main/java/com/forgon/tools/json/DateJsonValueProcessor.java (.../DateJsonValueProcessor.java) (revision 19642) @@ -16,7 +16,12 @@ public DateJsonValueProcessor(String format) { this._format = new SimpleDateFormat(format); } + + public DateJsonValueProcessor(SimpleDateFormat format) { + this._format = format; + } + @Override public Object processArrayValue(Object value, JsonConfig jsonConfig) { String[] obj = {}; if (value != null && value instanceof Date[]) { @@ -29,6 +34,7 @@ return obj; } + @Override public Object processObjectValue(String key, Object value, JsonConfig jsonConfig) { if (value != null && value instanceof Date) { Index: ssts-recyclingrecord/src/main/java/com/forgon/disinfectsystem/recyclingrecord/action/RecyclingRecordAction.java =================================================================== diff -u -r19486 -r19642 --- ssts-recyclingrecord/src/main/java/com/forgon/disinfectsystem/recyclingrecord/action/RecyclingRecordAction.java (.../RecyclingRecordAction.java) (revision 19486) +++ ssts-recyclingrecord/src/main/java/com/forgon/disinfectsystem/recyclingrecord/action/RecyclingRecordAction.java (.../RecyclingRecordAction.java) (revision 19642) @@ -39,6 +39,7 @@ import com.forgon.Constants; import com.forgon.databaseadapter.service.DateQueryAdapter; +import com.forgon.databaseadapter.service.SqlFunctionsAdapter; import com.forgon.directory.acegi.tools.AcegiHelper; import com.forgon.directory.model.BarcodeDevice; import com.forgon.directory.model.OrgUnit; @@ -106,6 +107,7 @@ import com.forgon.tools.db.DatabaseUtil; import com.forgon.tools.hibernate.ObjectDao; import com.forgon.tools.json.JSONUtil; +import com.forgon.tools.json.JsonIncludePropertyFilter; import com.forgon.tools.json.JsonPropertyFilter; import com.forgon.tools.string.StringTools; import com.opensymphony.xwork2.ModelDriven; @@ -178,7 +180,12 @@ private TousseMaterialErrorDamageManager tousseMaterialErrorDamageManager; private MaterialDefinitionManager materialDefinitionManager; + private SqlFunctionsAdapter sqlFunctionsAdapter; + public void setSqlFunctionsAdapter(SqlFunctionsAdapter sqlFunctionsAdapter) { + this.sqlFunctionsAdapter = sqlFunctionsAdapter; + } + public void setMaterialDefinitionManager( MaterialDefinitionManager materialDefinitionManager) { this.materialDefinitionManager = materialDefinitionManager; @@ -1811,15 +1818,27 @@ } String sql = String - .format("select min(po.depart),po.departCode,td.ancestorID,min(bo.tousseName),sum(bo.amount),td.id from %s po, %s bo,%s td " - + "where po.id = bo.recyclingRecord_id and td.id = bo.tousseDefinitionId and po.recyclingTime " - + "between %s and %s and po.orgUnitCoding = '%s' %s group by po.departCode,td.ancestorID,td.id", + .format("select min(po.depart),po.departCode,td.ancestorID,min(bo.tousseName),sum(bo.amount),td.id from %s po " + + "join %s bo on po.id = bo.recyclingRecord_id join %s td on td.id = bo.tousseDefinitionId " + + "where po.recyclingTime between %s and %s and po.orgUnitCoding = '%s' %s group by po.departCode,td.ancestorID,td.id", RecyclingRecord.class.getSimpleName(), RecyclingItem.class.getSimpleName(), TousseDefinition.class.getSimpleName(),fromTime, toTime, handlerDepartCoding,orOrgUnitNameSQL); ResultSet rs = objectDao.executeSql(sql); - - tousseItemClassification(rs); + JSONObject json = tousseItemClassification(rs); + String invoicePlanHql = String.format("id in(select recyclingApplication.id from %s po where po.recyclingTime between %s and %s and po.orgUnitCoding = '%s' %s) and %s order by depart,recyclingTime", + RecyclingRecord.class.getSimpleName(),fromTime,toTime,handlerDepartCoding,orOrgUnitNameSQL,sqlFunctionsAdapter.strNotBlank("remark")); + List invoicePlans = invoicePlanManager.getByHql(invoicePlanHql); + Map> maps = invoicePlanManager.groupByDepartCoding(invoicePlans); + JsonConfig jsonConfig = new JsonConfig(); + List list = new ArrayList<>(maps.keySet()); + list.add("serialNumber"); + list.add("depart"); + list.add("departCoding"); + list.add("remark"); + jsonConfig.setJsonPropertyFilter(new JsonIncludePropertyFilter(list.toArray(new String[0]))); + json.put("remarks", JSONObject.fromObject(maps, jsonConfig)); + StrutsResponseUtils.output(json); } } @@ -1920,12 +1939,11 @@ /** * 器械包分类 */ - public void tousseItemClassification(ResultSet rs){ + public JSONObject tousseItemClassification(ResultSet rs){ JSONObject printConfig = CssdUtils.getWebConfigInfo(CssdUtils.getProjectName() + "/print/recyclingDetailPrintConfig.js"); if(printConfig == null){ - StrutsResponseUtils.output(false, "回收清单参数配置有误!"); - return; + return JSONUtil.buildJsonObject(false, "回收清单参数配置有误!"); } Map> configMap = getPrintTableConfigInfo(printConfig); @@ -2026,7 +2044,7 @@ data.put("配置文件", printConfig); data.put("printUser", AcegiHelper.getLoginUserFullName()); - StrutsResponseUtils.output(data); + return data; } private void setOtherTousse(long ancestorID, String tousseName, Index: forgon-tools/src/main/java/com/forgon/tools/json/JsonIncludePropertyFilter.java =================================================================== diff -u --- forgon-tools/src/main/java/com/forgon/tools/json/JsonIncludePropertyFilter.java (revision 0) +++ forgon-tools/src/main/java/com/forgon/tools/json/JsonIncludePropertyFilter.java (revision 19642) @@ -0,0 +1,30 @@ +package com.forgon.tools.json; + +import net.sf.json.util.PropertyFilter; + +/** + * 转换为json时,需要包含的属性过滤。 + * @author kzh + * + */ +public class JsonIncludePropertyFilter implements PropertyFilter { + private String[] filterProperties = null; + /** + * 构造对象并指定需要包含的属性名 + * @param includeFilters + */ + public JsonIncludePropertyFilter(String... includeFilters){ + filterProperties = includeFilters; + } + @Override + public boolean apply(Object source, String name, Object value) { + if(filterProperties != null){ + for(String filterProperty : filterProperties){ + if(name.equalsIgnoreCase(filterProperty)){ + return false; + } + } + } + return true; + } +}