Index: ssts-recyclingrecord/src/main/java/com/forgon/disinfectsystem/recyclingrecord/service/RecyclingRecordManager.java =================================================================== diff -u -r14632 -r14762 --- ssts-recyclingrecord/src/main/java/com/forgon/disinfectsystem/recyclingrecord/service/RecyclingRecordManager.java (.../RecyclingRecordManager.java) (revision 14632) +++ ssts-recyclingrecord/src/main/java/com/forgon/disinfectsystem/recyclingrecord/service/RecyclingRecordManager.java (.../RecyclingRecordManager.java) (revision 14762) @@ -21,7 +21,7 @@ public RecyclingRecord getByRecyclingApplicationId(String applicationId); - public String getRecyclingRecordListByJson(long start, long end,String filterJson); + public JSONObject getRecyclingRecordListByJson(long start, long end,String filterJson); public List findApplicationItemVOs( String recyclingRecordId); Index: ssts-recyclingrecord/src/main/java/com/forgon/disinfectsystem/recyclingrecord/action/RecyclingRecordAction.java =================================================================== diff -u -r14736 -r14762 --- ssts-recyclingrecord/src/main/java/com/forgon/disinfectsystem/recyclingrecord/action/RecyclingRecordAction.java (.../RecyclingRecordAction.java) (revision 14736) +++ ssts-recyclingrecord/src/main/java/com/forgon/disinfectsystem/recyclingrecord/action/RecyclingRecordAction.java (.../RecyclingRecordAction.java) (revision 14762) @@ -1,7 +1,6 @@ package com.forgon.disinfectsystem.recyclingrecord.action; import java.io.IOException; -import java.io.PrintWriter; import java.io.UnsupportedEncodingException; import java.sql.ResultSet; import java.sql.SQLException; @@ -64,7 +63,6 @@ import com.forgon.disinfectsystem.entity.recyclingerror.RecyclingError; import com.forgon.disinfectsystem.entity.recyclingrecord.RecyclingRecord; import com.forgon.disinfectsystem.entity.tousseitem.TousseItem; -import com.forgon.disinfectsystem.exception.RecyclingRecordException; import com.forgon.disinfectsystem.foreigntousseapplication.service.ForeignTousseApplicationManager; import com.forgon.disinfectsystem.idcarddefinition.service.IDCardDefinitionManager; import com.forgon.disinfectsystem.idcardinstance.util.IDCardInstanceUtils; @@ -81,6 +79,7 @@ import com.forgon.tools.MathTools; import com.forgon.tools.SqlBuilder; import com.forgon.tools.StrutsParamUtils; +import com.forgon.tools.StrutsResponseUtils; import com.forgon.tools.db.DatabaseUtil; import com.forgon.tools.hibernate.ObjectDao; import com.forgon.tools.json.JsonPropertyFilter; @@ -369,15 +368,9 @@ } } } - HttpServletResponse response = StrutsParamUtils.getResponse(); - response.setCharacterEncoding("UTF-8"); - PrintWriter out; - try { - out = response.getWriter(); - out.print("{success:true,message:'"+msg+"'}"); - out.close(); - } catch (IOException e) {} - + + StrutsResponseUtils.output(true, msg); + return null; } @@ -470,13 +463,8 @@ HttpSession session = request.getSession(); session.setAttribute("recyclingUser",recyclingRecord.getRecyclingUser()); session.setAttribute("sessionOperator",recyclingRecord.getOperator()); - HttpServletResponse response = StrutsParamUtils.getResponse(); - response.setCharacterEncoding("UTF-8"); - try { - PrintWriter out = response.getWriter(); - out.print("{\"success\":" + success + ",\"message\":\"" + message + "\"}"); - } catch (IOException e2) { - } + + StrutsResponseUtils.output(success, message); } /** @@ -557,14 +545,9 @@ map.put("success", true); map.put("data", recyclingRecord); JSONObject jsonObject = JSONObject.fromObject(map, config); - String jsonStr = jsonObject.toString(); - try { - response.setCharacterEncoding("UTF-8"); - response.getWriter().print(jsonStr); - response.getWriter().close(); - } catch (IOException e) { - e.printStackTrace(); - } + + StrutsResponseUtils.output(jsonObject); + return null; } @@ -702,14 +685,9 @@ map.put("errorMessage", errorMessage); try { JSONObject jsonObject = JSONObject.fromObject(map, config); - String jsonStr = jsonObject.toString(); - try { - response.setCharacterEncoding("UTF-8"); - response.getWriter().print(jsonStr); - response.getWriter().close(); - } catch (IOException e) { - e.printStackTrace(); - } + + StrutsResponseUtils.output(jsonObject); + } catch (Exception e1) { e1.printStackTrace(); } @@ -901,10 +879,9 @@ map.put("isTousseNeedMaintain", isTousseNeedMaintain); try { JSONObject jsonObject = JSONObject.fromObject(map, config); - response.setCharacterEncoding("UTF-8"); - PrintWriter writer = response.getWriter(); - writer.print(jsonObject.toString()); - writer.close(); + + StrutsResponseUtils.output(jsonObject); + } catch (Exception e1) { e1.printStackTrace(); } @@ -990,16 +967,9 @@ obj.put("remark", StringTools.getDefaultString(ip.getRemark())); jsonArray.add(obj); } - - String jsonStr = jsonArray.toString(); - try { - HttpServletResponse response = StrutsParamUtils.getResponse(); - response.setCharacterEncoding("UTF-8"); - response.getWriter().print(jsonStr); - response.getWriter().close(); - } catch (IOException e) { - e.printStackTrace(); - } + + StrutsResponseUtils.output(jsonArray); + return null; } @@ -1090,15 +1060,9 @@ } } JSONArray jsonArray = JSONArray.fromObject(quickRecyclingList); - String jsonStr = jsonArray.toString(); - try { - HttpServletResponse response = StrutsParamUtils.getResponse(); - response.setCharacterEncoding("UTF-8"); - response.getWriter().print(jsonStr); - response.getWriter().close(); - } catch (IOException e) { - e.printStackTrace(); - } + + StrutsResponseUtils.output(jsonArray); + if(StringUtils.isNotBlank(ids)){ String sql = "update invoicePlan set readed = "+InvoicePlan.READED+" where id in (" + ids +")"; recyclingApplicationManager.updateBySql(sql); @@ -1174,14 +1138,8 @@ }*/ } - try { - HttpServletResponse response = StrutsParamUtils.getResponse(); - response.setCharacterEncoding("UTF-8"); - response.getWriter().print(array.toString()); - response.getWriter().close(); - } catch (IOException e) { - e.printStackTrace(); - } + StrutsResponseUtils.output(array); + } /** @@ -1199,16 +1157,10 @@ } long start = (page - 1) * 20 + 1; long end = page * 20; - try { - HttpServletResponse response = StrutsParamUtils.getResponse(); - response.setCharacterEncoding("UTF-8"); - response.getWriter().print( - recyclingRecordManager.getRecyclingRecordListByJson(start, - end,filter)); - response.getWriter().close(); - } catch (IOException e) { - e.printStackTrace(); - } + + StrutsResponseUtils.output(recyclingRecordManager.getRecyclingRecordListByJson(start, + end,filter)); + return null; } @@ -1258,13 +1210,9 @@ } } JSONArray jsonArray = JSONArray.fromObject(recyclingErrorVos); - try { - response.setCharacterEncoding("UTF-8"); - response.getWriter().print(jsonArray.toString()); - response.getWriter().close(); - } catch (IOException e) { - e.printStackTrace(); - } + + StrutsResponseUtils.output(jsonArray); + } return null; } @@ -1295,14 +1243,9 @@ } } } - HttpServletResponse response = StrutsParamUtils.getResponse(); - try { - response.setCharacterEncoding("UTF-8"); - response.getWriter().print(array.toString()); - response.getWriter().close(); - } catch (IOException e) { - e.printStackTrace(); - } + + StrutsResponseUtils.output(array); + } public void setMaterialRecycleAmount(){ @@ -1317,13 +1260,9 @@ msg = e.getMessage(); } } - HttpServletResponse response = StrutsParamUtils.getResponse(); - try { - response.setCharacterEncoding("UTF-8"); - response.getWriter().print("{\"success\":"+success+",\"msg\":\""+msg+"\"}"); - } catch (IOException e) { - e.printStackTrace(); - } + + StrutsResponseUtils.output(success, msg); + } /** @@ -1369,14 +1308,9 @@ config.setCycleDetectionStrategy(CycleDetectionStrategy.LENIENT); JSONArray jsonArray = JSONArray.fromObject(materialInstances, config); - jsonStr = jsonArray.toString(); - try { - response.setCharacterEncoding("UTF-8"); - response.getWriter().print(jsonStr); - response.getWriter().close(); - } catch (IOException e) { - e.printStackTrace(); - } + + StrutsResponseUtils.output(jsonArray); + } return null; } @@ -1543,9 +1477,6 @@ public void recyclingBeOverdueTousse() { - HttpServletResponse response = StrutsParamUtils.getResponse(); - response.setCharacterEncoding("UTF-8"); - PrintWriter out; String currentOrgUnitCode = AcegiHelper .getLoginUser().getCurrentOrgUnitCode(); String depart = StrutsParamUtils.getPraramValue("depart", null); @@ -1562,13 +1493,7 @@ String message = recyclingRecordManager.recyclingOverdueTousse(recyclingRecord,ids, basketName,basketBarcode); - try { - out = response.getWriter(); - out.print("{'success':'true','message':'" + message + "'}"); - out.close(); - } catch (IOException e) { - e.printStackTrace(); - } + StrutsResponseUtils.output(true, message); } @Override @@ -1628,17 +1553,8 @@ obj.put("data", voList); obj.put("disinfectionGoods", disinfectionGoodsList); + StrutsResponseUtils.output(obj); - HttpServletResponse response = StrutsParamUtils.getResponse(); - response.setCharacterEncoding("UTF-8"); - PrintWriter out; - try { - out = response.getWriter(); - out.print(obj.toString()); - out.close(); - } catch (IOException e) { - e.printStackTrace(); - } } }catch(Exception e){ e.printStackTrace(); @@ -1920,13 +1836,9 @@ } } } - try { - HttpServletResponse response = StrutsParamUtils.getResponse(); - response.setCharacterEncoding("UTF-8"); - response.getWriter().println(result.toString()); - } catch (Exception e) { - e.printStackTrace(); - } + + StrutsResponseUtils.output(result); + } public void loadForeignTousseItems(){ @@ -1982,15 +1894,10 @@ } obj.put("tousseInfo", jsonArray); - try { - HttpServletResponse response = StrutsParamUtils.getResponse(); - response.setCharacterEncoding("UTF-8"); - response.getWriter().println(obj.toString()); - } catch (Exception e) { - e.printStackTrace(); - } + StrutsResponseUtils.output(obj); + } - + private JSONArray buildTousseItemsJson(List tousseItems,boolean confirmRecycle,JSONArray jsonArray) { if(tousseItems != null){ for (TousseItem tousseItem : tousseItems) { Index: ssts-recyclingrecord/src/main/java/com/forgon/disinfectsystem/recyclingrecord/service/RecyclingRecordManagerImpl.java =================================================================== diff -u -r14715 -r14762 --- ssts-recyclingrecord/src/main/java/com/forgon/disinfectsystem/recyclingrecord/service/RecyclingRecordManagerImpl.java (.../RecyclingRecordManagerImpl.java) (revision 14715) +++ ssts-recyclingrecord/src/main/java/com/forgon/disinfectsystem/recyclingrecord/service/RecyclingRecordManagerImpl.java (.../RecyclingRecordManagerImpl.java) (revision 14762) @@ -20,6 +20,7 @@ import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.Predicate; import org.apache.commons.collections4.map.MultiValueMap; +import org.apache.commons.lang.ArrayUtils; import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; @@ -1717,7 +1718,7 @@ @Override - public String getRecyclingRecordListByJson(long start, long end, + public JSONObject getRecyclingRecordListByJson(long start, long end, String filterJson) { RecyclingRecordListSqlGenerator sqlGenerator = new RecyclingRecordListSqlGenerator(dbConnection,start,end,filterJson); String sql = sqlGenerator.getListSql(); @@ -1749,7 +1750,7 @@ + totalCount + "条"); map.put("data", records); JSONObject jsonObject = JSONObject.fromObject(map); - return jsonObject.toString(); + return jsonObject; } @Override @@ -1988,7 +1989,9 @@ JSONArray basketJson = washClassifyTypeToBasketJsonMap.get(md_washClassifyType); if(basketJson == null){ - return buildUnSuccessMsg("缺少装载【" + md_washClassifyType + "】类型的篮筐,请扫描!"); + String msg2 = getWashContainerWarnningPrompt(md_washClassifyType); + + return buildUnSuccessMsg(msg2); } //材料入筐总数量 Integer totalIntoBasketAmount = mi.getCount() * amount; @@ -2042,7 +2045,8 @@ } //部分器械还未入筐 if(totalIntoBasketAmount > 0){ - return buildUnSuccessMsg("部分器械未能入筐,缺少装载【" + md_washClassifyType + "】类型的篮筐,请扫描!"); + String msg2 = "部分器械未能入筐," + getWashContainerWarnningPrompt(md_washClassifyType); + return buildUnSuccessMsg(msg2); } } Object[] keys = basketGroupBarcodeMap.keySet().toArray(); @@ -2094,6 +2098,19 @@ obj.put("data", data); return obj; } + + /** + * 获取回收入筐时,清洗分类篮筐类型告警的提示信息 + * @param md_washClassifyType + * @return + */ + private String getWashContainerWarnningPrompt(String md_washClassifyType) { + String msg = "缺少清洗分类类型为空的篮筐,请扫描!"; + if (StringUtils.isNotBlank(md_washClassifyType)){ + msg = "缺少装载【" + md_washClassifyType + "】类型的篮筐,请扫描!"; + } + return msg; + } private void buildWashClassifyTypeMap(JSONArray basketArray, Map washClassifyTypeToBasketJsonMap) {