Commit 053af0c5 authored by wuzhilong's avatar wuzhilong

不合格邮寄订单下载

parent 3e6b5362
......@@ -538,7 +538,7 @@ public class PersonPostApi {
HSSFRow row = sheet.createRow(i + 1);
PersonPostEntity personPostEntity = records.get(i);
HSSFCell cell = row.createCell(0);
cell.setCellValue(personPostEntity.getId());
cell.setCellValue(personPostEntity.getOrderNumber());
cell = row.createCell(1);
cell.setCellValue("人口管理总队");
cell = row.createCell(2);
......@@ -716,4 +716,120 @@ public class PersonPostApi {
logger.error("Exception 创建报表异常", e);
}
}
@RequestMapping("downLoadInvalidOrder")
public void exportInvalidOrderExcel(HttpServletRequest request, HttpServletResponse response,
@RequestParam("beginDate") String beginDate,@RequestParam("endDate") String endDate) throws Exception {
String remoteAddr = request.getRemoteAddr();
MDC.put("ip", remoteAddr);
JSONArray jsonArray = new JSONArray();
try {
List<Map<String,Object>> list = personPostService.selectCancelPost(replaceDate(beginDate),replaceDate(endDate));
exportInvalidOrder(request, response, list);
} catch (Exception e) {
logger.error("起始日期:" + beginDate + endDate + "截至日期" + endDate );
logger.error("Exception 下载无效订单Excel异常", e);
}
}
/**
* 创建错误订单模板
*/
private void exportInvalidOrder(HttpServletRequest request, HttpServletResponse response,List<Map<String,Object>> records) throws Exception {
String remoteAddr = request.getRemoteAddr();
MDC.put("ip", remoteAddr);
try {
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("不合格订单");
HSSFCellStyle style = wb.createCellStyle();
style.setAlignment(HorizontalAlignment.CENTER);
HSSFRow firstRow = sheet.createRow(0);
String[] rowTitle = {"NO.","订单号", "上传受理号", "取消原因", "申请人", "出生日期", "收件人","收件人电话", "内件信息", "提交人", "提交时间", "收件地址"};
for (int i = 0; i < rowTitle.length; i++) {
HSSFCell cell = firstRow.createCell(i);
cell.setCellValue(rowTitle[i]);
cell.setCellStyle(style);
}
sheet.setColumnWidth(0, (int) ((6.67 + 0.72) * 256));
sheet.setColumnWidth(1, (int) ((12.36 + 0.72) * 256));
sheet.setColumnWidth(2, (int) ((24 + 0.72) * 256));
sheet.setColumnWidth(3, (int) ((44 + 0.72) * 256));
sheet.setColumnWidth(4, (int) ((10.55 + 0.72) * 256));
sheet.setColumnWidth(5, (int) ((12.36 + 0.72) * 256));
sheet.setColumnWidth(6, (int) ((10.55 + 0.72) * 256));
sheet.setColumnWidth(7, (int) ((14.64 + 0.72) * 256));
sheet.setColumnWidth(8, (int) ((28 + 0.72) * 256));
sheet.setColumnWidth(9, (int) ((7 + 0.72) * 256));
sheet.setColumnWidth(10, (int) ((19 + 0.72) * 256));
sheet.setColumnWidth(11, (int) ((55 + 0.72) * 256));
for (int i = 0; i < records.size(); i++) {
HSSFRow row = sheet.createRow(i + 1);
Map<String,Object> map = records.get(i);
HSSFCell cell = row.createCell(0);
cell.setCellValue(i+1);
cell = row.createCell(1);
cell.setCellValue(map.get("ORDER_NUMBER").toString());
cell = row.createCell(2);
cell.setCellValue(map.get("UPLOAD_NO").toString());
cell = row.createCell(3);
cell.setCellValue(map.get("REMARKS").toString());
cell = row.createCell(4);
cell.setCellValue(map.get("APPLICANT_NAME").toString());
cell = row.createCell(5);
cell.setCellValue(map.get("BIRTH_DATE").toString());
cell = row.createCell(6);
cell.setCellValue(map.get("RECIPIENT_NAME").toString());
cell = row.createCell(7);
cell.setCellValue(map.get("RECIPIENT_PHONE").toString());
cell = row.createCell(8);
cell.setCellValue(map.get("NATURE_OF_THE_INFORMATION").toString());
cell = row.createCell(9);
cell.setCellValue(map.get("NAME").toString());
cell = row.createCell(10);
cell.setCellValue(map.get("UP_TIUME").toString());
cell = row.createCell(11);
cell.setCellValue(map.get("RECIPIENT_ADDRESS").toString());
}
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月dd日不合格订单导出");
String fileName = simpleDateFormat.format(new Date()) + ".xls";
String rtn = "";
fileName = URLEncoder.encode(fileName, "UTF8");
String userAgent = request.getHeader("User-Agent");
/*针对IE或者以IE为内核的浏览器:*/
if (userAgent != null) {
userAgent = userAgent.toLowerCase();
/*IE浏览器,只能采用URLEncoder编码*/
if (userAgent.contains("msie")) {
rtn = "filename=\"" + fileName + "\"";
}
/*Opera浏览器只能采用filename**/
else if (userAgent.contains("opera")) {
rtn = "filename*=UTF-8''" + fileName;
}
/*Safari浏览器,只能采用ISO编码的中文输出*/
else if (userAgent.contains("safari")) {
rtn = "filename=\"" + new String(fileName.getBytes(StandardCharsets.UTF_8), "ISO8859-1") + "\"";
}
/*Chrome浏览器,只能采用MimeUtility编码或ISO编码的中文输出*/
// else if (userAgent.indexOf("applewebkit") != -1) {
// fileName = MimeUtility.encodeText(fileName, "UTF8", "B");
// rtn = "filename=\"" + fileName + "\"";
// }
/* FireFox浏览器,可以使用MimeUtility或filename*或ISO编码的中文输出*/
else if (userAgent.contains("mozilla")) {
rtn = "filename*=UTF-8''" + fileName;
}
}
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition", "attachment;" + rtn);
response.setCharacterEncoding("UTF-8");
OutputStream outputStream = response.getOutputStream();
wb.write(outputStream);
outputStream.flush();
outputStream.close();
} catch (Exception e) {
logger.error("个人邮寄信息:" + records);
logger.error("Exception 创建不合格订单异常", e);
}
}
}
......@@ -153,7 +153,8 @@ public interface PersonPostMapper {
@Select("SELECT af.*,pp.APPLICANT_NAME,pp.NATURE_OF_THE_INFORMATION,pp.RECIPIENT_NAME,pp.RECIPIENT_ADDRESS,pp.RECIPIENT_PHONE,pp.ORDER_NUMBER,pp.BIRTH_DATE FROM AUDLIT_FAILURE af\n" +
"left join PERSON_POST pp \n" +
"on af.UPLOAD_NO=pp.FIRST_WHITE " +
"WHERE TO_CHAR(UP_TIUME,'yyyyMMdd') BETWEEN #{beginDate} AND #{endDate}")
"WHERE TO_CHAR(UP_TIUME,'yyyyMMdd') BETWEEN #{beginDate} AND #{endDate}" +
" order by af.ID")
public List<Map<String, Object>> selectCancelPost(@Param("beginDate")String beginDate,@Param("endDate") String endDate);
@Select("SELECT * FROM PERSON_POST WHERE FIRST_WHITE = #{acceptNo}")
......@@ -199,4 +200,27 @@ public interface PersonPostMapper {
" where FILE_ID=#{fileID})")
public int findBackWaybillNumber( @Param("fileID") String fileID);
@Select("<script> " +
"SELECT af.*,pp.APPLICANT_NAME,pp.NATURE_OF_THE_INFORMATION,pp.RECIPIENT_NAME,pp.RECIPIENT_ADDRESS,pp.RECIPIENT_PHONE,pp.ORDER_NUMBER,pp.BIRTH_DATE\n" +
" FROM AUDLIT_FAILURE af \n" +
" left join PERSON_POST pp on af.UPLOAD_NO=pp.FIRST_WHITE\n" +
" LEFT JOIN FILE_NAME_DIC ON FILE_NAME_DIC.FILE_ID=pp.FILE_ID " +
" WHERE 1=1" +
" <when test='sqrxm!=\"\"'> and pp.APPLICANT_NAME = #{sqrxm} </when>" +
" <when test='ddh!=\"\"'> and pp.ORDER_NUMBER=#{ddh} </when>" +
// " <when test='hasPrinted!=\"\"'> and PERSON_POST.STATE=#{hasPrinted} </when>" +
" <when test='hasPrinted== 0 '> and pp.print_date is null </when>" +
" <when test='hasPrinted== 1 '> and pp.print_date is not null </when>" +
" <when test='gkxx!=\"\"'> and pp.LATTICE_MOUTH_INFORMATION=#{gkxx} </when>" +
" <when test='emailNo!=\"\"'> and pp.WAYBILL_NUMBER=TO_NUMBER(#{emailNo}) </when>" +
" <when test='str!=\"\"'> and pp.GET_TO_COUNTY in ( ${str} ) </when>" +
" <when test='startDate!=\"\"'> and subStr(FILE_NAME_DIC.UPLOAD_DATE,0,8) between #{startDate} and #{endDate} </when>" +
" <when test='printDate!=\"\"'> and to_char(pp.print_Date,'yyyyMMdd')=${printDate} </when>" +
" <when test='notNull!=\"\"'> and pp.state1=${notNull} </when>" +
" order by pp.ORDER_NUMBER " +
"</script>")
public List<Map<String,Object>> findAllPoarInvalidOrder( @Param("sqrxm") String sqrxm, @Param("ddh") String ddh, @Param("hasPrinted") String hasPrinted,
@Param("gkxx") String gkxx, @Param("str") String str, @Param("startDate") String startDate,@Param("endDate") String endDate, @Param("emailNo") String emailNo,@Param("printDate") String printDate,@Param("notNull") String notNull );
}
......@@ -60,4 +60,7 @@ public interface PersonPostService {
public int findWaybillNumber( @Param("fileID") String fileID);
public int findBackWaybillNumber( @Param("fileID") String fileID);
public List<Map<String,Object>> downLoadInvalidOrder(HttpServletRequest request,HttpServletResponse response,String sqrxm, String ddh, String hasPrinted, String gkxx, JSONArray jsonArray,String starDate,String endDate,String emailNo,String printDate,String notNull);
}
......@@ -42,7 +42,7 @@
<tr>
<td style="text-align:left;"><strong>内件信息:</strong>{{item.natureOfTheInformation}}</td>
<td style="text-align:left;"><strong>申请人姓名:</strong>{{item.applicantName}}</td>
<td style="text-align:left;"><strong>出生日期:</strong>{{item.birthDate|date:'yyyy-MM-dd'}}</td>
<td style="text-align:left;"><strong>出生日期:</strong>{{item.birthDate}}</td>
</tr>
<tr>
<td colspan="3" style="text-align:left;"><strong>备注:</strong><h4>{{item.note}}</h4></td>
......
......@@ -135,6 +135,7 @@
<button class="btn btn-primary" ng-click="aselectAF()">查询</button>
</div>
</td>
<td><button type="submit" class="btn btn-info" style="margin-right: 7px;" ng-click="downloadInvalidOrderExcel()"> 不合格订单Excel模板</button></td>
</tr>
</table>
<div class="box-info" style="padding: 7px;padding-top: 0px;">
......
......@@ -150,5 +150,22 @@ angular.module('AvatarCheck.addAuditFailure', ['ngRoute', 'AvatarCheck.http'])
});
}
};
//下载不合格订单excel
$scope.downloadInvalidOrderExcel = function(){
var begDate = $('#datepicker1').val();
var endDate = $('#datepicker2').val();
if(begDate==""){
begDate=$scope.choseDate1;
}
if(endDate==""){
endDate=$scope.choseDate;
}
var url = '../personPostApi/downLoadInvalidOrder?beginDate='+begDate+'&endDate='+endDate;
var a = document.createElement("a");
document.body.appendChild(a);
a.href = encodeURI(url);
a.click();
}
});
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment