Commit d16f6b79 authored by liboyang's avatar liboyang

整合完成

parent 5d871a1d
...@@ -29,11 +29,7 @@ ...@@ -29,11 +29,7 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-web</artifactId>
</dependency> </dependency>
<!--引入jersey作为http rest接口实现-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jersey</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.mybatis.spring.boot</groupId> <groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId> <artifactId>mybatis-spring-boot-starter</artifactId>
......
package com.yxproject.start.api; package com.yxproject.start.api;
import com.yxproject.start.entity.*; import com.yxproject.start.entity.SysPermission;
import com.yxproject.start.service.ProductionTaskListService; import com.yxproject.start.entity.SysRole;
import com.yxproject.start.entity.UserInfo;
import com.yxproject.start.service.SysPermissionService; import com.yxproject.start.service.SysPermissionService;
import com.yxproject.start.service.SysRoleService; import com.yxproject.start.service.SysRoleService;
import com.yxproject.start.service.UserInfoService; import com.yxproject.start.service.UserInfoService;
import com.yxproject.start.utils.Md5Utils; import com.yxproject.start.utils.Md5Utils;
import com.yxproject.start.utils.YXJSONResponse;
import net.sf.json.JSONArray; import net.sf.json.JSONArray;
import net.sf.json.JSONObject; import net.sf.json.JSONObject;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.IncorrectCredentialsException;
import org.apache.shiro.authc.UnknownAccountException;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.authz.annotation.RequiresRoles; import org.apache.shiro.authz.annotation.RequiresRoles;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.POST; import java.util.HashMap;
import java.util.*;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.UUID;
/** /**
......
...@@ -5,6 +5,9 @@ import com.yxproject.start.service.*; ...@@ -5,6 +5,9 @@ import com.yxproject.start.service.*;
import com.yxproject.start.utils.YXJSONResponse; import com.yxproject.start.utils.YXJSONResponse;
import net.sf.json.JSONArray; import net.sf.json.JSONArray;
import net.sf.json.JSONObject; import net.sf.json.JSONObject;
import org.apache.commons.lang.time.DateFormatUtils;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.shiro.SecurityUtils; import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.IncorrectCredentialsException; import org.apache.shiro.authc.IncorrectCredentialsException;
import org.apache.shiro.authc.UnknownAccountException; import org.apache.shiro.authc.UnknownAccountException;
...@@ -13,10 +16,11 @@ import org.apache.shiro.authz.annotation.RequiresPermissions; ...@@ -13,10 +16,11 @@ import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.subject.Subject; import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.LinkedHashMap; import javax.servlet.http.HttpServletResponse;
import java.util.List; import java.io.*;
import java.util.Map; import java.text.SimpleDateFormat;
import java.util.*;
/** /**
* @author Administrator * @author Administrator
...@@ -29,10 +33,10 @@ public class UserApi { ...@@ -29,10 +33,10 @@ public class UserApi {
@Autowired @Autowired
private UserInfoService userInfoService; private GroupNoService groupNoService;
@Autowired @Autowired
private SysRoleService sysRoleService; private PoliceStationApplyReasonService policeStationApplyReasonService;
@Autowired @Autowired
private SysPermissionService sysPermissionService; private SysPermissionService sysPermissionService;
...@@ -81,7 +85,7 @@ public class UserApi { ...@@ -81,7 +85,7 @@ public class UserApi {
*/ */
@RequestMapping(value = "/getProductionTaskListByID", method = RequestMethod.GET) @RequestMapping(value = "/getProductionTaskListByID", method = RequestMethod.GET)
@ResponseBody @ResponseBody
public String getProductionTaskListByID(@RequestParam("id") String id, @Context HttpServletResponse resp) { public String getProductionTaskListByID(@RequestParam("id") String id, HttpServletResponse resp) {
List<TaskEntity> productionTaskListEntity = taskService.findProductionTaskListEntityByID(Long.valueOf(id)); List<TaskEntity> productionTaskListEntity = taskService.findProductionTaskListEntityByID(Long.valueOf(id));
YXJSONResponse yxjsonResponse = new YXJSONResponse(); YXJSONResponse yxjsonResponse = new YXJSONResponse();
...@@ -99,7 +103,7 @@ public class UserApi { ...@@ -99,7 +103,7 @@ public class UserApi {
@RequestMapping(value = "/updateProductionTask", method = RequestMethod.GET) @RequestMapping(value = "/updateProductionTask", method = RequestMethod.GET)
@RequiresPermissions("userInfo.add")//权限管理; @RequiresPermissions("userInfo.add")//权限管理;
@ResponseBody @ResponseBody
public String updateProductionTask(@RequestParam("id") String id, @Context HttpServletResponse resp) { public String updateProductionTask(@RequestParam("id") String id, HttpServletResponse resp) {
String map = "{\"production_Task_List_Id\":\"20181016001\",\"make_Type\":8,\"old_Make_Type\":8,} "; String map = "{\"production_Task_List_Id\":\"20181016001\",\"make_Type\":8,\"old_Make_Type\":8,} ";
JSONObject jsonObject = JSONObject.fromObject(map); JSONObject jsonObject = JSONObject.fromObject(map);
TaskEntity productionTaskListEntity = (TaskEntity) jsonObject.toBean(jsonObject, TaskEntity.class); TaskEntity productionTaskListEntity = (TaskEntity) jsonObject.toBean(jsonObject, TaskEntity.class);
...@@ -118,7 +122,7 @@ public class UserApi { ...@@ -118,7 +122,7 @@ public class UserApi {
@RequestMapping(value = "/addProductionTaskList", method = RequestMethod.GET) @RequestMapping(value = "/addProductionTaskList", method = RequestMethod.GET)
@RequiresPermissions("userInfo.add")//权限管理; @RequiresPermissions("userInfo.add")//权限管理;
@ResponseBody @ResponseBody
public String addProductionTaskList(@RequestParam("id") String id, @Context HttpServletResponse resp) { public String addProductionTaskList(@RequestParam("id") String id, HttpServletResponse resp) {
String map = "{\"productionTaskListId\":\"20181016001\",\"makeType\":4,\"oldMakeType\":7}"; String map = "{\"productionTaskListId\":\"20181016001\",\"makeType\":4,\"oldMakeType\":7}";
JSONObject jsonObject = JSONObject.fromObject(map); JSONObject jsonObject = JSONObject.fromObject(map);
Object taskList = jsonObject.get("taskList"); Object taskList = jsonObject.get("taskList");
...@@ -140,7 +144,7 @@ public class UserApi { ...@@ -140,7 +144,7 @@ public class UserApi {
@RequestMapping(value = "/findCardInfoByCardIDOrAcceptNo", method = RequestMethod.GET) @RequestMapping(value = "/findCardInfoByCardIDOrAcceptNo", method = RequestMethod.GET)
@RequiresPermissions("userInfo.add")//权限管理; @RequiresPermissions("userInfo.add")//权限管理;
@ResponseBody @ResponseBody
public String findCardInfoByCardIDOrAcceptNo(@RequestParam("id") String id, @Context HttpServletResponse resp) { public String findCardInfoByCardIDOrAcceptNo(@RequestParam("id") String id, HttpServletResponse resp) {
YXJSONResponse yxjsonResponse = new YXJSONResponse(); YXJSONResponse yxjsonResponse = new YXJSONResponse();
resp.setCharacterEncoding("UTF-8"); resp.setCharacterEncoding("UTF-8");
...@@ -156,7 +160,7 @@ public class UserApi { ...@@ -156,7 +160,7 @@ public class UserApi {
@RequestMapping(value = "/addQuickCyclesheetInfo", method = RequestMethod.GET) @RequestMapping(value = "/addQuickCyclesheetInfo", method = RequestMethod.GET)
@RequiresPermissions("userInfo.add")//权限管理; @RequiresPermissions("userInfo.add")//权限管理;
@ResponseBody @ResponseBody
public String addQuickCyclesheetInfo(@RequestParam("id") String id, @Context HttpServletResponse resp) { public String addQuickCyclesheetInfo(@RequestParam("id") String id, HttpServletResponse resp) {
YXJSONResponse yxjsonResponse = new YXJSONResponse(); YXJSONResponse yxjsonResponse = new YXJSONResponse();
resp.setCharacterEncoding("UTF-8"); resp.setCharacterEncoding("UTF-8");
...@@ -173,7 +177,7 @@ public class UserApi { ...@@ -173,7 +177,7 @@ public class UserApi {
@RequestMapping(value = "/savePoliceStationVailedInfoEntity", method = RequestMethod.GET) @RequestMapping(value = "/savePoliceStationVailedInfoEntity", method = RequestMethod.GET)
@RequiresPermissions("userInfo.add")//权限管理; @RequiresPermissions("userInfo.add")//权限管理;
@ResponseBody @ResponseBody
public String savePoliceStationVailedInfoEntity(@RequestParam("id") String id, @Context HttpServletResponse resp) { public String savePoliceStationVailedInfoEntity(@RequestParam("id") String id, HttpServletResponse resp) {
String map = "[{\"cyclesheetid\":\"20181016001\",\"invalid_Count\":1,\"police_Station_Code\":\"41108201\",\"police_Station_Vailed_Info_Id\":\"1\",\"sava_Date\":\"20181025\",\"vailed_Count\":1}]"; String map = "[{\"cyclesheetid\":\"20181016001\",\"invalid_Count\":1,\"police_Station_Code\":\"41108201\",\"police_Station_Vailed_Info_Id\":\"1\",\"sava_Date\":\"20181025\",\"vailed_Count\":1}]";
JSONArray jsonArray = JSONArray.fromObject(map); JSONArray jsonArray = JSONArray.fromObject(map);
List<PoliceStationVailedEntity> policeStationVailedInfoEntities = new ArrayList<>(); List<PoliceStationVailedEntity> policeStationVailedInfoEntities = new ArrayList<>();
...@@ -197,7 +201,8 @@ public class UserApi { ...@@ -197,7 +201,8 @@ public class UserApi {
@RequestMapping("/test") @RequestMapping("/test")
@RequiresPermissions("userInfo.add")//权限管理; @RequiresPermissions("userInfo.add")//权限管理;
@ResponseBody @ResponseBody
public String test(@RequestParam("id") String permissionId, @Context HttpServletResponse resp) { public String test(@RequestParam("id") String permissionId,HttpServletResponse resp) {
//TODO
YXJSONResponse yxjsonResponse = new YXJSONResponse(); YXJSONResponse yxjsonResponse = new YXJSONResponse();
resp.setCharacterEncoding("UTF-8"); resp.setCharacterEncoding("UTF-8");
List<PoliceStationVailedEntity> policeStationVailedEntities = taskService.find(permissionId); List<PoliceStationVailedEntity> policeStationVailedEntities = taskService.find(permissionId);
...@@ -206,5 +211,847 @@ public class UserApi { ...@@ -206,5 +211,847 @@ public class UserApi {
return yxjsonResponse.toJSONString(); return yxjsonResponse.toJSONString();
} }
/**
* 保存废证详情;
* @return
*/
@RequestMapping("addFailedinfo")
public String addFailedinfo(@RequestParam("id") String id,HttpServletResponse resp){
String map ="[{\"failedinfoid\":\"20181016002\",\"failed_Reason\":1,\"groupno\":\"41108201\",\"cyclesheetid\":\"20181016001\"}]";
JSONArray jsonArray = JSONArray.fromObject(map);
List<FailedCardEntity> failedinfoEntityList = new ArrayList<>();
for (Object object: jsonArray) {
FailedCardEntity o = (FailedCardEntity) JSONObject.toBean((JSONObject) object, FailedCardEntity.class);
failedinfoEntityList.add(o);
}
YXJSONResponse yxjsonResponse = new YXJSONResponse();
resp.setCharacterEncoding("UTF-8");
int i = failedCardService.saveFailedinfo(failedinfoEntityList);
yxjsonResponse.outPutSuccess(i+"添加成功");
return yxjsonResponse.toJSONString();
}
/**
* 更新废证详情;
* @return
*/
@RequestMapping("updateFailedinfo")
@RequiresPermissions("userInfo.add")//权限管理;
public String updateFailedinfo(@RequestParam("id") String id, HttpServletResponse resp){
String map ="[{\"failedinfoid\":\"201810302\",\"failed_Reason\":1,\"groupno\":\"411081\",\"cyclesheetid\":\"20181016001\"}]";
JSONArray jsonArray = JSONArray.fromObject(map);
List<FailedCardEntity> failedinfoEntityList = new ArrayList<>();
for (Object object: jsonArray) {
FailedCardEntity o = (FailedCardEntity) JSONObject.toBean((JSONObject) object, FailedCardEntity.class);
failedinfoEntityList.add(o);
}
YXJSONResponse yxjsonResponse = new YXJSONResponse();
resp.setCharacterEncoding("UTF-8");
int i = failedCardService.updateFailedinfo(failedinfoEntityList);
yxjsonResponse.outPutSuccess(i+"更新成功");
return yxjsonResponse.toJSONString();
}
/**
* 查询废证详情;
* @return
*/
@RequestMapping("findFailedinfo")
@RequiresPermissions("userInfo.add")//权限管理;
public String findFailedinfo(@RequestParam("id") String id, HttpServletResponse resp){
YXJSONResponse yxjsonResponse = new YXJSONResponse();
resp.setCharacterEncoding("UTF-8");
List<Map<String, Object>> maps = failedCardService.selectFailedinfo(Integer.valueOf(id));
yxjsonResponse.outPutSuccess(maps+"------添加成功---"+maps.size());
return yxjsonResponse.toJSONString();
}
/**
* 查询任务单详情;
* @return
*/
@RequestMapping("findProductionTaskListByState")
@RequiresPermissions("userInfo.add")//权限管理;
public String findProductionTaskListByState(@RequestParam("state") String state, HttpServletResponse resp){
YXJSONResponse yxjsonResponse = new YXJSONResponse();
resp.setCharacterEncoding("UTF-8");
List<Map<String, Object>> productionTaskInfoList = taskService.findProductionTaskListEntityByState(Integer.valueOf(state));
yxjsonResponse.outPutSuccess(productionTaskInfoList);
return yxjsonResponse.toJSONString();
}
/**
* 查询区县列表详情;
* @return
*/
@RequestMapping("findProdCountyList")
@RequiresPermissions("userInfo.add")//权限管理;
public String findProdCountyList(@RequestParam("cyclesheetID") String cyclesheetID, HttpServletResponse resp){
YXJSONResponse yxjsonResponse = new YXJSONResponse();
resp.setCharacterEncoding("UTF-8");
List<Map<String, Object>> countyInfoList = groupNoService.findCountyInfoList(cyclesheetID);
yxjsonResponse.outPutSuccess(countyInfoList);
return yxjsonResponse.toJSONString();
}
/**
* 保存派出所申请类型数量;
* @return
*/
@RequestMapping("savePoliceApplyCount")
@RequiresPermissions("userInfo.add")//权限管理;
public String savePoliceApplyCount(@RequestParam("cyclesheetID") String cyclesheetID, HttpServletResponse resp){
YXJSONResponse yxjsonResponse = new YXJSONResponse();
resp.setCharacterEncoding("UTF-8");
int i = policeStationApplyReasonService.savePoliceStationApplyReasonEntity(cyclesheetID);
yxjsonResponse.outPutSuccess(i+"");
return yxjsonResponse.toJSONString();
}
/**
* 下载装箱单
*/
@RequestMapping("printPackingList")
// @RequiresPermissions("userInfo.add")//权限管理;
public byte[] printPackingList(@RequestParam("cyclesheetID") String taskID, HttpServletResponse response) {
// cyclesheetID ="20180802032";
response.setContentType("application/x-download");
response.setCharacterEncoding("UTF-8");
String dateTime = DateFormatUtils.format(new Date(), "yyyyMMddHH");
// //使用Servlet实现文件下载的时候,避免浏览器自动打开文件
String fout = null;
List<Map<String, Object>> countyInfoList = groupNoService.findCountyInfoList(taskID);
List<TaskEntity> taskEntities = taskService.findProductionTaskListEntityByID(Long.valueOf(taskID));
fout = exportExcel(countyInfoList, taskEntities.get(0).getCard_Type()+"", "p1", 6000, taskEntities.get(0).getCitycode() ,dateTime,taskID);
String outFile = dateTime + taskEntities.get(0).getCitycode() + "二代身份证统计表";
try {
FileInputStream fis = new FileInputStream(new File(fout));
byte[] b = new byte[fis.available()];
fis.read(b);
fis.close();
response.addHeader("Content-Disposition", "attachment;filename=" + outFile + ".xls");
return b;
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
/**
* 下载装箱单
*
* @param countyInfoList 装箱单信息
* @param typeName 制证类型
* @param workShop 制证车间
* @param sum 总数
* @param cityName 地市
*/
private String exportExcel(List<Map<String, Object>> countyInfoList, String typeName, String workShop, int sum, String cityName,String permanentPositionDate ,String cyclesheetid) {
if (typeName.contains("null")){
typeName=typeName.replace("null","");
}
//第一步创建workbook
HSSFWorkbook wb = new HSSFWorkbook();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
HSSFSheet sheet = wb.createSheet("二代身份证统计表");
sheet.setColumnWidth(0, (int) 30 * 100);
sheet.setColumnWidth(1, (int) 30 * 70);
sheet.setColumnWidth(2, (int) 30 * 80);
sheet.setColumnWidth(3, (int) 30 * 50);
sheet.setColumnWidth(4, (int) 30 * 110);
HSSFPrintSetup ps = sheet.getPrintSetup();
ps.setLandscape(true); // 打印方向,true:横向,false:纵向
ps.setPaperSize(HSSFPrintSetup.B5_PAPERSIZE); //纸张
sheet.setColumnWidth(0, (int) 35.7 * 100);
//第三步创建行row:添加表头0行
HSSFRow row = sheet.createRow(0);
HSSFCellStyle style = wb.createCellStyle();//样式
style.setVerticalAlignment(HSSFCellStyle.ALIGN_LEFT); //设置垂直居中
style.setAlignment(HSSFCellStyle.ALIGN_LEFT);
style.setWrapText(true);//设置自动换行
style.setBorderBottom(HSSFCellStyle.BORDER_THIN); //下边框
style.setBorderLeft(HSSFCellStyle.BORDER_THIN);//左边框
style.setBorderTop(HSSFCellStyle.BORDER_THIN);//上边框
style.setBorderRight(HSSFCellStyle.BORDER_THIN);//右边框
HSSFFont font = wb.createFont();
font.setFontHeightInPoints((short) 12);
style.setFont(font);
HSSFCellStyle style2 = wb.createCellStyle(); //表头样式
style2.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER); //设置垂直居中
style2.setAlignment(HSSFCellStyle.ALIGN_CENTER);
HSSFFont font2 = wb.createFont();
font2.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);//粗体显示
font2.setFontHeightInPoints((short) 14);
style2.setFont(font2);
row = sheet.createRow(0); //创建下标为0的单元格
row.setHeightInPoints(Short.parseShort("20"));//设置行高
HSSFCell cell = row.createCell(0); //设定值
cell.setCellValue("二代身份证统计表");
cell.setCellStyle(style2);
for (int i = 0; i < 4; i++) {
cell = row.createCell(i + 1);
cell.setCellValue("");
cell.setCellStyle(style2);
}
CellRangeAddress callRangeAddress = new CellRangeAddress(0, 0, 0, 4);//起始行,结束行,起始列,结束列
sheet.addMergedRegion(callRangeAddress);
row = sheet.createRow(1);
row.setHeightInPoints(Short.parseShort("16"));//设置行高
cell = row.createCell(0);
cell.setCellValue("单位"); //设定值
cell.setCellStyle(style); //内容居中
cell = row.createCell(1); //第二个单元格
cell.setCellValue("数量");
cell.setCellStyle(style);
cell = row.createCell(2); //第三个单元格
cell.setCellValue("质检号");
cell.setCellStyle(style);
cell = row.createCell(3); //第四个单元格
cell.setCellValue("盒数");
cell.setCellStyle(style);
cell = row.createCell(4); //第五个单元格
cell.setCellValue("入库日期");
cell.setCellStyle(style);
row = sheet.createRow(2);//i+2行之后开始创建
row.setHeightInPoints(Short.parseShort("16"));//设置行高
//创建单元格并且添加数据
cell = row.createCell(0);
cell.setCellValue(cityName);
cell.setCellStyle(style);
for (int i = 0; i < 4; i++) {
cell = row.createCell(i + 1);
cell.setCellValue("");
cell.setCellStyle(style);
}
//第五步插入数据
int num = 0;
for (int i = 0; i < countyInfoList.size(); i++) {
Map<String, Object> map = countyInfoList.get(i);
//创建行
row = sheet.createRow(i + 3);//i+2行之后开始创建
row.setHeightInPoints(Short.parseShort("16"));//设置行高
//创建单元格并且添加数据
cell = row.createCell(0);
cell.setCellValue((String) map.get("COUNTYNAME"));
cell.setCellStyle(style);
cell = row.createCell(1);
cell.setCellValue(map.get("DOWNLOAD").toString().equals("0") ? "" : map.get("DOWNLOAD").toString());
cell.setCellStyle(style);
cell = row.createCell(2);
cell.setCellValue("");
cell.setCellStyle(style);
cell = row.createCell(3);
cell.setCellValue(((Integer.parseInt(map.get("DOWNLOAD").toString()) % 250==0?Integer.parseInt(map.get("DOWNLOAD").toString()) / 250:Integer.parseInt(map.get("DOWNLOAD").toString()) / 250+1)) + "");
num += ((Integer.parseInt(map.get("DOWNLOAD").toString()) % 250==0?Integer.parseInt(map.get("DOWNLOAD").toString()) / 250:Integer.parseInt(map.get("DOWNLOAD").toString()) / 250+1));
cell.setCellStyle(style);
cell = row.createCell(4);
cell.setCellValue("");
cell.setCellStyle(style);
}
if (countyInfoList.size() < 16) {
for (int i = 0; i <= 16 - countyInfoList.size(); i++) {
//创建行
row = sheet.createRow(countyInfoList.size() + 3 + i);// 行之后开始创建
row.setHeightInPoints(Short.parseShort("16"));//设置行高
//创建单元格并且添加数据
for (int j = 0; j < 5; j++) {
cell = row.createCell(j);
cell.setCellValue("");
cell.setCellStyle(style);
}
}
row = sheet.createRow(18);
row.setHeightInPoints(Short.parseShort("16"));//设置行高
//创建单元格并且添加数据
cell = row.createCell(0);
cell.setCellValue("合计");
cell.setCellStyle(style);
cell = row.createCell(1);
cell.setCellValue(sum);
cell.setCellStyle(style);
cell = row.createCell(2);
cell.setCellValue("制证车间");
cell.setCellStyle(style);
if ("p1".equals(workShop) || "p3".equals(workShop)) {
cell = row.createCell(2);
cell.setCellValue(" 平 一 ");
cell.setCellStyle(style2);
} else {
cell = row.createCell(2);
cell.setCellValue("平二");
cell.setCellStyle(style2);
}
cell = row.createCell(3);
cell.setCellValue(num);
cell.setCellStyle(style);
cell = row.createCell(4);
cell.setCellValue(permanentPositionDate);
cell.setCellStyle(style);
row = sheet.createRow(19);
row.setHeightInPoints(Short.parseShort("16"));//设置行高
//创建单元格并且添加数据
cell = row.createCell(0);
cell.setCellValue("类型");
cell.setCellStyle(style);
cell = row.createCell(1);
cell.setCellValue(typeName);
cell.setCellStyle(style);
for (int j = 0; j < 3; j++) {
cell = row.createCell(j + 2);
cell.setCellValue("");
cell.setCellStyle(style);
}
CellRangeAddress callRangeNum1 = new CellRangeAddress(19, 19, 1, 4);//起始行,结束行,起始列,结束列
sheet.addMergedRegion(callRangeNum1);
row = sheet.createRow(20);
row.setHeightInPoints(Short.parseShort("32"));//设置行高
//创建单元格并且添加数据
cell = row.createCell(0);
cell.setCellValue("循环单");
cell.setCellStyle(style);
cell = row.createCell(1);
cell.setCellValue(cyclesheetid);
cell.setCellStyle(style);
for (int j = 0; j < 3; j++) {
cell = row.createCell(j + 2);
cell.setCellValue("");
cell.setCellStyle(style);
}
CellRangeAddress callRangeNum = new CellRangeAddress(20, 20, 1, 4);//起始行,结束行,起始列,结束列
sheet.addMergedRegion(callRangeNum);
row = sheet.createRow(21);
row.setHeightInPoints(Short.parseShort("16"));//设置行高
//创建单元格并且添加数据
cell = row.createCell(0);
cell.setCellValue("出库日期");
cell.setCellStyle(style);
cell = row.createCell(1);
cell.setCellValue("20 年 月 日");
cell.setCellStyle(style);
cell = row.createCell(2);
cell.setCellValue("");
cell.setCellStyle(style);
cell = row.createCell(3);
cell.setCellValue("");
cell.setCellStyle(style);
cell = row.createCell(4);
cell.setCellValue("");
cell.setCellStyle(style);
CellRangeAddress callRangedate = new CellRangeAddress(21, 21, 1, 4);//起始行,结束行,起始列,结束列
sheet.addMergedRegion(callRangedate);
}
if (countyInfoList.size() >= 16) {
row = sheet.createRow(countyInfoList.size() + 3);
row.setHeightInPoints(Short.parseShort("16"));//设置行高
//创建单元格并且添加数据
cell = row.createCell(0);
cell.setCellValue("合计");
cell.setCellStyle(style);
cell = row.createCell(1);
cell.setCellValue(sum);
cell.setCellStyle(style);
cell = row.createCell(2);
cell.setCellValue("制证车间");
cell.setCellStyle(style);
if ("p1".equals(workShop) || "p3".equals(workShop)) {
cell = row.createCell(2);
cell.setCellValue("平一");
cell.setCellStyle(style);
} else {
cell = row.createCell(2);
cell.setCellValue("平二");
cell.setCellStyle(style);
}
cell = row.createCell(3);
cell.setCellValue(num);
cell.setCellStyle(style);
cell = row.createCell(4);
cell.setCellValue(permanentPositionDate);
cell.setCellStyle(style);
row = sheet.createRow(countyInfoList.size() + 4);
row.setHeightInPoints(Short.parseShort("16"));//设置行高
//创建单元格并且添加数据
cell = row.createCell(0);
cell.setCellValue("类型");
cell.setCellStyle(style);
cell = row.createCell(1);
cell.setCellValue(typeName);
cell.setCellStyle(style);
for (int j = 0; j < 3; j++) {
cell = row.createCell(j + 2);
cell.setCellValue("");
cell.setCellStyle(style);
}
row = sheet.createRow(countyInfoList.size() + 5);
row.setHeightInPoints(Short.parseShort("32"));//设置行高
cell = row.createCell(0);
cell.setCellValue("循环单");
cell.setCellStyle(style);
cell = row.createCell(1);
cell.setCellValue(cyclesheetid);
cell.setCellStyle(style);
for (int j = 0; j < 3; j++) {
cell = row.createCell(j + 2);
cell.setCellValue("");
cell.setCellStyle(style);
}
CellRangeAddress callRangeNum = new CellRangeAddress(countyInfoList.size() + 5, countyInfoList.size() + 5, 1, 4);//起始行,结束行,起始列,结束列
sheet.addMergedRegion(callRangeNum);
row = sheet.createRow(countyInfoList.size() + 6);
row.setHeightInPoints(Short.parseShort("16"));//设置行高
//创建单元格并且添加数据
cell = row.createCell(0);
cell.setCellValue("出库日期");
cell.setCellStyle(style);
cell = row.createCell(1);
cell.setCellValue("20 年 月 日");
cell.setCellStyle(style);
for (int j = 0; j < 3; j++) {
cell = row.createCell(j + 2);
cell.setCellValue("");
cell.setCellStyle(style);
}
CellRangeAddress callRangedate = new CellRangeAddress(countyInfoList.size() + 6, countyInfoList.size() + 6, 1, 4);//起始行,结束行,起始列,结束列
sheet.addMergedRegion(callRangedate);
}
//创建分单
//创建辖区合单
HSSFSheet mergeSheet = wb.createSheet("辖区合单");
mergeSheet.setColumnWidth(0, (int) 30 * 115);
mergeSheet.setColumnWidth(1, (int) 30 * 70);
mergeSheet.setColumnWidth(2, (int) 30 * 80);
mergeSheet.setColumnWidth(3, (int) 30 * 50);
mergeSheet.setColumnWidth(4, (int) 30 * 110);
HSSFPrintSetup ps1 = mergeSheet.getPrintSetup();
ps1.setLandscape(true); // 打印方向,true:横向,false:纵向
ps1.setPaperSize(HSSFPrintSetup.B5_PAPERSIZE); //纸张
//计算合单的行数
int lineNum = 0;
//计算合单的总数
int mergeSum = 0;
//计算合单的盒数
int boxNum = 0;
for (int a = 0; a < countyInfoList.size(); a++) {
Map<String, Object> map = countyInfoList.get(a);
//第二步创建sheet
if (map.get("COUNTYNAME").toString().contains("区")) {
//第三步创建行row:添加表头0行
row = mergeSheet.createRow(0);
row.setHeightInPoints(Short.parseShort("20"));//设置行高
cell = row.createCell(0); //第一个单元格
cell.setCellValue("二代身份证统计表"); //设定值
cell.setCellStyle(style2);
for (int j = 0; j < 4; j++) {
cell = row.createCell(j + 1);
cell.setCellValue("");
cell.setCellStyle(style2);
}
CellRangeAddress callRange = new CellRangeAddress(0, 0, 0, 4);//起始行,结束行,起始列,结束列
mergeSheet.addMergedRegion(callRange);
row = mergeSheet.createRow(1);
row.setHeightInPoints(Short.parseShort("16"));//设置行高
//第四步创建单元格
cell = row.createCell(0); //第一个单元格
cell.setCellValue("单位"); //设定值
cell.setCellStyle(style); //内容居中
cell = row.createCell(1); //第二个单元格
cell.setCellValue("数量");
cell.setCellStyle(style);
cell = row.createCell(2); //第三个单元格
cell.setCellValue("质检号");
cell.setCellStyle(style);
cell = row.createCell(3); //第四个单元格
cell.setCellValue("盒数");
cell.setCellStyle(style);
cell = row.createCell(4); //第五个单元格
cell.setCellValue("入库日期");
cell.setCellStyle(style);
//第五步插入数据
//创建行
row = mergeSheet.createRow(2);
row.setHeightInPoints(Short.parseShort("16"));//设置行高
//创建单元格并且添加数据
cell = row.createCell(0);
cell.setCellValue(cityName);
cell.setCellStyle(style);
for (int j = 0; j < 4; j++) {
cell = row.createCell(j + 1);
cell.setCellValue("");
cell.setCellStyle(style);
}
row = mergeSheet.createRow(lineNum + 3);
row.setHeightInPoints(Short.parseShort("16"));//设置行高
//创建单元格并且添加数据
cell = row.createCell(0);
cell.setCellValue(map.get("COUNTYNAME").toString());
cell.setCellStyle(style);
cell = row.createCell(1);
cell.setCellValue(map.get("DOWNLOAD") + "");
mergeSum += Integer.valueOf(map.get("DOWNLOAD") + "");
cell.setCellStyle(style);
cell = row.createCell(2);
cell.setCellValue("");
cell.setCellStyle(style);
cell = row.createCell(3);
cell.setCellStyle(style);
cell.setCellValue(((Integer.parseInt(map.get("DOWNLOAD") + "") % 250==0?Integer.parseInt(map.get("DOWNLOAD") + "") / 250:Integer.parseInt(map.get("DOWNLOAD") + "") / 250+1)) + "");
boxNum += ((Integer.parseInt(map.get("DOWNLOAD") + "") % 250==0?Integer.parseInt(map.get("DOWNLOAD") + "") / 250:Integer.parseInt(map.get("DOWNLOAD") + "") / 250+1));
cell = row.createCell(4);
cell.setCellValue("");
cell.setCellStyle(style);
//创建空的行和列
for (int i = 0; i <= 14 - lineNum; i++) {
//创建行
row = mergeSheet.createRow(lineNum + 4 + i);// 行之后开始创建
row.setHeightInPoints(Short.parseShort("16"));//设置行高
//创建单元格并且添加数据
for (int j = 0; j < 5; j++) {
cell = row.createCell(j);
cell.setCellValue("");
cell.setCellStyle(style);
}
}
row = mergeSheet.createRow(18);
row.setHeightInPoints(Short.parseShort("16"));//设置行高
//创建单元格并且添加数据
cell = row.createCell(0);
cell.setCellValue("合计");
cell.setCellStyle(style);
cell = row.createCell(1);
cell.setCellValue(mergeSum + "");
cell.setCellStyle(style);
cell = row.createCell(2);
cell.setCellValue("制证车间");
cell.setCellStyle(style);
if ("p1".equals(workShop) || "p3".equals(workShop)) {
cell = row.createCell(2);
cell.setCellValue("平一");
cell.setCellStyle(style);
} else {
cell = row.createCell(2);
cell.setCellValue("平二");
cell.setCellStyle(style);
}
cell.setCellStyle(style);
cell = row.createCell(3);
cell.setCellValue(boxNum + "");
cell.setCellStyle(style);
cell = row.createCell(4);
cell.setCellValue(permanentPositionDate);
cell.setCellStyle(style);
//创建单元格并且添加数据
row = mergeSheet.createRow(19);
row.setHeightInPoints(Short.parseShort("16"));//设置行高
cell = row.createCell(0);
cell.setCellValue("类型");
cell.setCellStyle(style);
cell = row.createCell(1);
cell.setCellValue(typeName);
cell.setCellStyle(style);
cell = row.createCell(2);
cell.setCellValue("");
cell.setCellStyle(style);
cell = row.createCell(3);
cell.setCellValue("");
cell.setCellStyle(style);
cell = row.createCell(4);
cell.setCellValue("");
cell.setCellStyle(style);
CellRangeAddress callRangea = new CellRangeAddress(19, 19, 1, 4);//起始行,结束行,起始列,结束列
mergeSheet.addMergedRegion(callRangea);
//创建单元格并且添加数据
row = mergeSheet.createRow(20);
row.setHeightInPoints(Short.parseShort("32"));//设置行高
cell = row.createCell(0);
cell.setCellValue("编号");
cell.setCellStyle(style);
cell = row.createCell(1);
cell.setCellValue(cyclesheetid);
cell.setCellStyle(style);
cell = row.createCell(0);
cell.setCellValue("循环单");
cell.setCellStyle(style);
cell = row.createCell(2);
cell.setCellValue("");
cell.setCellStyle(style);
cell = row.createCell(3);
cell.setCellValue("");
cell.setCellStyle(style);
cell = row.createCell(4);
cell.setCellValue("");
cell.setCellStyle(style);
CellRangeAddress callRangea1 = new CellRangeAddress(20, 20, 1, 4);//起始行,结束行,起始列,结束列
mergeSheet.addMergedRegion(callRangea1);
row = mergeSheet.createRow(21);
row.setHeightInPoints(Short.parseShort("16"));//设置行高
//创建单元格并且添加数据
cell = row.createCell(0);
cell.setCellValue("出库日期");
cell.setCellStyle(style);
cell = row.createCell(1);
cell.setCellValue("20 年 月 日");
cell.setCellStyle(style);
cell = row.createCell(2);
cell.setCellValue("");
cell.setCellStyle(style);
cell = row.createCell(3);
cell.setCellValue("");
cell.setCellStyle(style);
cell = row.createCell(4);
cell.setCellValue("");
cell.setCellStyle(style);
CellRangeAddress callRangeb = new CellRangeAddress(21, 21, 1, 4);//起始行,结束行,起始列,结束列
mergeSheet.addMergedRegion(callRangeb);
lineNum++;
} else {
sheet = wb.createSheet(a + "-" + (String) map.get("COUNTYNAME"));
sheet.setColumnWidth(0, (int) 30 * 100);
sheet.setColumnWidth(1, (int) 30 * 70);
sheet.setColumnWidth(2, (int) 30 * 80);
sheet.setColumnWidth(3, (int) 30 * 50);
sheet.setColumnWidth(4, (int) 30 * 110);
HSSFPrintSetup ps2 = sheet.getPrintSetup();
ps2.setLandscape(true); // 打印方向,true:横向,false:纵向
ps2.setPaperSize(HSSFPrintSetup.B5_PAPERSIZE);
//第三步创建行row:添加表头0行
row = sheet.createRow(0);
row.setHeightInPoints(Short.parseShort("20"));//设置行高
cell = row.createCell(0); //第一个单元格
cell.setCellValue("二代身份证统计表"); //设定值
cell.setCellStyle(style2);
for (int j = 0; j < 4; j++) {
cell = row.createCell(j + 1);
cell.setCellValue("");
cell.setCellStyle(style2);
}
CellRangeAddress callRange = new CellRangeAddress(0, 0, 0, 4);//起始行,结束行,起始列,结束列
sheet.addMergedRegion(callRange);
row = sheet.createRow(1);
row.setHeightInPoints(Short.parseShort("16"));//设置行高
//第四步创建单元格
cell = row.createCell(0); //第一个单元格
cell.setCellValue("单位"); //设定值
cell.setCellStyle(style); //内容居中
cell = row.createCell(1); //第二个单元格
cell.setCellValue("数量");
cell.setCellStyle(style);
cell = row.createCell(2); //第三个单元格
cell.setCellValue("质检号");
cell.setCellStyle(style);
cell = row.createCell(3); //第四个单元格
cell.setCellValue("盒数");
cell.setCellStyle(style);
cell = row.createCell(4); //第五个单元格
cell.setCellValue("入库日期");
cell.setCellStyle(style);
//第五步插入数据
//创建行
row = sheet.createRow(2);
row.setHeightInPoints(Short.parseShort("16"));//设置行高
//创建单元格并且添加数据
cell = row.createCell(0);
// cell.setCellValue(typeName);
cell.setCellValue(cityName);
cell.setCellStyle(style);
for (int j = 0; j < 4; j++) {
cell = row.createCell(j + 1);
cell.setCellValue("");
cell.setCellStyle(style);
}
row = sheet.createRow(3);
row.setHeightInPoints(Short.parseShort("16"));//设置行高
//创建单元格并且添加数据
cell = row.createCell(0);
cell.setCellValue(map.get("COUNTYNAME").toString());
cell.setCellStyle(style);
cell = row.createCell(1);
cell.setCellValue(map.get("DOWNLOAD") + "");
cell.setCellStyle(style);
cell = row.createCell(2);
cell.setCellValue("");
cell.setCellStyle(style);
cell = row.createCell(3);
cell.setCellStyle(style);
cell.setCellValue(((Integer.parseInt(map.get("DOWNLOAD") + "") % 250==0?Integer.parseInt(map.get("DOWNLOAD") + "") / 250:Integer.parseInt(map.get("DOWNLOAD") + "") / 250+1)) + "");
cell = row.createCell(4);
cell.setCellValue("");
cell.setCellStyle(style);
//创建空的行和列
for (int i = 0; i <= 14; i++) {
//创建行
row = sheet.createRow(4 + i);// 行之后开始创建
row.setHeightInPoints(Short.parseShort("16"));//设置行高
//创建单元格并且添加数据
for (int j = 0; j < 5; j++) {
cell = row.createCell(j);
cell.setCellValue("");
cell.setCellStyle(style);
}
}
row = sheet.createRow(18);
row.setHeightInPoints(Short.parseShort("16"));//设置行高
//创建单元格并且添加数据
cell = row.createCell(0);
cell.setCellValue("合计");
cell.setCellStyle(style);
cell = row.createCell(1);
cell.setCellValue(Integer.valueOf(map.get("DOWNLOAD") + ""));
cell.setCellStyle(style);
cell = row.createCell(2);
cell.setCellValue("制证车间");
cell.setCellStyle(style);
if ("p1".equals(workShop) || "p3".equals(workShop)) {
cell = row.createCell(2);
cell.setCellValue("平一");
cell.setCellStyle(style);
} else {
cell = row.createCell(2);
cell.setCellValue("平二");
cell.setCellStyle(style);
}
cell.setCellStyle(style);
cell = row.createCell(3);
cell.setCellValue(((Integer.parseInt(map.get("DOWNLOAD") + "") % 250==0?Integer.parseInt(map.get("DOWNLOAD") + "") / 250:Integer.parseInt(map.get("DOWNLOAD") + "") / 250+1)) + "");
cell.setCellStyle(style);
cell = row.createCell(4);
cell.setCellValue(permanentPositionDate);
cell.setCellStyle(style);
//创建单元格并且添加数据
row = sheet.createRow(19);
row.setHeightInPoints(Short.parseShort("16"));//设置行高
cell = row.createCell(0);
cell.setCellValue("类型");
cell.setCellStyle(style);
cell = row.createCell(1);
cell.setCellValue(typeName);
cell.setCellStyle(style);
cell = row.createCell(2);
cell.setCellValue("");
cell.setCellStyle(style);
cell = row.createCell(3);
cell.setCellValue("");
cell.setCellStyle(style);
cell = row.createCell(4);
cell.setCellValue("");
cell.setCellStyle(style);
CellRangeAddress callRangea = new CellRangeAddress(19, 19, 1, 4);//起始行,结束行,起始列,结束列
sheet.addMergedRegion(callRangea);
//创建单元格并且添加数据
row = sheet.createRow(20);
row.setHeightInPoints(Short.parseShort("32"));//设置行高
cell = row.createCell(0);
cell.setCellValue("编号");
cell.setCellStyle(style);
cell = row.createCell(1);
cell.setCellValue(cyclesheetid);
cell.setCellStyle(style);
cell = row.createCell(0);
cell.setCellValue("循环单");
cell.setCellStyle(style);
cell = row.createCell(2);
cell.setCellValue("");
cell.setCellStyle(style);
cell = row.createCell(3);
cell.setCellValue("");
cell.setCellStyle(style);
cell = row.createCell(4);
cell.setCellValue("");
cell.setCellStyle(style);
CellRangeAddress callRangea1 = new CellRangeAddress(20, 20, 1, 4);//起始行,结束行,起始列,结束列
sheet.addMergedRegion(callRangea1);
row = sheet.createRow(21);
row.setHeightInPoints(Short.parseShort("16"));//设置行高
//创建单元格并且添加数据
cell = row.createCell(0);
cell.setCellValue("出库日期");
cell.setCellStyle(style);
cell = row.createCell(1);
cell.setCellValue("20 年 月 日");
cell.setCellStyle(style);
cell = row.createCell(2);
cell.setCellValue("");
cell.setCellStyle(style);
cell = row.createCell(3);
cell.setCellValue("");
cell.setCellStyle(style);
cell = row.createCell(4);
cell.setCellValue("");
cell.setCellStyle(style);
CellRangeAddress callRangeb = new CellRangeAddress(21, 21, 1, 4);//起始行,结束行,起始列,结束列
sheet.addMergedRegion(callRangeb);
}
}
//第六步将生成excel文件保存到指定路径下
FileOutputStream fout = null;
try {
fout = new FileOutputStream("F:\\Excel\\" + simpleDateFormat.format(new Date()) + countyInfoList.get(0).get("COUNTYNAME") + ".xls");
// fout = new FileOutputStream("D:\\" + simpleDateFormat.format(new Date()) + list.get(0).getString("COUNTYNAME") + ".xls");
wb.write(fout);
fout.close();
} catch (IOException e) {
e.printStackTrace();
}
System.out.println("Excel文件生成成功..." + new Date());
return "F:\\Excel\\" + simpleDateFormat.format(new Date()) +countyInfoList.get(0).get("COUNTYNAME") + ".xls";
// return "D:\\" + simpleDateFormat.format(new Date()) + list.get(0).getString("COUNTYNAME") + ".xls";
}
} }
package com.yxproject.start.config; package com.yxproject.start.config;
import com.yxproject.start.entity.ProductionTaskListEntity;
import com.yxproject.start.entity.SysPermission; import com.yxproject.start.entity.SysPermission;
import com.yxproject.start.entity.SysRole; import com.yxproject.start.entity.SysRole;
import com.yxproject.start.entity.UserInfo; import com.yxproject.start.entity.UserInfo;
......
...@@ -12,7 +12,7 @@ import java.util.List; ...@@ -12,7 +12,7 @@ import java.util.List;
public interface PoliceStationVailedMapper { public interface PoliceStationVailedMapper {
/** /**
* 保存派出所照片质量报表 * 保存派出所照片质量报表
* @param policeStationVailedInfoEntity * @param policeStationVailedEntity
* @return * @return
*/ */
@Insert("INSERT INTO POLICE_STATION_VAILED_INFO (POLICE_STATION_VAILED_INFO_ID,CYCLESHEETID,POLICE_STATION_CODE,VAILED_COUNT,INVALID_COUNT,SAVA_DATE) " + @Insert("INSERT INTO POLICE_STATION_VAILED_INFO (POLICE_STATION_VAILED_INFO_ID,CYCLESHEETID,POLICE_STATION_CODE,VAILED_COUNT,INVALID_COUNT,SAVA_DATE) " +
......
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