42ad361f0f96e33300149f401f2deff56cf0ced1.svn-base 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613
  1. package cn.com.goldenwater.dcproj.service.impl;
  2. import cn.com.goldenwater.core.service.AbstractCrudService;
  3. import cn.com.goldenwater.dcproj.common.WtprjConvert;
  4. import cn.com.goldenwater.dcproj.constValue.BisInspEnum;
  5. import cn.com.goldenwater.dcproj.constValue.SplitValue;
  6. import cn.com.goldenwater.dcproj.dao.BisInspWtprjRegisterDao;
  7. import cn.com.goldenwater.dcproj.dto.BisInspWtprjRegisterDto;
  8. import cn.com.goldenwater.dcproj.dto.ResponsibilityDto;
  9. import cn.com.goldenwater.dcproj.model.*;
  10. import cn.com.goldenwater.dcproj.param.BisInspWtprjRegisterParam;
  11. import cn.com.goldenwater.dcproj.param.TypeParam;
  12. import cn.com.goldenwater.dcproj.service.*;
  13. import cn.com.goldenwater.dcproj.utils.AdLevelUtil;
  14. import cn.com.goldenwater.dcproj.utils.Builder;
  15. import cn.com.goldenwater.dcproj.utils.DateUtils;
  16. import cn.com.goldenwater.dcproj.utils.InspPblmUtils;
  17. import cn.com.goldenwater.id.util.UuidUtil;
  18. import com.github.pagehelper.PageHelper;
  19. import com.github.pagehelper.PageInfo;
  20. import com.itextpdf.text.*;
  21. import com.itextpdf.text.pdf.BaseFont;
  22. import com.itextpdf.text.pdf.PdfPCell;
  23. import com.itextpdf.text.pdf.PdfPTable;
  24. import com.itextpdf.text.pdf.PdfWriter;
  25. import org.apache.commons.collections.MapUtils;
  26. import org.apache.commons.lang.StringUtils;
  27. import org.springframework.beans.BeanUtils;
  28. import org.springframework.beans.factory.annotation.Autowired;
  29. import org.springframework.stereotype.Service;
  30. import org.springframework.transaction.annotation.Transactional;
  31. import javax.servlet.http.HttpServletResponse;
  32. import java.io.IOException;
  33. import java.io.OutputStream;
  34. import java.net.URLEncoder;
  35. import java.util.List;
  36. import java.util.*;
  37. import java.util.stream.Collectors;
  38. /**
  39. * @author lhc
  40. * @date 2021-4-14
  41. */
  42. @Service
  43. @Transactional
  44. public class BisInspWtprjRegisterServiceImpl extends AbstractCrudService<BisInspWtprjRegister, BisInspWtprjRegisterParam> implements BisInspWtprjRegisterService, BisInspObjStrategy {
  45. @Autowired
  46. private BisInspWtprjRegisterDao bisInspWtprjRegisterDao;
  47. @Autowired
  48. private AttWtprjBaseService attWtprjBaseService;
  49. @Autowired
  50. private BisInspWtprjSectionService bisInspWtprjSectionService;
  51. @Autowired
  52. private BisInspWtprjUnitService bisInspWtprjUnitService;
  53. public BisInspWtprjRegisterServiceImpl(BisInspWtprjRegisterDao bisInspWtprjRegisterDao) {
  54. super(bisInspWtprjRegisterDao);
  55. this.bisInspWtprjRegisterDao = bisInspWtprjRegisterDao;
  56. }
  57. @Override
  58. public int insert(BisInspWtprjRegister bisInspWtprjRegister) {
  59. bisInspWtprjRegister.setId(UuidUtil.uuid());
  60. bisInspWtprjRegister.setIntm(new Date());
  61. bisInspWtprjRegister.setUptm(new Date());
  62. bisInspWtprjRegister.setDataStat("0");
  63. return this.bisInspWtprjRegisterDao.insert(bisInspWtprjRegister);
  64. }
  65. @Override
  66. public int update(BisInspWtprjRegister bisInspWtprjRegister) {
  67. bisInspWtprjRegister.setUptm(new Date());
  68. int ret = this.bisInspWtprjRegisterDao.update(bisInspWtprjRegister);
  69. // 更新基础表信息
  70. updateAttBase(bisInspWtprjRegister);
  71. return ret;
  72. }
  73. private void updateAttBase(BisInspWtprjRegister rgstr) {
  74. BisInspWtprjRegister r = get(rgstr.getId());
  75. AttWtprjBase base = attWtprjBaseService.getObjId(r.getObjId());
  76. base.setNm(rgstr.getNm());
  77. base.setAdCode(rgstr.getAdCode());
  78. base.setAdName(rgstr.getAdName());
  79. base.setLoc(rgstr.getLoc());
  80. base.setPrjCtgy(rgstr.getPrjCtgy());
  81. base.setPrjType(rgstr.getPrjType());
  82. base.setPrjRisk(rgstr.getPrjRisk());
  83. base.setCenterX(rgstr.getCenterX());
  84. base.setCenterY(rgstr.getCenterY());
  85. base.setGdX(rgstr.getGdX());
  86. base.setGdY(rgstr.getGdY());
  87. base.setNote(rgstr.getNote());
  88. attWtprjBaseService.update(base);
  89. }
  90. @Override
  91. public int delete(String id) {
  92. return this.bisInspWtprjRegisterDao.delete(id);
  93. }
  94. // AttEmpwtprjBase
  95. @Override
  96. public void insertObj(BisInspAllObj bisInspAllObj, String persId) {
  97. BisInspWtprjRegister b = new BisInspWtprjRegister();
  98. AttWtprjBase base = attWtprjBaseService.get(bisInspAllObj.getCode());
  99. BeanUtils.copyProperties(base, b);
  100. b.setObjId(bisInspAllObj.getObjId());
  101. b.setId(UuidUtil.uuid());
  102. b.setIntm(new Date());
  103. b.setUptm(new Date());
  104. b.setDataStat("0");
  105. b.setState("0");
  106. /* 添加 登记表 */
  107. bisInspWtprjRegisterDao.insert(b);
  108. }
  109. @Override
  110. public String getType() {
  111. return BisInspEnum.WTPRJ.getValue();
  112. }
  113. @Override
  114. public void cleanObjData(String objId) {
  115. BisInspWtprjRegisterParam rgstrParam = new BisInspWtprjRegisterParam();
  116. rgstrParam.setObjId(objId);
  117. List<BisInspWtprjRegister> list = this.bisInspWtprjRegisterDao.findList(rgstrParam);
  118. if (list.size() > 0) {
  119. String id = list.get(0).getId();
  120. // 删除登记表
  121. this.bisInspWtprjRegisterDao.delete(id);
  122. }
  123. }
  124. @Override
  125. public Object findObjListByType(TypeParam typeParam) {
  126. return this.bisInspWtprjRegisterDao.findPageList(typeParam);
  127. }
  128. @Override
  129. public PageInfo findObjPageByType(TypeParam typeParam, HttpServletResponse response) {
  130. if (StringUtils.isNotBlank(typeParam.getAdCode())) {
  131. typeParam.setAdCode(String.valueOf(AdLevelUtil.SubAd(typeParam.getAdCode()).get(SplitValue.SUBAD)));
  132. }
  133. PageHelper.startPage(typeParam);
  134. List<BisInspWtprjRegisterDto> list = this.bisInspWtprjRegisterDao.findPageList(typeParam);
  135. return new PageInfo<>(list);
  136. }
  137. @Override
  138. public List<BisInspAllNode> wtprjTree(TypeParam typeParam) {
  139. List<BisInspWtprjRegisterDto> list = bisInspWtprjRegisterDao.findPageList(typeParam);
  140. List<BisInspAllNode> nodes = new ArrayList<>();
  141. for (BisInspWtprjRegisterDto reg : list) {
  142. BisInspAllNode node = Builder.of(BisInspAllNode::new)
  143. .with(BisInspAllNode::setId, reg.getId())
  144. .with(BisInspAllNode::setPid, "0")
  145. .with(BisInspAllNode::setPnm, reg.getNm())
  146. .with(BisInspAllNode::setObjId, reg.getObjId())
  147. .with(BisInspAllNode::setCode, reg.getCode())
  148. .with(BisInspAllNode::setState, reg.getState())
  149. .with(BisInspAllNode::setLevel, "1")
  150. .with(BisInspAllNode::setNodeId, reg.getNodeId())
  151. .with(BisInspAllNode::setChildren, new ArrayList<>())
  152. .build();
  153. nodes.add(node);
  154. // 添加登记表下的 标段
  155. addSection(node);
  156. }
  157. return nodes;
  158. }
  159. void addSection(BisInspAllNode node) {
  160. List<BisInspWtprjSection> sectionList = bisInspWtprjSectionService.listByRegId(node.getId());
  161. for (BisInspWtprjSection sec : sectionList) {
  162. BisInspAllNode secNode = new BisInspAllNode();
  163. secNode.setId(sec.getId());
  164. secNode.setObjId(sec.getObjId());
  165. secNode.setPnm(sec.getNm());
  166. secNode.setPid(node.getId());
  167. secNode.setLevel("2");
  168. secNode.setChildren(new ArrayList<>());
  169. // 添加标段下的公司
  170. addUnit(secNode);
  171. node.getChildren().add(secNode);
  172. }
  173. }
  174. /**
  175. * 添加标段下的公司
  176. *
  177. * @param section
  178. */
  179. void addUnit(BisInspAllNode section) {
  180. List<BisInspWtprjUnit> unitList = bisInspWtprjUnitService.listBySecId(section.getId());
  181. for (BisInspWtprjUnit unit : unitList) {
  182. BisInspAllNode unitNode = new BisInspAllNode();
  183. unitNode.setId(unit.getId());
  184. unitNode.setPnm(unit.getNm());
  185. unitNode.setObjId(unit.getObjId());
  186. unitNode.setPid(section.getId());
  187. unitNode.setLevel("3");
  188. unitNode.setState(unit.getMendType());
  189. section.getChildren().add(unitNode);
  190. }
  191. }
  192. @Override
  193. public void exportResponsibility(String id, HttpServletResponse response) {
  194. try {
  195. String fileName = "水利项目安全生产责任追究建议清单.pdf";
  196. // 修改模板内容导出新模板
  197. response.setContentType("application/x-msdownload");
  198. String fileNameURL = URLEncoder.encode(fileName, "UTF-8");
  199. response.setHeader("Content-disposition", "attachment;filename=" + fileNameURL + ";filename*=utf-8''" + fileNameURL);
  200. OutputStream out = response.getOutputStream();
  201. testRowSpan(id, out);
  202. out.flush();
  203. out.close();
  204. } catch (IOException | DocumentException e) {
  205. e.printStackTrace();
  206. }
  207. }
  208. private void testRowSpan(String id, OutputStream out) throws IOException, DocumentException {
  209. BaseFont bfCN = BaseFont.createFont("STSongStd-Light", "UniGB-UCS2-H", false);
  210. // 正文的字体
  211. Font headFont = new Font(bfCN, 14f, Font.BOLD);
  212. Font topFont = new Font(bfCN, 28f, Font.BOLD);
  213. Font textFont = new Font(bfCN, 14f, Font.NORMAL);
  214. Document document = new Document();
  215. PdfWriter.getInstance(document, out);
  216. document.open();
  217. // 获取数据
  218. List<ResponsibilityDto> responsibilityDtoList = getResponsibility(id);
  219. //建立一个4列的表格
  220. PdfPTable table = new PdfPTable(new float[]{5f, 10f, 10f, 40f, 5f, 5f, 25f});
  221. table.setTotalWidth(PageSize.A4.getWidth() - 20f);
  222. table.setLockedWidth(true);
  223. String nm = "";
  224. String duchaDate = "";
  225. if (responsibilityDtoList != null && responsibilityDtoList.size() > 0) {
  226. nm = responsibilityDtoList.get(0).getNm();
  227. duchaDate = DateUtils.Date2Str(responsibilityDtoList.get(0).getIntm(), "yyyy-MM-dd");
  228. }
  229. //第1列
  230. Paragraph paragraph = new Paragraph("水利项目安全生产责任追究建议清单", topFont);
  231. paragraph.setAlignment(1);
  232. PdfPCell cel0 = new PdfPCell();
  233. cel0.setBorder(0);
  234. cel0.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
  235. cel0.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
  236. cel0.setPaddingTop(-2f);//把字垂直居中
  237. cel0.setPaddingBottom(8f);//把字垂直居中
  238. cel0.addElement(paragraph);
  239. cel0.setColspan(7);
  240. table.addCell(cel0);
  241. //第1列
  242. Paragraph paragraph01 = new Paragraph("工程名称:" + nm, textFont);
  243. paragraph01.setAlignment(1);
  244. PdfPCell cell = new PdfPCell();
  245. cell.setBorder(0);
  246. cell.addElement(paragraph01);
  247. cell.setColspan(4);
  248. table.addCell(cell);
  249. //第1列
  250. Paragraph paragraph02 = new Paragraph("巡查时间:" + duchaDate, textFont);
  251. paragraph02.setAlignment(1);
  252. PdfPCell cell2 = new PdfPCell();
  253. cell2.setBorder(0);
  254. cell2.addElement(paragraph02);
  255. cell2.setColspan(3);
  256. table.addCell(cell2);
  257. //加表格头部
  258. String[] titleArr = {"序号", "标段", "责任单位", "存在的主要问题", "问题分类", "问题个数", "责任追究建议"};
  259. addTitle(table, titleArr, headFont);
  260. //加表格内容
  261. if (responsibilityDtoList != null && responsibilityDtoList.size() > 0) {
  262. addContent(table, responsibilityDtoList, textFont);
  263. }
  264. document.add(table);
  265. document.close();
  266. }
  267. private List<ResponsibilityDto> getResponsibility(String id) {
  268. List<ResponsibilityDto> responsibilityList = bisInspWtprjRegisterDao.getResponsibility(id);
  269. if (responsibilityList == null || responsibilityList.size() == 0) {
  270. return null;
  271. }
  272. int index = 1;
  273. String secNmIndex = responsibilityList.get(0).getSecNm();
  274. for (ResponsibilityDto responsibilityDto : responsibilityList) {
  275. if (!secNmIndex.equals(responsibilityDto.getSecNm())) {
  276. secNmIndex = responsibilityDto.getSecNm();
  277. index++;
  278. }
  279. responsibilityDto.setSeq(index);
  280. }
  281. return responsibilityList;
  282. }
  283. private void addContent(PdfPTable table, List<ResponsibilityDto> list, Font textFont) {
  284. List<Integer> seqList = list.stream().map(ResponsibilityDto::getSeq).distinct().sorted().collect(Collectors.toList());
  285. //表格数据内容
  286. for (Integer index : seqList) {
  287. // 各标段
  288. List<ResponsibilityDto> secList = list.stream().filter(res -> index.equals(res.getSeq())).collect(Collectors.toList());
  289. setSecCell(table, secList, textFont);
  290. }
  291. }
  292. private void setSecCell(PdfPTable table, List<ResponsibilityDto> secList, Font textFont) {
  293. //第1列
  294. Paragraph paragraph01 = new Paragraph(String.valueOf(secList.get(0).getSeq()), textFont);
  295. paragraph01.setAlignment(1);
  296. PdfPCell cell = new PdfPCell();
  297. cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
  298. cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
  299. // 把字垂直居中
  300. cell.setPaddingTop(-2f);
  301. // 把字垂直居中
  302. cell.setPaddingBottom(8f);
  303. cell.addElement(paragraph01);
  304. cell.setRowspan(secList.size());
  305. table.addCell(cell);
  306. //合并列
  307. Paragraph paragraph02 = new Paragraph(secList.get(0).getSecNm(), textFont);
  308. paragraph02.setAlignment(1);
  309. PdfPCell cell1 = new PdfPCell();
  310. cell1.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
  311. cell1.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);//然并卵
  312. cell1.setPaddingTop(-2f);//把字垂直居中
  313. cell1.setPaddingBottom(8f);//把字垂直居中
  314. cell1.addElement(paragraph02);
  315. cell1.setRowspan(secList.size());
  316. table.addCell(cell1);
  317. List<String> unitNmList = secList.stream().map(ResponsibilityDto::getUnitNm).distinct().collect(Collectors.toList());
  318. for (String unitNm : unitNmList) {
  319. List<ResponsibilityDto> unitList = secList.stream().filter(unit -> unitNm.equals(unit.getUnitNm())).collect(Collectors.toList());
  320. setUnitCell(table, unitList, textFont);
  321. }
  322. }
  323. private void setUnitCell(PdfPTable table, List<ResponsibilityDto> secList, Font textFont) {
  324. int index = 0;
  325. //计算'合并列'的合并相关集合
  326. List<Integer> indexs;
  327. //每个'合并列'的初始下标集合
  328. List<Integer> spanStartIndex;
  329. //每个'合并列'的合并数量集合
  330. List<Integer> spanNumList;
  331. //取出'合并列'的所有数据计算
  332. List<String> ListIn = new ArrayList<>();
  333. long yibanCount = secList.stream().filter(res -> "0".equals(res.getInspPblmCate())).count();
  334. long jiaozhongCount = secList.stream().filter(res -> "1".equals(res.getInspPblmCate())).count();
  335. long yanzhongCount = secList.stream().filter(res -> "2".equals(res.getInspPblmCate())).count();
  336. for (ResponsibilityDto res : secList) {
  337. if ("0".equals(res.getInspPblmCate())) {
  338. res.setPblmCount(String.valueOf(yibanCount));
  339. }
  340. if ("1".equals(res.getInspPblmCate())) {
  341. res.setPblmCount(String.valueOf(jiaozhongCount));
  342. }
  343. if ("2".equals(res.getInspPblmCate())) {
  344. res.setPblmCount(String.valueOf(yanzhongCount));
  345. }
  346. ListIn.add(res.getInspPblmCate());
  347. }
  348. spanNumList = getSpanNumList(ListIn);
  349. spanStartIndex = getStartIndexList(ListIn, spanNumList);
  350. indexs = getIndexs(secList, spanNumList, spanStartIndex);
  351. for (ResponsibilityDto res : secList) {
  352. if (index == 0) {
  353. //第1列
  354. Paragraph paragraph01 = new Paragraph(res.getUnitNm(), textFont);
  355. paragraph01.setAlignment(1);
  356. PdfPCell cell = new PdfPCell();
  357. cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
  358. cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
  359. cell.setPaddingTop(-2f);//把字垂直居中
  360. cell.setPaddingBottom(8f);//把字垂直居中
  361. cell.addElement(paragraph01);
  362. cell.setRowspan(secList.size());
  363. table.addCell(cell);
  364. }
  365. //合并列
  366. Paragraph paragraph02 = new Paragraph(StringUtils.isBlank(res.getInspPblmDesc()) ? "无" : res.getInspPblmDesc(), textFont);
  367. paragraph02.setAlignment(1);
  368. PdfPCell cell1 = new PdfPCell();
  369. cell1.addElement(paragraph02);
  370. table.addCell(cell1);
  371. //合并列
  372. Paragraph paragraph03 = new Paragraph(InspPblmUtils.plbmCateDesc(res.getInspPblmCate()), textFont);
  373. paragraph03.setAlignment(1);
  374. PdfPCell cell3 = new PdfPCell();
  375. cell3.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
  376. cell3.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);//然并卵
  377. cell3.setPaddingTop(-2f);//把字垂直居中
  378. cell3.setPaddingBottom(8f);//把字垂直居中
  379. cell3.addElement(paragraph03);
  380. setRowsSpan(indexs, spanStartIndex, spanNumList, table, cell3, index);
  381. //合并列
  382. Paragraph paragraph04 = new Paragraph(res.getPblmCount(), textFont);
  383. paragraph04.setAlignment(1);
  384. PdfPCell cell4 = new PdfPCell();
  385. cell4.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
  386. cell4.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);//然并卵
  387. cell4.setPaddingTop(-2f);//把字垂直居中
  388. cell4.setPaddingBottom(8f);//把字垂直居中
  389. cell4.addElement(paragraph04);
  390. setRowsSpan(indexs, spanStartIndex, spanNumList, table, cell4, index);
  391. if (index == 0) {
  392. //第1列
  393. Paragraph paragraph01 = new Paragraph(WtprjConvert.mendType1(res.getMendType()), textFont);
  394. paragraph01.setAlignment(1);
  395. PdfPCell cell = new PdfPCell();
  396. cell.addElement(paragraph01);
  397. cell.setRowspan(secList.size());
  398. table.addCell(cell);
  399. }
  400. index++;
  401. }
  402. }
  403. /**
  404. * 设置恰当位置的setRowSpan属性
  405. *
  406. * @param indexs 不加单元格的索引集合
  407. * @param spanStartIndex 要加的单元格开始索引集合
  408. * @param spanNumList 要加的单元格合并的值集合
  409. * @param table table
  410. * @param cell cell
  411. * @param i 索引
  412. */
  413. private void setRowsSpan(List<Integer> indexs, List<Integer> spanStartIndex,
  414. List<Integer> spanNumList, PdfPTable table, PdfPCell cell, int i) {
  415. if (indexs != null) {
  416. boolean isAllNotEqual = true;
  417. for (Integer index : indexs) {
  418. if (i == index) {
  419. isAllNotEqual = false;
  420. break;
  421. }
  422. }
  423. //没有不加的下标
  424. if (isAllNotEqual) {
  425. // 判断在哪里设置span值
  426. if (spanStartIndex != null) {
  427. boolean isSpan = false;
  428. int copyJ = 0;
  429. for (int j = 0; j < spanStartIndex.size(); j++) {
  430. if (i == spanStartIndex.get(j)) {
  431. isSpan = true;
  432. copyJ = j;
  433. break;
  434. }
  435. }
  436. if (isSpan) {
  437. int spanNum = spanNumList.get(copyJ);
  438. cell.setRowspan(spanNum);
  439. }
  440. }
  441. table.addCell(cell);
  442. }
  443. } else {
  444. table.addCell(cell);
  445. }
  446. }
  447. private void addTitle(PdfPTable table, String[] titleArr, Font headFont) {
  448. for (String aTitleArr : titleArr) {
  449. Paragraph p = new Paragraph(aTitleArr, headFont);
  450. PdfPCell cell = new PdfPCell();
  451. p.setAlignment(1);
  452. cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
  453. // 然并卵
  454. cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
  455. // 把字垂直居中
  456. cell.setPaddingTop(-2f);
  457. // 把字垂直居中
  458. cell.setPaddingBottom(8f);
  459. cell.addElement(p);
  460. table.addCell(cell);
  461. }
  462. }
  463. /**
  464. * 获取某列要合并的单元格数量
  465. *
  466. * @param list 内容必须符合'A,A,B,C,D,D,D,E' 而不是 'A,A,B,C,A,D,D,D,E' ,即所有相同的值必须在一起不能分散
  467. * @return
  468. */
  469. private List<Integer> getSpanNumList(List<String> list) {
  470. LinkedHashMap<String, Integer> map = new LinkedHashMap<>();
  471. if (list.size() > 0) {
  472. for (int i = 0; i < list.size(); i = i + 1) {
  473. map.put(list.get(i), i);
  474. }
  475. }
  476. //修改对应key值的value
  477. Set<String> s = map.keySet();//获取KEY集合
  478. List<String> strings = new ArrayList<>(s);
  479. int spanNum = 0;
  480. for (String string : strings) {
  481. int tmpSpanNum = map.get(string) - spanNum + 1;
  482. map.put(string, tmpSpanNum);
  483. spanNum += tmpSpanNum;
  484. }
  485. List<Integer> res = new ArrayList<>();
  486. for (String string : strings) {
  487. res.add(map.get(string));
  488. }
  489. return res;
  490. }
  491. /**
  492. * 获取某列要合并的单元格初始下标
  493. *
  494. * @param list 内容必须符合'A,A,B,C,D,D,D,E' 而不是 'A,A,B,C,A,D,D,D,E' ,即所有相同的值必须在一起不能分散
  495. * @param resSpanNumList
  496. * @return
  497. */
  498. private List<Integer> getStartIndexList(List<String> list, List<Integer> resSpanNumList) {
  499. LinkedHashMap<String, Integer> map = new LinkedHashMap<>();
  500. if (list.size() > 0) {
  501. for (int i = 0; i < list.size(); i = i + 1) {
  502. map.put(list.get(i), i);
  503. }
  504. }
  505. Set<String> keys = map.keySet();//获取KEY集合
  506. List<String> stringKeys = new ArrayList<>(keys);
  507. List<Integer> res = new ArrayList<>();
  508. if (stringKeys.size() == resSpanNumList.size()) {
  509. for (int i = 0; i < stringKeys.size(); i++) {
  510. res.add(map.get(stringKeys.get(i)) - resSpanNumList.get(i) + 1);
  511. }
  512. }
  513. return res;
  514. }
  515. /**
  516. * 不加某字段的索引集合
  517. *
  518. * @param list
  519. * @param resSpanNumList
  520. * @param resStartIndexList
  521. * @return
  522. */
  523. private List<Integer> getIndexs(List<ResponsibilityDto> list,
  524. List<Integer> resSpanNumList, List<Integer> resStartIndexList) {
  525. List<Integer> indexs = new ArrayList<>();
  526. for (int i = 0; i < list.size(); i++) {
  527. for (int j = 0; j < resStartIndexList.size(); j++) {
  528. if (i == resStartIndexList.get(j)) {
  529. for (int k = i + 1; k < i + resSpanNumList.get(j); k++) {
  530. indexs.add(k);
  531. }
  532. }
  533. }
  534. }
  535. return indexs;
  536. }
  537. private String getResDesc(String unitId) {
  538. List<Map<String, Object>> res = bisInspWtprjUnitService.getResponsibility(unitId);
  539. StringBuilder stb = new StringBuilder();
  540. for (Map<String, Object> map : res) {
  541. if (MapUtils.getIntValue(map, "count") != 0) {
  542. stb.append(InspPblmUtils.plbmCateDesc(MapUtils.getString(map, "level")))
  543. .append("问题:")
  544. .append(MapUtils.getIntValue(map, "count"))
  545. .append("个,\n")
  546. .append(StringUtils.isBlank(MapUtils.getString(map, "chose")) ? "" : ("可选责任追究方式:" + MapUtils.getString(map, "chose") + "\n"))
  547. .append("最高责任追究方式:")
  548. .append(MapUtils.getString(map, "max", ""))
  549. .append("\n");
  550. }
  551. }
  552. return stb.toString();
  553. }
  554. }