e508fac5b022cc41ee3cc4a0fb71eca515c16724.svn-base 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566
  1. package cn.com.goldenwater.dcproj.service.impl.ducha;
  2. import cn.com.goldenwater.core.service.AbstractCrudService;
  3. import cn.com.goldenwater.dcproj.dao.BisInspPlanYearPrgDao;
  4. import cn.com.goldenwater.dcproj.model.BisInspPlanYearPrg;
  5. import cn.com.goldenwater.dcproj.param.BisInspPlanYearPrgParam;
  6. import cn.com.goldenwater.dcproj.service.BisInspPlanYearPrgService;
  7. import cn.com.goldenwater.dcproj.service.OlBisInspOrgService;
  8. import cn.com.goldenwater.dcproj.utils.AdLevelUtil;
  9. import cn.com.goldenwater.dcproj.utils.StringUtils;
  10. import cn.com.goldenwater.id.util.UuidUtil;
  11. import org.apache.poi.hssf.usermodel.HSSFDataFormat;
  12. import org.apache.poi.ss.usermodel.*;
  13. import org.apache.poi.ss.util.CellRangeAddress;
  14. import org.apache.poi.ss.util.CellReference;
  15. import org.springframework.beans.factory.annotation.Autowired;
  16. import org.springframework.beans.factory.annotation.Value;
  17. import org.springframework.stereotype.Service;
  18. import org.springframework.transaction.annotation.Transactional;
  19. import javax.servlet.http.HttpServletResponse;
  20. import java.io.File;
  21. import java.io.FileInputStream;
  22. import java.io.IOException;
  23. import java.io.InputStream;
  24. import java.io.OutputStream;
  25. import java.net.URLEncoder;
  26. import java.text.ParseException;
  27. import java.text.SimpleDateFormat;
  28. import java.time.Instant;
  29. import java.time.LocalDateTime;
  30. import java.time.ZoneId;
  31. import java.time.format.DateTimeFormatter;
  32. import java.util.Date;
  33. import java.util.List;
  34. /**
  35. * @author lhc
  36. * @date 2022-3-3
  37. */
  38. @Service
  39. @Transactional
  40. public class BisInspPlanYearPrgServiceImpl extends AbstractCrudService<BisInspPlanYearPrg, BisInspPlanYearPrgParam> implements BisInspPlanYearPrgService {
  41. @Autowired
  42. private BisInspPlanYearPrgDao bisInspPlanYearPrgDao;
  43. @Value("${export.templatePath}")
  44. private String templatePath;
  45. @Autowired
  46. private OlBisInspOrgService olBisInspOrgService;
  47. private final SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
  48. private static final SimpleDateFormat monthFormat = new SimpleDateFormat("yyyy-mm") ;
  49. public BisInspPlanYearPrgServiceImpl(BisInspPlanYearPrgDao bisInspPlanYearPrgDao) {
  50. super(bisInspPlanYearPrgDao);
  51. this.bisInspPlanYearPrgDao = bisInspPlanYearPrgDao;
  52. }
  53. @Override
  54. public int insert(BisInspPlanYearPrg bisInspPlanYearPrg) {
  55. String uuid = UuidUtil.uuid(); // 生成uuid
  56. bisInspPlanYearPrg.setId(uuid);
  57. bisInspPlanYearPrg.setIntm(new Date());
  58. bisInspPlanYearPrg.setUptm(new Date());
  59. bisInspPlanYearPrg.setDataStat("0");
  60. return this.bisInspPlanYearPrgDao.insert(bisInspPlanYearPrg);
  61. }
  62. @Override
  63. public int update(BisInspPlanYearPrg bisInspPlanYearPrg) {
  64. bisInspPlanYearPrg.setUptm(new Date());
  65. return this.bisInspPlanYearPrgDao.update(bisInspPlanYearPrg);
  66. }
  67. @Override
  68. public int delete(String id) {
  69. return this.bisInspPlanYearPrgDao.delete(id);
  70. }
  71. @Override
  72. public List<BisInspPlanYearPrg> getPlanByYearId(String yearId) {
  73. return this.bisInspPlanYearPrgDao.getPlanByYearId(yearId);
  74. }
  75. @Override
  76. public List<BisInspPlanYearPrg> findPageList(BisInspPlanYearPrgParam bisInspPlanYearPrgParam) {
  77. List<BisInspPlanYearPrg> list = bisInspPlanYearPrgDao.findList(bisInspPlanYearPrgParam);
  78. return list;
  79. }
  80. // @Override
  81. // public void export(HttpServletResponse response, BisInspPlanYearPrgParam bisInspPlanYearPrgParam,String type) {
  82. // String templateFilePath = templatePath+ File.separator +"planCheckSdMonth.xls";
  83. // String addvcd = AdLevelUtil.getAddvcd(olBisInspOrgService.getProvince(bisInspPlanYearPrgParam.getOrgId()));
  84. // if(StringUtils.equals(addvcd, "37")){
  85. // // 若是 山东省
  86. // templateFilePath = templatePath+ File.separator +"planCheckSdMonth37.xls";
  87. // }
  88. // File file = new File(templateFilePath);
  89. // if(file.exists()){
  90. // try{
  91. // InputStream inputStream = new FileInputStream(file);
  92. // Workbook workbook = WorkbookFactory.create(inputStream);
  93. // exportFile(workbook,bisInspPlanYearPrgParam,type,addvcd);
  94. // writeToResponse(response,workbook,"监督进度月报.xls");
  95. // }catch(Exception e){
  96. // e.printStackTrace();
  97. // }
  98. // }
  99. // }
  100. @Override
  101. public void export(HttpServletResponse response, BisInspPlanYearPrgParam bisInspPlanYearPrgParam,String type) {
  102. String templateFilePath = templatePath+ File.separator +"planCheckSdMonth.xls";
  103. String addvcd = AdLevelUtil.getAddvcd(olBisInspOrgService.getProvince(bisInspPlanYearPrgParam.getOrgId()));
  104. if(StringUtils.equals(addvcd, "37")){
  105. // 若是 山东省
  106. templateFilePath = templatePath+ File.separator +"监督检查开展情况表.xls";
  107. }
  108. File file = new File(templateFilePath);
  109. if(file.exists()){
  110. try{
  111. InputStream inputStream = new FileInputStream(file);
  112. Workbook workbook = WorkbookFactory.create(inputStream);
  113. exportFile(workbook,bisInspPlanYearPrgParam,type,addvcd);
  114. writeToResponse(response,workbook,"监督检查开展情况表.xls");
  115. }catch(Exception e){
  116. e.printStackTrace();
  117. }
  118. }
  119. }
  120. @Override
  121. public void export1(HttpServletResponse response, BisInspPlanYearPrgParam bisInspPlanYearPrgParam,String type) {
  122. String templateFilePath = templatePath+ File.separator +"planCheckSdMonth.xls";
  123. String addvcd = AdLevelUtil.getAddvcd(olBisInspOrgService.getProvince(bisInspPlanYearPrgParam.getOrgId()));
  124. if(StringUtils.equals(addvcd, "37")){
  125. // 若是 山东省
  126. templateFilePath = templatePath+ File.separator +"业务性监督检查计划表.xls";
  127. }
  128. File file = new File(templateFilePath);
  129. if(file.exists()){
  130. try{
  131. InputStream inputStream = new FileInputStream(file);
  132. Workbook workbook = WorkbookFactory.create(inputStream);
  133. exportFile1(workbook,bisInspPlanYearPrgParam,type,addvcd);
  134. writeToResponse(response,workbook,"业务性监督检查计划.xls");
  135. }catch(Exception e){
  136. e.printStackTrace();
  137. }
  138. }
  139. }
  140. @Override
  141. public List<BisInspPlanYearPrg> findListByMonth(BisInspPlanYearPrgParam bisInspPlanYearPrgParam) {
  142. return bisInspPlanYearPrgDao.findListByMonth(bisInspPlanYearPrgParam);
  143. }
  144. // private void exportFile(Workbook xssfWorkbook, BisInspPlanYearPrgParam bisInspPlanYearPrgParam,String type, String addvcd) throws ParseException {
  145. // String title = "监督进度月报";
  146. // List<BisInspPlanYearPrg> list = null;
  147. // if(null != bisInspPlanYearPrgParam.getChkMnth()){
  148. // Date mnth = bisInspPlanYearPrgParam.getChkMnth();
  149. // Instant instant = mnth.toInstant();
  150. // ZoneId zoneId = ZoneId.systemDefault();
  151. // LocalDateTime mnLocalDateTime = instant.atZone(zoneId).toLocalDateTime();
  152. // DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM");
  153. // bisInspPlanYearPrgParam.setChkMnth(monthFormat.parse(dtf.format(mnLocalDateTime)));
  154. // }
  155. // if(StringUtils.isNotBlank(type)){
  156. // title = "月进度汇总";
  157. // list = bisInspPlanYearPrgDao.findListByMonth(bisInspPlanYearPrgParam);
  158. // }else{
  159. // title = "监督检查实施情况月报";
  160. // list = bisInspPlanYearPrgDao.findList(bisInspPlanYearPrgParam);
  161. // }
  162. // int num[] = {0,0,0,0,0,0};
  163. // Sheet sheet = xssfWorkbook.getSheetAt(0);
  164. // if(StringUtils.isBlank(type) && StringUtils.isNotBlank(bisInspPlanYearPrgParam.getSttm()) && StringUtils.isNotBlank(bisInspPlanYearPrgParam.getEntm())){
  165. // title = title+"("+simpleDateFormat.format(simpleDateFormat.parse(bisInspPlanYearPrgParam.getSttm()))+"~"+simpleDateFormat.format(simpleDateFormat.parse(bisInspPlanYearPrgParam.getEntm()))+")";
  166. // }
  167. // if(StringUtils.isBlank(type) && StringUtils.isNotNull(bisInspPlanYearPrgParam.getChkMnth()) ){
  168. // // 设置sheet名称
  169. // xssfWorkbook.setSheetName(0, monthFormat.format(bisInspPlanYearPrgParam.getChkMnth()) );
  170. // title = title+"("+monthFormat.format(bisInspPlanYearPrgParam.getChkMnth())+")";
  171. // }
  172. // CellStyle styleColor = sheet.getRow(1).getCell(0).getCellStyle();
  173. // CellStyle styleContent = xssfWorkbook.createCellStyle();
  174. // styleColor.setAlignment(HorizontalAlignment.CENTER);
  175. // styleColor.setVerticalAlignment(VerticalAlignment.CENTER);
  176. // styleContent.setAlignment(HorizontalAlignment.CENTER);
  177. // styleContent.setVerticalAlignment(VerticalAlignment.CENTER);
  178. // if(!StringUtils.equals(addvcd, "37")){
  179. // setCellValue(sheet, 0, 1, title);
  180. // }
  181. // if(list!=null && list.size()>0){
  182. // CellStyle contentStyle = sheet.getRow(3).getCell(0).getCellStyle();
  183. // contentStyle.setAlignment(HorizontalAlignment.CENTER);
  184. // contentStyle.setVerticalAlignment(VerticalAlignment.CENTER);
  185. // int size = list.size();
  186. // if(StringUtils.equals(addvcd, "37")){
  187. // size = size+1;
  188. // }
  189. // for(int i = 0;i<size;i++){
  190. // int cols = 14;
  191. // if(StringUtils.equals(addvcd, "37")){
  192. // Row row = sheet.createRow(3+i);
  193. // //山东省
  194. // cols = 13;
  195. // for(int j = 0;j<=cols;j++){
  196. // Cell cell = row.createCell(j);
  197. // if(1==j){
  198. // contentStyle.setDataFormat(HSSFDataFormat.getBuiltinFormat("0"));
  199. // }
  200. // cell.setCellStyle(contentStyle);
  201. // }
  202. // }else{
  203. // Row row = sheet.createRow(2+i);
  204. // for(int j = 0;j<=cols;j++){
  205. // Cell cell = row.createCell(j);
  206. // cell.setCellStyle(styleContent);
  207. // }
  208. // }
  209. // }
  210. // for (int i = 0; i < list.size(); i++) {
  211. // BisInspPlanYearPrg bisInspPlanYearPrg = list.get(i);
  212. // if (StringUtils.equals(addvcd, "37")) {
  213. // setAllCell37(sheet, i, bisInspPlanYearPrg);
  214. // } else {
  215. // setAllCell(sheet, i, bisInspPlanYearPrg, num);
  216. // }
  217. // }
  218. //// CellStyle style = sheet.getRow(1).getCell(0).getCellStyle();
  219. //// style.setAlignment(HorizontalAlignment.CENTER);
  220. //// style.setVerticalAlignment(VerticalAlignment.CENTER);
  221. //
  222. // if(StringUtils.equals(addvcd, "37") && list.size()>0){
  223. // // 山东省 增加汇总行
  224. // int lastRowIndex = list.size()+3;
  225. // CellRangeAddress region = new CellRangeAddress(lastRowIndex, lastRowIndex, 0, 1);
  226. // sheet.addMergedRegion(region);
  227. // Cell mergeCell = sheet.getRow(lastRowIndex).getCell(0) ;
  228. // mergeCell.setCellValue("合计");
  229. // CellStyle mergeCellCellStyle = mergeCell.getCellStyle();
  230. // mergeCellCellStyle.setAlignment(HorizontalAlignment.CENTER);
  231. // mergeCellCellStyle.setAlignment(HorizontalAlignment.CENTER);
  232. // mergeCell.setCellStyle(mergeCellCellStyle);
  233. // // 从 第3列 到14列
  234. // for(int i=2 ;i<=13 ;i++){
  235. // // 从第4行到最后一行 求和
  236. // String colString = CellReference.convertNumToColString(i);
  237. // if( 4==i || 5 ==i){
  238. // // 求和公式
  239. // String sumstring = "SUM(" ;
  240. // for(int k= 4;k<=lastRowIndex;k++){
  241. // sumstring += "IF(COUNTBLANK("+colString +k+"),0,1)," ;
  242. // }
  243. // sumstring = sumstring.substring(0,sumstring.length()-1);
  244. // sumstring += ")";
  245. // // 设置求和
  246. // sheet.getRow(lastRowIndex).getCell(i).setCellFormula(sumstring);
  247. // continue;
  248. // }
  249. // // 求和公式
  250. // String sumstring = "SUM(" + colString + "4:" + colString + lastRowIndex + ")";
  251. // // 设置求和
  252. // sheet.getRow(lastRowIndex).getCell(i).setCellFormula(sumstring);
  253. // }
  254. // }
  255. // int lastRowIndex = list.size()+2;
  256. // setCellValue(sheet, lastRowIndex, 5, String.valueOf(num[0]));
  257. // setCellValue(sheet, lastRowIndex, 6, String.valueOf(num[1]));
  258. // setCellValue(sheet, lastRowIndex, 7, String.valueOf(num[2]));
  259. // setCellValue(sheet, lastRowIndex, 9, String.valueOf(num[3]));
  260. // setCellValue(sheet, lastRowIndex, 10, String.valueOf(num[4]));
  261. // setCellValue(sheet, lastRowIndex, 11, String.valueOf(num[5]));
  262. // Row row = sheet.getRow(lastRowIndex);
  263. // CellRangeAddress region = new CellRangeAddress(lastRowIndex, lastRowIndex, 0, 4);
  264. // sheet.addMergedRegion(region);
  265. // row.getCell(0).setCellValue("总计");
  266. // row.getCell(0).setCellStyle(style);
  267. // }
  268. //
  269. // }
  270. private void exportFile(Workbook xssfWorkbook, BisInspPlanYearPrgParam bisInspPlanYearPrgParam,String type, String addvcd) throws ParseException {
  271. String title = "月份业务性监督检查计划表";
  272. if(null != bisInspPlanYearPrgParam.getChkMnth()){
  273. Date mnth = bisInspPlanYearPrgParam.getChkMnth();
  274. Instant instant = mnth.toInstant();
  275. ZoneId zoneId = ZoneId.systemDefault();
  276. LocalDateTime mnLocalDateTime = instant.atZone(zoneId).toLocalDateTime();
  277. DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM");
  278. bisInspPlanYearPrgParam.setChkMnth(monthFormat.parse(dtf.format(mnLocalDateTime)));
  279. }
  280. if(StringUtils.isBlank(type) && StringUtils.isNotBlank(bisInspPlanYearPrgParam.getSttm()) && StringUtils.isNotBlank(bisInspPlanYearPrgParam.getEntm())){
  281. title = "("+monthFormat.format(bisInspPlanYearPrgParam.getSttm())+"~"+monthFormat.format(bisInspPlanYearPrgParam.getEntm())+")"+title;
  282. }
  283. if(StringUtils.isBlank(type) && StringUtils.isNotNull(bisInspPlanYearPrgParam.getChkMnth()) ){
  284. // 设置sheet名称
  285. xssfWorkbook.setSheetName(0, monthFormat.format(bisInspPlanYearPrgParam.getChkMnth()) );
  286. title = "("+monthFormat.format(bisInspPlanYearPrgParam.getChkMnth())+")"+title;
  287. }
  288. List<BisInspPlanYearPrg> list = bisInspPlanYearPrgDao.findListByMonth(bisInspPlanYearPrgParam);
  289. int num[] = {0,0,0,0,0,0};
  290. Sheet sheet = xssfWorkbook.getSheetAt(0);
  291. CellStyle styleColor = sheet.getRow(1).getCell(0).getCellStyle();
  292. CellStyle styleContent = xssfWorkbook.createCellStyle();
  293. styleColor.setAlignment(HorizontalAlignment.CENTER);
  294. styleColor.setVerticalAlignment(VerticalAlignment.CENTER);
  295. styleContent.setAlignment(HorizontalAlignment.CENTER);
  296. styleContent.setVerticalAlignment(VerticalAlignment.CENTER);
  297. if(!StringUtils.equals(addvcd, "37")){
  298. setCellValue(sheet, 0, 1, title);
  299. }
  300. if(list!=null && list.size()>0){
  301. CellStyle contentStyle = sheet.getRow(2).getCell(0).getCellStyle();
  302. contentStyle.setAlignment(HorizontalAlignment.CENTER);
  303. contentStyle.setVerticalAlignment(VerticalAlignment.CENTER);
  304. int size = list.size();
  305. for(int i = 0;i<size+1;i++){
  306. //单元格列
  307. int cols = 10;
  308. Row row = sheet.createRow(2+i);
  309. //山东省
  310. for(int j = 0;j<cols;j++){
  311. Cell cell = row.createCell(j);
  312. cell.setCellStyle(contentStyle);
  313. }
  314. }
  315. for (int i = 0; i < list.size(); i++) {
  316. BisInspPlanYearPrg bisInspPlanYearPrg = list.get(i);
  317. setAllCell(sheet, i, bisInspPlanYearPrg, num);
  318. }
  319. CellStyle styleContent1 = xssfWorkbook.createCellStyle();
  320. styleContent1.setAlignment(HorizontalAlignment.LEFT);
  321. styleContent1.setVerticalAlignment(VerticalAlignment.CENTER);
  322. styleContent1.setBorderTop(BorderStyle.THIN); // 上边框
  323. styleContent1.setBorderBottom(BorderStyle.THIN); // 下边框
  324. styleContent1.setBorderLeft(BorderStyle.THIN); // 左边框
  325. styleContent1.setBorderRight(BorderStyle.THIN); // 右边框
  326. sheet.addMergedRegion(new CellRangeAddress(list.size()+2, list.size()+2, 0, 9));
  327. sheet.getRow(list.size()+2).getCell(0).setCellStyle(styleContent1);
  328. String note = "注:1.检查事项为厅业务性监督检查计划名称,具体内容见附件1-2024年度业务性监督检查计划表。\n" +
  329. " 2.检查形式分为暗访、明查、明查暗访相结合。";
  330. setCellValue(sheet, list.size()+2, 0, note);
  331. }
  332. }
  333. private void exportFile1(Workbook xssfWorkbook, BisInspPlanYearPrgParam bisInspPlanYearPrgParam,String type, String addvcd) throws ParseException {
  334. String title = "月份业务性监督检查计划表";
  335. if(null != bisInspPlanYearPrgParam.getChkMnth()){
  336. Date mnth = bisInspPlanYearPrgParam.getChkMnth();
  337. Instant instant = mnth.toInstant();
  338. ZoneId zoneId = ZoneId.systemDefault();
  339. LocalDateTime mnLocalDateTime = instant.atZone(zoneId).toLocalDateTime();
  340. DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM");
  341. bisInspPlanYearPrgParam.setChkMnth(monthFormat.parse(dtf.format(mnLocalDateTime)));
  342. }
  343. if(StringUtils.isBlank(type) && StringUtils.isNotBlank(bisInspPlanYearPrgParam.getSttm()) && StringUtils.isNotBlank(bisInspPlanYearPrgParam.getEntm())){
  344. title = "("+monthFormat.format(bisInspPlanYearPrgParam.getSttm())+"~"+monthFormat.format(bisInspPlanYearPrgParam.getEntm())+")"+title;
  345. }
  346. if(StringUtils.isBlank(type) && StringUtils.isNotNull(bisInspPlanYearPrgParam.getChkMnth()) ){
  347. // 设置sheet名称
  348. xssfWorkbook.setSheetName(0, monthFormat.format(bisInspPlanYearPrgParam.getChkMnth()) );
  349. title = "("+monthFormat.format(bisInspPlanYearPrgParam.getChkMnth())+")"+title;
  350. }
  351. List<BisInspPlanYearPrg> list = bisInspPlanYearPrgDao.findListByMonth(bisInspPlanYearPrgParam);
  352. int num[] = {0,0,0,0,0,0};
  353. Sheet sheet = xssfWorkbook.getSheetAt(0);
  354. CellStyle styleColor = sheet.getRow(1).getCell(0).getCellStyle();
  355. CellStyle styleContent = xssfWorkbook.createCellStyle();
  356. styleColor.setAlignment(HorizontalAlignment.CENTER);
  357. styleColor.setVerticalAlignment(VerticalAlignment.CENTER);
  358. styleContent.setAlignment(HorizontalAlignment.CENTER);
  359. styleContent.setVerticalAlignment(VerticalAlignment.CENTER);
  360. if(!StringUtils.equals(addvcd, "37")){
  361. setCellValue(sheet, 0, 1, title);
  362. }
  363. if(list!=null && list.size()>0){
  364. CellStyle contentStyle = sheet.getRow(2).getCell(0).getCellStyle();
  365. contentStyle.setAlignment(HorizontalAlignment.CENTER);
  366. contentStyle.setVerticalAlignment(VerticalAlignment.CENTER);
  367. int size = list.size();
  368. for(int i = 0;i<size+1;i++){
  369. //单元格列
  370. int cols = 6;
  371. Row row = sheet.createRow(2+i);
  372. //山东省
  373. for(int j = 0;j<cols;j++){
  374. Cell cell = row.createCell(j);
  375. cell.setCellStyle(contentStyle);
  376. }
  377. }
  378. for (int i = 0; i < list.size(); i++) {
  379. BisInspPlanYearPrg bisInspPlanYearPrg = list.get(i);
  380. setAllCell1(sheet, i, bisInspPlanYearPrg);
  381. }
  382. CellStyle styleContent1 = xssfWorkbook.createCellStyle();
  383. /*styleColor.setAlignment(HorizontalAlignment.CENTER);
  384. styleColor.setVerticalAlignment(VerticalAlignment.CENTER);*/
  385. styleContent1.setAlignment(HorizontalAlignment.LEFT);
  386. styleContent1.setVerticalAlignment(VerticalAlignment.CENTER);
  387. styleContent1.setBorderTop(BorderStyle.THIN); // 上边框
  388. styleContent1.setBorderBottom(BorderStyle.THIN); // 下边框
  389. styleContent1.setBorderLeft(BorderStyle.THIN); // 左边框
  390. styleContent1.setBorderRight(BorderStyle.THIN); // 右边框
  391. sheet.addMergedRegion(new CellRangeAddress(list.size()+2, list.size()+2, 0, 5));
  392. sheet.getRow(list.size()+2).getCell(0).setCellStyle(styleContent1);
  393. //String note = ;
  394. setCellValue(sheet, list.size()+2, 0, "注:1.检查事项为厅业务性监督检查计划名称,具体内容见附件1-2024年度业务性监督检查计划表。\n2.检查形式分为暗访、明查、明查暗访相结合。");
  395. }
  396. }
  397. private void setAllCell37(Sheet sheet, int i, BisInspPlanYearPrg bisInspPlanYearPrg) {
  398. setCellValue(sheet, 3 + i, 0, String.valueOf(i + 1));
  399. if(null == bisInspPlanYearPrg.getChkMnth()){
  400. if(null != bisInspPlanYearPrg.getSttm() && null != bisInspPlanYearPrg.getEntm()){
  401. setCellValue(sheet, 3 + i, 1, simpleDateFormat.format(bisInspPlanYearPrg.getSttm())+"~"+simpleDateFormat.format(bisInspPlanYearPrg.getEntm()));
  402. }
  403. }else{
  404. Date mnth = bisInspPlanYearPrg.getChkMnth();
  405. Instant instant = mnth.toInstant();
  406. ZoneId zoneId = ZoneId.systemDefault();
  407. LocalDateTime mnLocalDateTime = instant.atZone(zoneId).toLocalDateTime();
  408. setCellValue(sheet, 3 + i, 1, String.valueOf(mnLocalDateTime.getMonthValue()));
  409. }
  410. setCellValue(sheet, 3 + i, 2, bisInspPlanYearPrg.getTrainNum());
  411. setCellValue(sheet, 3 + i, 3, bisInspPlanYearPrg.getTrainPers());
  412. if("1".equals(bisInspPlanYearPrg.getIsPlanned()) || StringUtils.isBlank(bisInspPlanYearPrg.getIsPlanned())){
  413. // 计划内
  414. setCellValue(sheet, 3 + i, 5, bisInspPlanYearPrg.getChkName());
  415. }else {
  416. // 计划外
  417. setCellValue(sheet, 3 + i, 4, bisInspPlanYearPrg.getUnplannedChkNm());
  418. }
  419. if("1".equals(bisInspPlanYearPrg.getChkForm())){
  420. // 检查形式 暗访
  421. setCellValue(sheet, 3 + i, 6, bisInspPlanYearPrg.getChkGroup());
  422. setCellValue(sheet, 3 + i, 7, bisInspPlanYearPrg.getChkPers());
  423. setCellValue(sheet, 3 + i, 8, bisInspPlanYearPrg.getChkLeder());
  424. setCellValue(sheet, 3 + i, 9, bisInspPlanYearPrg.getChkPblm());
  425. }else{
  426. // 除 暗访 外的 其他检查形式
  427. setCellValue(sheet, 3 + i, 10, bisInspPlanYearPrg.getChkGroup());
  428. setCellValue(sheet, 3 + i, 11, bisInspPlanYearPrg.getChkPers());
  429. setCellValue(sheet, 3 + i, 12, bisInspPlanYearPrg.getChkLeder());
  430. setCellValue(sheet, 3 + i, 13, bisInspPlanYearPrg.getChkPblm());
  431. }
  432. }
  433. // private void setAllCell(Sheet sheet, int i, BisInspPlanYearPrg bisInspPlanYearPrg,int[] num) {
  434. // setCellValue(sheet, 2 + i, 0, String.valueOf(i + 1));
  435. // setCellValue(sheet, 2 + i, 1, bisInspPlanYearPrg.getObjTypeNm());
  436. // setCellValue(sheet, 2 + i, 2, bisInspPlanYearPrg.getLeadDep());
  437. // setCellValue(sheet, 2 + i, 3, StringUtils.isEmpty(bisInspPlanYearPrg.getChkName())?bisInspPlanYearPrg.getUnplannedChkNm():bisInspPlanYearPrg.getChkName());
  438. // setCellValue(sheet, 2 + i, 4, simpleDateFormat.format(bisInspPlanYearPrg.getSttm()) + "~" + simpleDateFormat.format(bisInspPlanYearPrg.getEntm()));
  439. // setCellValue(sheet, 2 + i, 5, bisInspPlanYearPrg.getChkGroup().toString());
  440. // setCellValue(sheet, 2 + i, 6, bisInspPlanYearPrg.getChkPers().toString());
  441. // setCellValue(sheet, 2 + i, 7, bisInspPlanYearPrg.getChkLeder().toString());
  442. // setCellValue(sheet, 2 + i, 8, bisInspPlanYearPrg.getChkNote());
  443. // setCellValue(sheet, 2 + i, 9, bisInspPlanYearPrg.getChkPblm().toString());
  444. // setCellValue(sheet, 2 + i, 10, bisInspPlanYearPrg.getTrainNum().toString());
  445. // setCellValue(sheet, 2 + i, 11, bisInspPlanYearPrg.getTrainPers().toString());
  446. // setCellValue(sheet, 2 + i, 12, bisInspPlanYearPrg.getIsFinish().equals("1") ? "是" : "否");
  447. // setCellValue(sheet, 2 + i, 13, bisInspPlanYearPrg.getIsFinish().equals("0") ? bisInspPlanYearPrg.getNextPlan() : "");
  448. // setCellValue(sheet, 2 + i, 14, bisInspPlanYearPrg.getNote());
  449. //// num[0]+=bisInspPlanYearPrg.getChkGroup();
  450. //// num[1]+=bisInspPlanYearPrg.getChkPers();
  451. //// num[2]+=bisInspPlanYearPrg.getChkLeder();
  452. //// num[3]+=bisInspPlanYearPrg.getChkPblm();
  453. //// num[4]+=bisInspPlanYearPrg.getTrainNum();
  454. //// num[5]+=bisInspPlanYearPrg.getTrainPers();
  455. // }
  456. private void setAllCell(Sheet sheet, int i, BisInspPlanYearPrg bisInspPlanYearPrg,int[] num) {
  457. setCellValue(sheet, 2 + i, 0, String.valueOf(i + 1));
  458. setCellValue(sheet, 2 + i, 1, bisInspPlanYearPrg.getLeadDep());
  459. setCellValue(sheet, 2 + i, 2, StringUtils.isEmpty(bisInspPlanYearPrg.getChkName())?bisInspPlanYearPrg.getUnplannedChkNm():bisInspPlanYearPrg.getChkName());
  460. setCellValue(sheet, 2 + i, 3, bisInspPlanYearPrg.getChkNote());
  461. setCellValue(sheet, 2 + i, 4, bisInspPlanYearPrg.getChkFormNm());
  462. setCellValue(sheet, 2 + i, 5, bisInspPlanYearPrg.getChkGroup());
  463. setCellValue(sheet, 2 + i, 6, bisInspPlanYearPrg.getChkPers());
  464. setCellValue(sheet, 2 + i, 7, bisInspPlanYearPrg.getChkPblm());
  465. setCellValue(sheet, 2 + i, 8, bisInspPlanYearPrg.getIsFinish().equals("1") ? "完成" : "否");
  466. // setCellValue(sheet, 2 + i, 9, bisInspPlanYearPrg.getIsFinish().equals("0") ? bisInspPlanYearPrg.getNextPlan() : "");
  467. setCellValue(sheet, 2 + i, 9, bisInspPlanYearPrg.getNote());
  468. // num[0]+=bisInspPlanYearPrg.getChkGroup();
  469. // num[1]+=bisInspPlanYearPrg.getChkPers();
  470. // num[2]+=bisInspPlanYearPrg.getChkLeder();
  471. // num[3]+=bisInspPlanYearPrg.getChkPblm();
  472. // num[4]+=bisInspPlanYearPrg.getTrainNum();
  473. // num[5]+=bisInspPlanYearPrg.getTrainPers();
  474. }
  475. private void setAllCell1(Sheet sheet, int i, BisInspPlanYearPrg bisInspPlanYearPrg) {
  476. setCellValue(sheet, 2 + i, 0, String.valueOf(i + 1));
  477. setCellValue(sheet, 2 + i, 1, bisInspPlanYearPrg.getLeadDep());
  478. //setCellValue(sheet, 2 + i, 2, bisInspPlanYearPrg.getUnplannedChkNm());
  479. setCellValue(sheet, 2 + i, 2, StringUtils.isEmpty(bisInspPlanYearPrg.getChkName())?bisInspPlanYearPrg.getUnplannedChkNm():bisInspPlanYearPrg.getChkName());
  480. setCellValue(sheet, 2 + i, 3, bisInspPlanYearPrg.getChkFormNm());
  481. String key = "";
  482. if(bisInspPlanYearPrg.getNextSttm() != null){
  483. key = simpleDateFormat.format(bisInspPlanYearPrg.getNextSttm());
  484. }
  485. if(bisInspPlanYearPrg.getNextEntm() != null){
  486. key = key + "~" +simpleDateFormat.format(bisInspPlanYearPrg.getNextEntm());
  487. }
  488. setCellValue(sheet, 2 + i, 4, key);
  489. setCellValue(sheet, 2 + i, 5, bisInspPlanYearPrg.getAddvnm());
  490. }
  491. private String getChkFormLabel(String v){
  492. switch (v){
  493. case "1":
  494. return "暗访";
  495. case "2":
  496. return "明查";
  497. case "3":
  498. return "书面";
  499. case "4":
  500. return "四不两直";
  501. case "5":
  502. return "明查暗访相结合";
  503. default:
  504. return "";
  505. }
  506. }
  507. private void setCellValue(Sheet sheet, int rownum, int cellnum, Object value) {
  508. if(null != value){
  509. Cell cell = sheet.getRow(rownum).getCell(cellnum);
  510. if(value instanceof String){
  511. cell.setCellValue(value.toString());
  512. }else if(value instanceof Long){
  513. cell.setCellValue(Long.valueOf(value.toString()));
  514. }else if(value instanceof Integer){
  515. cell.setCellValue(Integer.valueOf(String.valueOf(value)));
  516. }else if(value instanceof Number){
  517. cell.setCellValue(Double.valueOf(String.valueOf(value)));
  518. }else if(value instanceof Date){
  519. cell.setCellValue((Date)value);
  520. }else if(value instanceof Boolean){
  521. cell.setCellValue((Boolean)value);
  522. }else {
  523. cell.setCellValue(String.valueOf(value));
  524. }
  525. }
  526. }
  527. private void writeToResponse(HttpServletResponse response, Workbook workbook, String name) throws IOException {
  528. // 修改模板内容导出新模板
  529. response.setContentType("application/x-msdownload");
  530. String fileNameURL = URLEncoder.encode(name, "UTF-8");
  531. response.setHeader("Content-disposition", "attachment;filename=" + fileNameURL + ";filename*=utf-8''" + fileNameURL);
  532. OutputStream out = response.getOutputStream();
  533. workbook.write(out);
  534. out.flush();
  535. out.close();
  536. }
  537. }