/** * @param page,rows,... * @description 提供查询分页/模糊查询分页 * @return entityMap * @type Json */ @Action( value = "listBatchSendResult", results = { @Result( type = "json", params = {"root", "entityMap", "contentType", "text/html"}) }) public String listBatchSendResult() { if (!StringUtil.isEmpty(batchId)) { PageUtil pageUtil = new PageUtil(); pageUtil.setStart(page); pageUtil.setPageSize(rows); pageUtil.setBatchId(Long.valueOf(batchId)); try { Users u = (Users) super.getSession().getAttribute(ApSmsConstants.SESSION_USER_INFO); pageUtil.setMerchantPin(u.getMerchantPin()); if (!StringUtil.isEmpty(searchBycontacts)) { pageUtil.setContactName(URLDecoder.decode(searchBycontacts, "UTF-8")); } if (!StringUtil.isEmpty(sendResult) && !sendResult.equals("4")) { pageUtil.setSendResult(Integer.valueOf(sendResult)); } Page page = mbnSmsHadSendService.batchPage(pageUtil); if (page != null) { @SuppressWarnings("unchecked") List<MbnSmsHadSend> datas = (List<MbnSmsHadSend>) page.getData(); entityMap = new HashMap<String, Object>(); entityMap.put("total", page.getRecords()); if (datas == null) { datas = new ArrayList<MbnSmsHadSend>(); } entityMap.put("rows", datas); entityMap.put("totalrecords", page.getTotal()); entityMap.put("currpage", page.getStart()); } } catch (Exception e) { e.printStackTrace(); return ERROR; } } return SUCCESS; }
/** * 导出已发箱结果 * * @return */ @Action( value = "exportResult", results = { @Result( type = "json", params = {"root", "entityMap", "contentType", "text/html"}) }) public String exportResult() { try { PageUtil pageUtil = new PageUtil(); pageUtil.setColumn3("export"); // 用于判断,sql是否分页 pageUtil.setBatchId(Long.valueOf(batchId)); Users u = (Users) super.getSession().getAttribute(ApSmsConstants.SESSION_USER_INFO); pageUtil.setMerchantPin(u.getMerchantPin()); if (!StringUtil.isEmpty(searchBycontacts)) { pageUtil.setContactName(URLDecoder.decode(searchBycontacts, "UTF-8")); } if (!StringUtil.isEmpty(sendResult) && !sendResult.equals("4")) { pageUtil.setSendResult(Integer.valueOf(sendResult)); } Page page = mbnSmsHadSendService.batchPage(pageUtil); if (page != null) { @SuppressWarnings("unchecked") List<MbnSmsHadSend> datas = (List<MbnSmsHadSend>) page.getData(); entityMap = new HashMap<String, Object>(); if (datas == null) { datas = new ArrayList<MbnSmsHadSend>(); } int size = datas.size(); String[][] billsInArr = new String[size][4]; for (int j = 0; j < size; j++) { MbnSmsHadSend mbnSmsHadSend = datas.get(j); int status = mbnSmsHadSend.getSendResult(); String smsStatus = ""; switch (status) { case -1: smsStatus = "取消发送"; break; case 0: smsStatus = "未发送"; break; case 1: smsStatus = "已提交网关"; break; case 2: smsStatus = "成功"; break; case 3: smsStatus = "失败"; break; default: smsStatus = "无"; break; } billsInArr[j][0] = mbnSmsHadSend.getTos(); // 手机号码 billsInArr[j][1] = (mbnSmsHadSend.getTosName() == null || mbnSmsHadSend.getTosName() == "" ? "(未知)" : mbnSmsHadSend.getTosName()); // 接收人姓名 billsInArr[j][2] = smsStatus; // 状态 -1取消发送,0未发送,1已提交网关,2成功,3失败 billsInArr[j][3] = (mbnSmsHadSend.getFailReason() == null || mbnSmsHadSend.getFailReason() == "" ? "(无)" : mbnSmsHadSend.getFailReason()); // 失败原因 } String[] cols = {"手机号码", "接收人姓名", "发送结果", "失败原因"}; String downLoadPath = ExportUtil.exportToExcel(getRequest(), "SMS_HADSEND_RESULT", cols, billsInArr); entityMap.put("fileName", downLoadPath); entityMap.put("message", "导出" + size + "条已发箱发送结果记录成功!"); entityMap.put("resultcode", SUCCESS); } } catch (Exception e) { entityMap = new HashMap<String, Object>(); entityMap.put("resultcode", ERROR); entityMap.put("message", "导出已发箱发送结果出错,请稍后再试"); e.printStackTrace(); return ERROR; } return SUCCESS; }
@Action( value = "retry", results = { @Result( type = "json", params = {"root", "entityMap", "contentType", "text/html"}) }) public String retry() { String result = SUCCESS; entityMap = new HashMap<String, Object>(); if (!StringUtil.isEmpty(smsIds)) { try { // String[] stringArr = smsIds.split(","); // Long[] ids = ConvertUtil.arrStringToLong(stringArr); // List<MbnSmsHadSend> smsList = mbnSmsHadSendService.getByPks(ids); PageUtil pageUtil = new PageUtil(); pageUtil.setBatchId(Long.parseLong(smsIds)); pageUtil.setSendResult(3); List<MbnSmsHadSend> smsList = null; Page batchTry = mbnSmsHadSendService.batchPage(pageUtil); if (batchTry != null) { smsList = (List<MbnSmsHadSend>) batchTry.getData(); } if (smsList != null) { ListIterator<MbnSmsHadSend> smsIterator = smsList.listIterator(); List<MbnSmsReadySend> smsRetry = new ArrayList<MbnSmsReadySend>(); long batchId = PinGen.getSerialPin(); while (smsIterator.hasNext()) { MbnSmsHadSend tempSms = smsIterator.next(); MbnSmsReadySend tempTry = new MbnSmsReadySend(); tempTry.setBatchId(batchId); tempTry.setContent(tempSms.getContent()); tempTry.setCreateBy(tempSms.getCreateBy()); tempTry.setCutApartNumber(tempSms.getCutApartNumber()); tempTry.setDescription(tempSms.getDescription()); tempTry.setId(PinGen.getSerialPin()); tempTry.setMerchantPin(tempSms.getMerchantPin()); tempTry.setOperationId(tempSms.getOperationId()); tempTry.setPriorityLevel(tempSms.getPriorityLevel()); tempTry.setProvince(tempSms.getProvince()); tempTry.setSelfMobile(tempSms.getSelfMobile()); tempTry.setSmsAccessNumber(tempSms.getSmsAccessNumber()); tempTry.setTaskNumber(tempSms.getTaskNumber()); tempTry.setTitle(tempSms.getTitle()); tempTry.setTos(tempSms.getTos()); tempTry.setTosName(tempSms.getTosName()); tempTry.setTunnelType(tempSms.getTunnelType()); tempTry.setWebService(tempSms.getWebService()); tempTry.setCompleteTime(null); // retry tempTry.setReadySendTime(new Date()); tempTry.setCommitTime(new Date()); tempTry.setSendResult(ApSmsConstants.SMS_READY_STATE); tempTry.setFailReason(""); tempTry.setExpireTime(null); smsRetry.add(tempTry); } mbnSmsReadySendService.batchSaveByList(smsRetry); entityMap.put("resultcode", "success"); entityMap.put("message", "短信失败重发命令提交成功!请勿短时间内重复点击“重发失败项”按钮。"); } else { entityMap.put("resultcode", "error"); entityMap.put("message", "未找到失败短信信息!"); } } catch (Exception e) { entityMap.put("resultcode", "error"); entityMap.put("message", "短信失败重发命令提交失败!请重试"); result = ERROR; e.printStackTrace(); } } return result; }