548f3ec9f9107435aaf19897111fca602287e563.svn-base 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. package cn.com.goldenwater.dcproj.utils;
  2. import cn.com.goldenwater.dcproj.constValue.JinChaEnum;
  3. import cn.com.goldenwater.dcproj.constValue.TacEnum;
  4. import cn.com.goldenwater.dcproj.dao.BisInspPreListDao;
  5. import cn.com.goldenwater.dcproj.dto.CateTotal;
  6. import cn.com.goldenwater.dcproj.dto.PblmRetCount;
  7. import cn.com.goldenwater.dcproj.model.*;
  8. import cn.com.goldenwater.id.util.UuidUtil;
  9. import com.github.pagehelper.PageInfo;
  10. import org.apache.commons.lang3.StringUtils;
  11. import javax.imageio.ImageIO;
  12. import java.awt.image.BufferedImage;
  13. import java.io.File;
  14. import java.io.IOException;
  15. import java.util.HashMap;
  16. import java.util.List;
  17. import java.util.Map;
  18. public class InspUtils {
  19. public static String convertThirdLengthStr(String value) {
  20. if (value == null) {
  21. return value;
  22. }
  23. switch (value.length()) {
  24. case 1:
  25. value = "00" + value;
  26. break;
  27. case 2:
  28. value = "0" + value;
  29. break;
  30. default:
  31. }
  32. return value;
  33. }
  34. public static void addPreList(BisInspBaseView bisInspBaseView, BisInspPreListDao bisInspPreListDao) {
  35. List<BisInspPreList> inspPreLists = bisInspBaseView.getInspPreLists();
  36. StringBuffer buffer = new StringBuffer();
  37. if (inspPreLists == null) {
  38. return;
  39. }
  40. for (BisInspPreList inspPreList : inspPreLists) {
  41. String viewPreId = UuidUtil.uuid();
  42. inspPreList.setViewPreId(viewPreId);
  43. inspPreList.setViewId(bisInspBaseView.getViewId());
  44. buffer.append(inspPreList.getViewPreName() + ",");
  45. bisInspPreListDao.insert(inspPreList);
  46. }
  47. if (StringUtils.isNotBlank(buffer.toString())) {
  48. String viewPreNames = buffer.substring(0, buffer.length() - 1);
  49. bisInspBaseView.setViewPreNames(viewPreNames);
  50. }
  51. if (bisInspBaseView.getInspPreLists() != null) {
  52. bisInspBaseView.setViewPres(bisInspBaseView.getInspPreLists().size());
  53. }
  54. }
  55. public static String getTypeState(String type, TacPawpRgstr tacPawpRgstr) {
  56. if (JinChaEnum.TACPAWPPDBST.getKey().equals(type)) {
  57. return tacPawpRgstr.getPdbstStat();
  58. }
  59. if (JinChaEnum.TacPawpBstocmTsopbfp.getKey().equals(type)) {
  60. return tacPawpRgstr.getBstocmTsopbfpStat();
  61. }
  62. if (JinChaEnum.TacPawpRaiobis.getKey().equals(type)) {
  63. return tacPawpRgstr.getRaiobisStat();
  64. }
  65. if (JinChaEnum.TacPawpBstocmCms.getKey().equals(type)) {
  66. return tacPawpRgstr.getBstocmCmsStat();
  67. }
  68. if (JinChaEnum.TacPawpBitopqPeqaa.getKey().equals(type)) {
  69. return tacPawpRgstr.getBitopqPeqaaStat();
  70. }
  71. if (JinChaEnum.TacPawpBioesRwunit.getKey().equals(type)) {
  72. return tacPawpRgstr.getBioesRwunitStat();
  73. }
  74. return "0";
  75. }
  76. public static String getBySn(String sn) {
  77. if (StringUtils.isBlank(sn)) {
  78. return "";
  79. }
  80. String[] arrays = sn.split("\\.");
  81. if (arrays.length == 3) {
  82. if (arrays[1].length() == 1) {
  83. arrays[1] = "0" + arrays[1];
  84. }
  85. if (arrays[2].length() == 1) {
  86. arrays[2] = "0" + arrays[2];
  87. }
  88. return arrays[0] + arrays[1] + arrays[2];
  89. }
  90. if (arrays.length == 2) {
  91. if (arrays[1].length() == 1) {
  92. arrays[1] = "0" + arrays[1] + "00";
  93. }
  94. return arrays[0] + arrays[1];
  95. }
  96. return "";
  97. }
  98. public static String getPblmType(String pblmChType) {
  99. if ("5".equals(pblmChType) || "6".equals(pblmChType)) {
  100. return "5";
  101. }
  102. if ("7".equals(pblmChType)) {
  103. return "6";
  104. }
  105. return pblmChType;
  106. }
  107. public static PblmRetCount setPblmCount(List<CateTotal> cateTotals) {
  108. PblmRetCount pblmRetCount = new PblmRetCount();
  109. pblmRetCount.setRsName("总计");
  110. int total = 0;
  111. for (CateTotal cateTotal : cateTotals) {
  112. total += cateTotal.getTotal();
  113. if ("一般".equals(cateTotal.getCate())) {
  114. pblmRetCount.setCate0(cateTotal.getTotal());
  115. }
  116. if ("较重".equals(cateTotal.getCate())) {
  117. pblmRetCount.setCate1(cateTotal.getTotal());
  118. }
  119. if ("严重".equals(cateTotal.getCate())) {
  120. pblmRetCount.setCate2(cateTotal.getTotal());
  121. }
  122. if ("特别严重".equals(cateTotal.getCate())) {
  123. pblmRetCount.setCate3(cateTotal.getTotal());
  124. }
  125. }
  126. pblmRetCount.setSub(total);
  127. return pblmRetCount;
  128. }
  129. public static String setOrgIds(String orgIds) {
  130. if (StringUtils.isNotBlank(orgIds)) {
  131. if (!orgIds.contains("'")) {
  132. orgIds = orgIds.replace(",", "','");
  133. orgIds = "'" + orgIds + "'";
  134. }
  135. }
  136. return orgIds;
  137. }
  138. public static String setPlbmName(String problemType) {
  139. if ("0".equals(problemType)) {
  140. return "违规行为";
  141. }
  142. if ("1".equals(problemType)) {
  143. return "质量缺陷";
  144. }
  145. if ("2".equals(problemType)) {
  146. return "合同问题";
  147. }
  148. if ("3".equals(problemType)) {
  149. return "工程缺陷";
  150. }
  151. return null;
  152. }
  153. public static String setProblemType(String inspName) {
  154. if ("违规行为".equals(inspName)) {
  155. return "0";
  156. }
  157. if ("质量缺陷".equals(inspName)) {
  158. return "1";
  159. }
  160. if ("合同问题".equals(inspName)) {
  161. return "2";
  162. }
  163. if ("工程缺陷".equals(inspName)) {
  164. return "3";
  165. }
  166. return null;
  167. }
  168. private static Map<String, String> sort1 = new HashMap<>();
  169. private static Map<String, String> sort2 = new HashMap<>();
  170. static {
  171. sort1.put("0", "质量管理违法行为");
  172. sort1.put("1", "安全生产违法行为");
  173. sort1.put("2", "质量缺陷");
  174. sort1.put("3", "合同问题");
  175. sort1.put("4", "运行管理违规行为");
  176. }
  177. static {
  178. sort2.put("0", "质量体系");
  179. sort2.put("1", "过程控制");
  180. sort2.put("2", "施工准备");
  181. sort2.put("3", "设计变更");
  182. sort2.put("4", "原材料及中间产品");
  183. sort2.put("5", "过程控制");
  184. sort2.put("6", "事故处理");
  185. }
  186. /**
  187. * 获取类型1
  188. */
  189. public static String getSort1(String key) {
  190. return sort1.get(key);
  191. }
  192. /**
  193. * 获取类型2
  194. */
  195. public static String getSort2(String key) {
  196. return sort2.get(key);
  197. }
  198. public static void initTempDocFile(File directory) {
  199. if (directory.isDirectory()) {
  200. /**只保留3小时内的临时文件*/
  201. long nowTime = System.currentTimeMillis() - 3 * 3600 * 1000L;
  202. File[] fileList = directory.listFiles(pathname -> {
  203. long lastModifyTime = pathname.lastModified();
  204. return lastModifyTime < nowTime;
  205. });
  206. if (fileList != null && fileList.length != 0) {
  207. for (File file1 : fileList) {
  208. try {
  209. file1.delete();
  210. } catch (Exception e) {
  211. }
  212. }
  213. }
  214. }
  215. }
  216. public static void addLocs(PageInfo<BisInspPblm> inspPblmList) {
  217. for (BisInspPblm bisInspPblm : inspPblmList.getList()) {
  218. if (StringUtils.isNotBlank(bisInspPblm.getAdFullName())) {
  219. String[] adFullNames = bisInspPblm.getAdFullName().split("-");
  220. bisInspPblm.setProvince(adFullNames[0]);
  221. if (adFullNames.length > 1) {
  222. bisInspPblm.setCity(adFullNames[1]);
  223. }
  224. if (adFullNames.length > 2) {
  225. bisInspPblm.setCountry(adFullNames[2]);
  226. }
  227. }
  228. }
  229. }
  230. public static void addLocsNew(PageInfo<KeyRegPblm> inspPblmList) {
  231. for (KeyRegPblm bisInspPblm : inspPblmList.getList()) {
  232. if (StringUtils.isNotBlank(bisInspPblm.getAdFullName())) {
  233. String[] adFullNames = bisInspPblm.getAdFullName().split("-");
  234. bisInspPblm.setProvince(adFullNames[0]);
  235. if (adFullNames.length > 1) {
  236. bisInspPblm.setCity(adFullNames[1]);
  237. }
  238. if (adFullNames.length > 2) {
  239. bisInspPblm.setCountry(adFullNames[2]);
  240. }
  241. }
  242. }
  243. }
  244. public static boolean isImage(File file) throws IOException {
  245. BufferedImage bi = ImageIO.read(file);
  246. if (bi == null) {
  247. return false;
  248. }
  249. return true;
  250. }
  251. public static String getSpfsnlType(String pblmChType) {
  252. if (TacEnum.QIANQI.getKey().equals(pblmChType)) {
  253. return TacEnum.QIANQI.getValue();
  254. }
  255. if (TacEnum.JIANSHE.getKey().equals(pblmChType)) {
  256. return TacEnum.JIANSHE.getValue();
  257. }
  258. if (TacEnum.JIHUA.getKey().equals(pblmChType)) {
  259. return TacEnum.JIHUA.getValue();
  260. }
  261. if (TacEnum.CAIWU.getKey().equals(pblmChType)) {
  262. return TacEnum.CAIWU.getValue();
  263. }
  264. if (TacEnum.ZILIANGSHITI.getKey().equals(pblmChType)) {
  265. return TacEnum.ZILIANGSHITI.getValue();
  266. }
  267. if (TacEnum.ZILIANGGUANLI.getKey().equals(pblmChType)) {
  268. return TacEnum.ZILIANGGUANLI.getValue();
  269. }
  270. return TacEnum.ANQUAN.getValue();
  271. }
  272. }