SupermeController.java 36 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211
  1. package platform.modules.government.web;
  2. import java.io.IOException;
  3. import java.util.ArrayList;
  4. import java.util.HashMap;
  5. import java.util.List;
  6. import java.util.Map;
  7. import org.apache.commons.lang3.StringUtils;
  8. import org.springframework.beans.factory.annotation.Autowired;
  9. import org.springframework.http.HttpStatus;
  10. import org.springframework.http.ResponseEntity;
  11. import org.springframework.stereotype.Controller;
  12. import org.springframework.ui.ModelMap;
  13. import org.springframework.web.bind.annotation.*;
  14. import com.github.pagehelper.PageHelper;
  15. import com.github.pagehelper.PageInfo;
  16. import org.springframework.web.multipart.MultipartFile;
  17. import platform.common.Constant;
  18. import platform.common.annotation.OperationLog;
  19. import platform.common.base.controller.BaseController;
  20. import platform.common.base.model.DictionaryItem;
  21. import platform.common.base.model.DictionaryType;
  22. import platform.common.base.model.Template;
  23. import platform.common.base.service.DictionaryItemService;
  24. import platform.common.base.service.DictionaryTypeService;
  25. import platform.common.base.service.TemplateService;
  26. import platform.common.util.ReadExcelUtil;
  27. import platform.common.util.holiday.HolidayExcelParser;
  28. import platform.common.util.holiday.HolidayExcelTemplateUtil;
  29. import platform.modules.build.entity.BuildInfo;
  30. import platform.modules.build.service.BuildInfoService;
  31. import platform.modules.build.service.CompanyService;
  32. import platform.modules.government.dto.AttachmentDto;
  33. import platform.modules.government.entity.Attachment;
  34. import platform.modules.government.entity.BuildType;
  35. import platform.modules.government.entity.Street;
  36. import platform.modules.government.entity.User;
  37. import platform.modules.government.service.AttachmentService;
  38. import platform.modules.government.service.BuildTypeService;
  39. import platform.modules.government.service.StreetService;
  40. import platform.modules.government.service.UserService;
  41. import platform.modules.sys.entity.SysConfig;
  42. import platform.modules.sys.service.SysConfigService;
  43. import platform.modules.sys.web.ResponseMessage;
  44. import tk.mybatis.mapper.entity.Example;
  45. import javax.annotation.Resource;
  46. import javax.servlet.http.HttpServletRequest;
  47. @Controller
  48. @RequestMapping(value = "/super")
  49. public class SupermeController extends BaseController {
  50. @Autowired
  51. private StreetService streeService;
  52. @Autowired
  53. private BuildTypeService buildTypeService;
  54. @Autowired
  55. private BuildInfoService buildService;
  56. @Autowired
  57. private CompanyService companyService;
  58. @Autowired
  59. private DictionaryTypeService dictionaryTypeService;
  60. @Autowired
  61. private DictionaryItemService dictionaryItemService;
  62. @Autowired
  63. private TemplateService templateService;
  64. @Autowired
  65. private UserService userService;
  66. @Autowired
  67. private AttachmentService attachmentService;
  68. @Autowired
  69. private SysConfigService sysConfigService;
  70. @Resource
  71. private HolidayExcelTemplateUtil holidayExcelTemplateUtil;
  72. @GetMapping(value = "")
  73. public String list() {
  74. return BASE_SUPER_PATH + "/datadictionary";
  75. }
  76. /**
  77. * 街道列表展示
  78. *
  79. * @param pageNum
  80. * @param keyword
  81. * @param modelMap
  82. * @return
  83. * @throws Exception
  84. */
  85. @OperationLog(value = "查询街道列表")
  86. @GetMapping(value = "/streeList")
  87. public String streeList(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, String keyword,
  88. ModelMap modelMap) throws Exception {
  89. PageInfo<Street> pageInfo = streeService.findPage(pageNum, PAGESIZE, keyword);
  90. modelMap.put("pageInfo", pageInfo);
  91. modelMap.put("keyword", keyword);
  92. return BASE_SUPER_PATH + "/stree_list";
  93. }
  94. @GetMapping(value = "/stree/add")
  95. public String addStreePage(ModelMap modelMap) {
  96. return BASE_SUPER_PATH + "/stree_add";
  97. }
  98. @OperationLog(value = "街道信息保存")
  99. @ResponseBody
  100. @PostMapping(value = "/stree/save")
  101. public ModelMap saveStree(Street stree) throws Exception {
  102. ModelMap messagesMap = new ModelMap();
  103. if(IsTooFrequently()) {
  104. messagesMap.put("status", FAILURE);
  105. messagesMap.put("message", "操作过于频繁,请稍后再试!");
  106. return messagesMap;
  107. }
  108. Boolean flag = false;
  109. if (stree.getId() == null) {
  110. flag = streeService.saveStree(stree);
  111. } else {
  112. flag = streeService.updateStree(stree);
  113. }
  114. if (flag) {
  115. messagesMap.put("status", SUCCESS);
  116. messagesMap.put("message", "操作成功!");
  117. return messagesMap;
  118. }
  119. messagesMap.put("status", FAILURE);
  120. messagesMap.put("message", "操作失败!");
  121. return messagesMap;
  122. }
  123. /**
  124. * 跳转到编辑页面
  125. *
  126. * @return
  127. */
  128. @GetMapping(value = "/stree/edit/{id}")
  129. public String editStree(@PathVariable("id") int id, ModelMap modelMap) {
  130. Street stree = streeService.findById(id);
  131. log.info("跳转到内容编辑页面!id = {}", id);
  132. modelMap.put("stree", stree);
  133. return BASE_SUPER_PATH + "/stree_edit";
  134. }
  135. @OperationLog(value = "街道删除")
  136. @ResponseBody
  137. @PutMapping(value = "/stree/delete")
  138. public ResponseMessage deleteStree(@RequestParam("ids") String ids) {
  139. Street stree = streeService.findById(Integer.parseInt(ids));
  140. if (null == stree) {
  141. return ResponseMessage.error("未找到相应的街道");
  142. }
  143. //若街道下面有园区,则不能删。
  144. Integer buildCount = buildService.findBuildCountByStreet(Integer.parseInt(ids));
  145. if(buildCount>0){
  146. return ResponseMessage.error("删除失败!该街道下存在园区,不能删除。");
  147. }
  148. stree.setDel_flag(true);
  149. Boolean flag = streeService.updateStree(stree);
  150. if (flag) {
  151. return ResponseMessage.success("删除成功!");
  152. } else {
  153. return ResponseMessage.error("删除失败!");
  154. }
  155. }
  156. @OperationLog(value = "园区类型删除")
  157. @ResponseBody
  158. @PutMapping(value = "/buildType/delete")
  159. public ResponseMessage deleteBuildType(@RequestParam("ids") String ids) {
  160. BuildType bt = buildTypeService.findById(Integer.parseInt(ids));
  161. if (null == bt) {
  162. return ResponseMessage.error("未找到相应的园区类型");
  163. }
  164. //若园区类型下面有园区,则不能删除。
  165. Integer buildCount = buildService.findCountByType(Integer.parseInt(ids));
  166. if(buildCount>0){
  167. return ResponseMessage.error("删除失败!该类型下存在园区,不能删除。");
  168. }
  169. bt.setDel_flag(true);
  170. Boolean flag = buildTypeService.updateBuildType(bt);
  171. if (flag) {
  172. return ResponseMessage.success("删除成功!");
  173. } else {
  174. return ResponseMessage.error("删除失败!");
  175. }
  176. }
  177. @OperationLog(value = "园区删除")
  178. @ResponseBody
  179. @PutMapping(value = "/build/delete")
  180. public ResponseMessage deleteBuild(@RequestParam("ids") String ids) {
  181. BuildInfo b = buildService.findById(Integer.parseInt(ids));
  182. if (null == b) {
  183. return ResponseMessage.error("未找到相应的园区");
  184. }
  185. //若园区下面有企业,则不能删。
  186. Integer companyCount = companyService.findAllCuntCompanyByBuildId(Integer.parseInt(ids));
  187. if(companyCount>0){
  188. return ResponseMessage.error("删除失败!该园区下存在企业,不能删除。");
  189. }
  190. b.setDel_flag(true);
  191. Boolean flag = buildService.updateBuild(b);
  192. if (flag) {
  193. return ResponseMessage.success("删除成功!");
  194. } else {
  195. return ResponseMessage.error("删除失败!");
  196. }
  197. }
  198. @GetMapping(value = "/buildTypeList")
  199. public String buildTypeList(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, String keyword,
  200. ModelMap modelMap) throws Exception {
  201. PageInfo<BuildType> pageInfo = buildTypeService.findPage(pageNum, PAGESIZE, keyword, Constant.DictType.BUILD);
  202. modelMap.put("pageInfo", pageInfo);
  203. modelMap.put("keyword", keyword);
  204. return BASE_SUPER_PATH + "/buildtype_list";
  205. }
  206. @GetMapping(value = "/buildType/add")
  207. public String addBuildTypePage(ModelMap modelMap) {
  208. return BASE_SUPER_PATH + "/buildtype_add";
  209. }
  210. @OperationLog(value = "园区类型保存")
  211. @ResponseBody
  212. @PostMapping(value = "/buildType/save")
  213. public ModelMap saveBuildType(BuildType bt) throws Exception {
  214. ModelMap messagesMap = new ModelMap();
  215. if(IsTooFrequently()) {
  216. messagesMap.put("status", FAILURE);
  217. messagesMap.put("message", "操作过于频繁,请稍后再试!");
  218. return messagesMap;
  219. }
  220. Boolean flag = false;
  221. bt.setOpt_type(Constant.DictType.BUILD);
  222. if (bt.getId() == null) {
  223. flag = buildTypeService.saveBuildType(bt);
  224. } else {
  225. flag = buildTypeService.updateBuildType(bt);
  226. }
  227. if (flag) {
  228. messagesMap.put("status", SUCCESS);
  229. messagesMap.put("message", "操作成功!");
  230. return messagesMap;
  231. }
  232. messagesMap.put("status", FAILURE);
  233. messagesMap.put("message", "操作失败!");
  234. return messagesMap;
  235. }
  236. /**
  237. * 跳转到编辑页面
  238. *
  239. * @return
  240. */
  241. @GetMapping(value = "/buildType/edit/{id}")
  242. public String editBuildType(@PathVariable("id") int id, ModelMap modelMap) {
  243. BuildType buildType = buildTypeService.findById(id);
  244. modelMap.put("buildType", buildType);
  245. return BASE_SUPER_PATH + "buildtype_edit";
  246. }
  247. @OperationLog(value = "企业类型删除")
  248. @ResponseBody
  249. @DeleteMapping(value = "/companyType/delete/{id}")
  250. public ResponseMessage deleteStreetType(@PathVariable("id") Integer id) {
  251. BuildType bt = buildTypeService.findById(id);
  252. if (null == bt) {
  253. return ResponseMessage.error("未找到相应的企业类型");
  254. }
  255. //若园区类型下面有园区,则不能删除。
  256. Integer buildCount = companyService.countByType(id);
  257. if(buildCount>0){
  258. return ResponseMessage.error("删除失败!该类型下存在企业,不能删除。");
  259. }
  260. bt.setDel_flag(true);
  261. Boolean flag = buildTypeService.updateBuildType(bt);
  262. if (flag) {
  263. return ResponseMessage.success("删除成功!");
  264. } else {
  265. return ResponseMessage.error("删除失败!");
  266. }
  267. }
  268. @GetMapping(value = "/companyTypeList")
  269. public String streetTypeList(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, String keyword,
  270. ModelMap modelMap) throws Exception {
  271. PageInfo<BuildType> pageInfo = buildTypeService.findPage(pageNum, PAGESIZE, keyword,Constant.DictType.COMPANY);
  272. modelMap.put("pageInfo", pageInfo);
  273. modelMap.put("keyword", keyword);
  274. return BASE_SUPER_PATH + "/company_type_list";
  275. }
  276. @GetMapping(value = "/companyType/add")
  277. public String companyTypeAdd() {
  278. return BASE_SUPER_PATH + "/company_type_add";
  279. }
  280. @OperationLog(value = "园区类型保存")
  281. @ResponseBody
  282. @PostMapping(value = "/companyTypeSave")
  283. public ModelMap companyTypeSave(BuildType bt) throws Exception {
  284. ModelMap messagesMap = new ModelMap();
  285. if(IsTooFrequently()) {
  286. messagesMap.put("status", FAILURE);
  287. messagesMap.put("message", "操作过于频繁,请稍后再试!");
  288. return messagesMap;
  289. }
  290. Boolean flag = false;
  291. bt.setOpt_type(Constant.DictType.COMPANY);
  292. if (bt.getId() == null) {
  293. flag = buildTypeService.saveBuildType(bt);
  294. } else {
  295. flag = buildTypeService.updateBuildType(bt);
  296. }
  297. if (flag) {
  298. messagesMap.put("status", SUCCESS);
  299. messagesMap.put("message", "操作成功!");
  300. return messagesMap;
  301. }
  302. messagesMap.put("status", FAILURE);
  303. messagesMap.put("message", "操作失败!");
  304. return messagesMap;
  305. }
  306. /**
  307. * 跳转到编辑页面
  308. *
  309. * @return
  310. */
  311. @GetMapping(value = "/companyType/edit/{id}")
  312. public String companyTypeEdit(@PathVariable("id") int id, ModelMap modelMap) {
  313. BuildType buildType = buildTypeService.findById(id);
  314. modelMap.put("companyType", buildType);
  315. return BASE_SUPER_PATH + "company_type_edit";
  316. }
  317. @GetMapping(value = "/buildList")
  318. public String buildList(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, String keyword,
  319. String street_id, String type, ModelMap modelMap) throws Exception {
  320. HashMap<String, String> param = new HashMap<>();
  321. param.put("keyWord", keyword);
  322. param.put("street_id", street_id);
  323. param.put("type", type);
  324. PageInfo<BuildInfo> pageInfo = buildService.findSPage(pageNum, PAGESIZE, param);
  325. modelMap.put("pageInfo", pageInfo);
  326. modelMap.put("keyword", keyword);
  327. modelMap.put("street_id",StringUtils.isBlank(street_id)?null:Integer.parseInt(street_id));
  328. modelMap.put("type",StringUtils.isBlank(type)?null:Integer.parseInt(type));
  329. getBuildPageInit(modelMap);
  330. return BASE_SUPER_PATH + "/build_list";
  331. }
  332. /**
  333. * 获取园区页面初始化下拉框信息
  334. *
  335. * @param modelMap
  336. */
  337. private void getBuildPageInit(ModelMap modelMap) {
  338. modelMap.addAttribute("streeList", streeService.findList());
  339. modelMap.addAttribute("buildTypeList", buildTypeService.findList(Constant.DictType.BUILD));
  340. }
  341. @GetMapping(value = "/build/add")
  342. public String addBuildPage(ModelMap modelMap) {
  343. getBuildPageInit(modelMap);
  344. return BASE_SUPER_PATH + "/build_add";
  345. }
  346. /**
  347. * 跳转到编辑页面
  348. *
  349. * @return
  350. */
  351. @GetMapping(value = "/build/edit/{id}")
  352. public String editBuild(@PathVariable("id") int id, ModelMap modelMap) {
  353. getBuildPageInit(modelMap);
  354. BuildInfo build = buildService.findById(id);
  355. modelMap.put("build", build);
  356. return BASE_SUPER_PATH + "build_edit";
  357. }
  358. @OperationLog(value = "园区信息修改")
  359. @ResponseBody
  360. @PostMapping(value = "/build/save")
  361. public ModelMap saveBuild(BuildInfo b) throws Exception {
  362. ModelMap messagesMap = new ModelMap();
  363. if(IsTooFrequently()) {
  364. messagesMap.put("status", FAILURE);
  365. messagesMap.put("message", "操作过于频繁,请稍后再试!");
  366. return messagesMap;
  367. }
  368. Boolean flag = false;
  369. if (b.getId() == null) {
  370. flag = buildService.saveBuild(b);
  371. } else {
  372. flag = buildService.updateBuild(b);
  373. }
  374. if (flag) {
  375. messagesMap.put("status", SUCCESS);
  376. messagesMap.put("message", "操作成功!");
  377. return messagesMap;
  378. }
  379. messagesMap.put("status", FAILURE);
  380. messagesMap.put("message", "操作失败!");
  381. return messagesMap;
  382. }
  383. /**
  384. * 检验街道名是否存在
  385. *
  386. * @param name
  387. * @return
  388. */
  389. @ResponseBody
  390. @GetMapping(value = "/isExistStreet")
  391. public Boolean isExistStreet(String id, String name) throws Exception {
  392. boolean flag = true;
  393. log.debug("检验街道名是否存在参数! id= {}, name= {}", id, name);
  394. Street street = streeService.getStreet(name);
  395. if (null != street) {
  396. if (StringUtils.isBlank(id)) {
  397. flag = false;
  398. } else {
  399. if (street.getId() != (Integer.parseInt(id))) {
  400. flag = false;
  401. }
  402. }
  403. }
  404. log.info("检验街道名是否存在结果! flag = {}", flag);
  405. return flag;
  406. }
  407. /**
  408. * 检验园区名是否存在
  409. *
  410. * @param name
  411. * @return
  412. */
  413. @ResponseBody
  414. @GetMapping(value = "/isExistBuild")
  415. public Boolean isExistBuild(String id, String name) throws Exception {
  416. boolean flag = true;
  417. log.debug("检验园区名是否存在参数! id= {}, name= {}", id, name);
  418. BuildInfo buildInfo= buildService.getBuildInfo(name);
  419. if (null != buildInfo) {
  420. if (StringUtils.isBlank(id)) {
  421. flag = false;
  422. } else {
  423. if (buildInfo.getId() != (Integer.parseInt(id))) {
  424. flag = false;
  425. }
  426. }
  427. }
  428. log.info("检验园区名是否存在结果! flag = {}", flag);
  429. return flag;
  430. }
  431. /**
  432. * 检验园区类型是否存在
  433. *
  434. * @param name
  435. * @return
  436. */
  437. @ResponseBody
  438. @GetMapping(value = "/isExistBuildType")
  439. public Boolean isExistBuildType(String id, String name) throws Exception {
  440. boolean flag = true;
  441. log.debug("检验园区类型是否存在参数! id= {}, name= {}", id, name);
  442. BuildType buildInfo= buildTypeService.getBuildInfo(name,Constant.DictType.BUILD);
  443. if (null != buildInfo) {
  444. if (StringUtils.isBlank(id)) {
  445. flag = false;
  446. } else {
  447. if (buildInfo.getId() != (Integer.parseInt(id))) {
  448. flag = false;
  449. }
  450. }
  451. }
  452. log.info("检验园区名是否存在结果! flag = {}", flag);
  453. return flag;
  454. }
  455. /**
  456. * 检验企业类型是否存在
  457. *
  458. * @param name
  459. * @return
  460. */
  461. @ResponseBody
  462. @GetMapping(value = "/isExistCompanyType")
  463. public Boolean isExistCompanyType(String id, String name) throws Exception {
  464. boolean flag = true;
  465. log.debug("检验企业类型是否存在! id= {}, name= {}", id, name);
  466. BuildType buildInfo= buildTypeService.getBuildInfo(name,Constant.DictType.COMPANY);
  467. if (null != buildInfo) {
  468. if (StringUtils.isBlank(id)) {
  469. flag = false;
  470. } else {
  471. if (buildInfo.getId() != (Integer.parseInt(id))) {
  472. flag = false;
  473. }
  474. }
  475. }
  476. log.info("检验企业类型是否存在结果! flag = {}", flag);
  477. return flag;
  478. }
  479. /**
  480. * 更新街道状态
  481. *
  482. * @param id
  483. * @return
  484. */
  485. @OperationLog(value = "更新街道状态")
  486. @ResponseBody
  487. @PostMapping(value = "/status/{id}")
  488. public ResponseMessage status(@PathVariable Integer id, @RequestParam("isLock") Boolean isLock) throws Exception {
  489. log.debug("更新街道状态! ids = {}", id);
  490. Street street = new Street();
  491. street.setId(id);
  492. street.setIs_start(isLock);
  493. if(1==streeService.updateSelective(street)){
  494. userService.updateStreetIsStart(id, null, isLock);
  495. return ResponseMessage.success("更新状态成功!");
  496. }
  497. return ResponseMessage.error("更新状态失败!");
  498. }
  499. /*********************数据字典**********************/
  500. /**
  501. * 数据字典类型列表展示
  502. *
  503. * @param pageNum
  504. * @param keyword
  505. * @param modelMap
  506. * @return
  507. * @throws Exception
  508. */
  509. @GetMapping(value = "/dictionaryTypeList")
  510. public String dictionaryTypeList(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, String keyword,
  511. ModelMap modelMap) throws Exception {
  512. PageInfo<DictionaryType> pageInfo = dictionaryTypeService.findPage(pageNum, PAGESIZE, keyword);
  513. modelMap.put("pageInfo", pageInfo);
  514. modelMap.put("keyword", keyword);
  515. return BASE_SUPER_PATH + "dictionary/dictionary_type_list";
  516. }
  517. @GetMapping(value = "/dictionaryType/add")
  518. public String addDictionaryTypePage(ModelMap modelMap) {
  519. return BASE_SUPER_PATH + "dictionary/dictionary_type_add";
  520. }
  521. @GetMapping(value = "/dictionaryType/edit/{id}")
  522. public String editDictionaryTypePage(@PathVariable("id") int id,ModelMap modelMap) {
  523. DictionaryType dictionaryType = dictionaryTypeService.findById(id);
  524. modelMap.put("dictionaryType", dictionaryType);
  525. return BASE_SUPER_PATH + "dictionary/dictionary_type_edit";
  526. }
  527. @OperationLog(value = "数据字典类型保存")
  528. @ResponseBody
  529. @PostMapping(value = "/dictionaryType/save")
  530. public ResponseMessage saveDictionaryType(DictionaryType type) throws Exception {
  531. if(IsTooFrequently()) {
  532. return ResponseMessage.success("操作过于频繁,请稍后再试!");
  533. }
  534. Boolean flag = false;
  535. if (type.getId() == null) {
  536. flag = dictionaryTypeService.saveDictionaryType(type);
  537. } else {
  538. flag = dictionaryTypeService.updateDictionaryType(type);
  539. }
  540. if (flag) {
  541. return ResponseMessage.success("操作成功!");
  542. }
  543. return ResponseMessage.success("操作失败!");
  544. }
  545. @OperationLog(value = "数据字典类型删除")
  546. @ResponseBody
  547. @DeleteMapping(value = "/dictionaryType/delete/{id}")
  548. public ResponseMessage deleteDictionaryType(@PathVariable("id") int id,ModelMap modelMap) {
  549. DictionaryType type = dictionaryTypeService.findById(id);
  550. if (null == type) {
  551. return ResponseMessage.error("未找到相应的数据类型");
  552. }
  553. type.setDel_flag(true);
  554. Boolean flag = dictionaryTypeService.updateDictionaryType(type);
  555. if (flag) {
  556. return ResponseMessage.success("删除成功!");
  557. } else {
  558. return ResponseMessage.error("删除失败!");
  559. }
  560. }
  561. /**
  562. * 检验数据类型是否存在
  563. * @param
  564. * @param name
  565. * @return
  566. */
  567. @ResponseBody
  568. @GetMapping(value = "/isExistDictionaryType")
  569. public Boolean isExistDictionaryType(String id, String name) throws Exception {
  570. boolean flag = true;
  571. log.debug("检验数据类型是否存在参数! id= {}, name= {}", id, name);
  572. DictionaryType dictionaryType= dictionaryTypeService.getDictionaryType(name);
  573. if (null != dictionaryType) {
  574. if (StringUtils.isBlank(id)) {
  575. flag = false;
  576. } else {
  577. if (dictionaryType.getId() != (Integer.parseInt(id))) {
  578. flag = false;
  579. }
  580. }
  581. }
  582. log.info("检验数据类型是否存在结果! flag = {}", flag);
  583. return flag;
  584. }
  585. /**
  586. * 数据字典条目列表展示
  587. *
  588. * @param pageNum
  589. * @param keyword
  590. * @param modelMap
  591. * @return
  592. * @throws Exception
  593. */
  594. @GetMapping(value = "/dictionaryItemList")
  595. public String dictionaryItemList(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, String keyword,
  596. ModelMap modelMap,Integer typeId) throws Exception {
  597. Example example = new Example(DictionaryType.class);
  598. Example.Criteria criteria = example.createCriteria();
  599. criteria.andEqualTo("del_flag", 0);
  600. criteria.andEqualTo("is_active", 1);
  601. List<DictionaryType> typeList = dictionaryTypeService.selectByExample(example);
  602. modelMap.put("typeList", typeList);
  603. if(null == typeId) {
  604. if(null != typeList && typeList.size()>0) {
  605. typeId = typeList.get(0).getId();
  606. modelMap.put("typeId", typeList.get(0).getId());
  607. }
  608. }
  609. PageInfo<DictionaryItem> pageInfo = dictionaryItemService.findPageByType(pageNum, PAGESIZE, keyword,typeId);
  610. modelMap.put("typeId", typeId);
  611. modelMap.put("pageInfo", pageInfo);
  612. modelMap.put("keyword", keyword);
  613. return BASE_SUPER_PATH + "dictionary/dictionary_item_list";
  614. }
  615. /**
  616. * 检验数据类型条目是否存在
  617. * @param
  618. * @param name
  619. * @return
  620. */
  621. @ResponseBody
  622. @GetMapping(value = "/isExistDictionaryItem")
  623. public Boolean isExistDictionaryItem(String id, String name,String value,Integer typeId) throws Exception {
  624. boolean flag = true;
  625. log.debug("检验数据类型条目是否存在参数! id= {}, name= {}", id, name);
  626. DictionaryItem dictionaryItem= dictionaryItemService.getDictionaryItem(name,value,typeId);
  627. if (null != dictionaryItem) {
  628. if (StringUtils.isBlank(id)) {
  629. flag = false;
  630. } else {
  631. if (dictionaryItem.getId() != (Integer.parseInt(id))) {
  632. flag = false;
  633. }
  634. }
  635. }
  636. log.info("检验数据类型条目是否存在结果! flag = {}", flag);
  637. return flag;
  638. }
  639. @GetMapping(value = "/dictionaryItem/add/{typeId}")
  640. public String addDictionaryItemPage(@PathVariable("typeId") int typeId,ModelMap modelMap) {
  641. modelMap.put("typeId", typeId);
  642. return BASE_SUPER_PATH + "dictionary/dictionary_item_add";
  643. }
  644. @GetMapping(value = "/dictionaryItem/edit/{id}")
  645. public String editDictionaryItemPage(@PathVariable("id") int id,ModelMap modelMap) {
  646. DictionaryItem dictionaryItem = dictionaryItemService.findById(id);
  647. modelMap.put("dictionaryItem", dictionaryItem);
  648. return BASE_SUPER_PATH + "dictionary/dictionary_item_edit";
  649. }
  650. @OperationLog(value = "数据字典类型条目保存")
  651. @ResponseBody
  652. @PostMapping(value = "/dictionaryItem/save")
  653. public ResponseMessage saveDictionaryItem(DictionaryItem item) throws Exception {
  654. if(IsTooFrequently()) {
  655. return ResponseMessage.success("操作过于频繁,请稍后再试!");
  656. }
  657. Boolean flag = false;
  658. if (item.getId() == null) {
  659. flag = dictionaryItemService.saveDictionaryItem(item);
  660. } else {
  661. flag = dictionaryItemService.updateDictionaryItem(item);
  662. }
  663. if (flag) {
  664. return ResponseMessage.success("操作成功!");
  665. }
  666. return ResponseMessage.success("操作失败!");
  667. }
  668. @OperationLog(value = "数据字典类型条目删除")
  669. @ResponseBody
  670. @DeleteMapping(value = "/dictionaryItem/delete/{id}")
  671. public ResponseMessage deleteDictionaryItem(@PathVariable("id") int id,ModelMap modelMap) {
  672. DictionaryItem item = dictionaryItemService.findById(id);
  673. if (null == item) {
  674. return ResponseMessage.error("未找到相应的数据类型条目");
  675. }
  676. item.setDel_flag(true);
  677. Boolean flag = dictionaryItemService.updateDictionaryItem(item);
  678. if (flag) {
  679. return ResponseMessage.success("删除成功!");
  680. } else {
  681. return ResponseMessage.error("删除失败!");
  682. }
  683. }
  684. /*********************模板管理**********************/
  685. /**
  686. * 模板管理列表展示
  687. *
  688. * @param pageNum
  689. * @param keyword
  690. * @param modelMap
  691. * @return
  692. * @throws Exception
  693. */
  694. @GetMapping(value = "/templateList")
  695. public String templateList(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, String keyword,
  696. ModelMap modelMap) throws Exception {
  697. PageInfo<Template> pageInfo = templateService.findPage(pageNum, PAGESIZE, keyword);
  698. modelMap.put("pageInfo", pageInfo);
  699. modelMap.put("keyword", keyword);
  700. modelMap.put("fileUrl", setFileUrl());
  701. return BASE_SUPER_PATH + "template/template_list";
  702. }
  703. /**
  704. * 添加模板,如果没有传类型和子类型,默认第一个类型的第一个类别的模板
  705. * @param pageNum
  706. * @param keyword
  707. * @param type_id
  708. * @param item_id
  709. * @param modelMap
  710. * @return
  711. */
  712. @GetMapping(value = "/template/add/{type_id}/{item_id}")
  713. public String addTemplatePage(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,String keyword,
  714. @PathVariable("type_id") Integer type_id,@PathVariable("item_id") Integer item_id,ModelMap modelMap) {
  715. List<DictionaryType> typeList = new ArrayList<DictionaryType>();
  716. List<DictionaryItem> itemList = new ArrayList<DictionaryItem>();
  717. Example example = new Example(DictionaryType.class);
  718. Example.Criteria criteria = example.createCriteria();
  719. criteria.andEqualTo("del_flag", 0);
  720. criteria.andEqualTo("is_template", 1);
  721. typeList = dictionaryTypeService.selectByExample(example);
  722. modelMap.put("typeList", typeList);
  723. if(null == type_id || type_id == 0) {
  724. type_id = typeList.get(0).getId();
  725. }
  726. modelMap.put("type_id", type_id);
  727. if(null != type_id && type_id > 0) {
  728. Example example2 = new Example(DictionaryItem.class);
  729. Example.Criteria criteria2 = example2.createCriteria();
  730. criteria2.andEqualTo("del_flag", 0);
  731. criteria2.andEqualTo("tid", type_id);
  732. criteria2.andEqualTo("is_active", 1);
  733. itemList = dictionaryItemService.selectByExample(example2);
  734. modelMap.put("itemList", itemList);
  735. if(itemList.size()>0) {
  736. if(null == item_id || item_id == 0) {
  737. item_id = itemList.get(0).getId();
  738. }
  739. }
  740. modelMap.put("item_id", item_id);
  741. }
  742. Template templateCondition = new Template();
  743. templateCondition.setType_id(type_id);
  744. templateCondition.setItem_id(item_id);
  745. PageInfo<Template> pageInfo = templateService.findPageByCondition(pageNum, PAGESIZE, keyword,templateCondition);
  746. modelMap.put("pageInfo", pageInfo);
  747. modelMap.put("fileUrl", setFileUrl());
  748. return BASE_SUPER_PATH + "template/template_add";
  749. }
  750. /**
  751. * 修改相应类型的模板,传过来的类型和子类型
  752. * @param pageNum
  753. * @param keyword
  754. * @param type_id
  755. * @param item_id
  756. * @param modelMap
  757. * @return
  758. */
  759. @GetMapping(value = "/template/edit/{id}")
  760. public String editTemplatePage(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,String keyword,
  761. @PathVariable("id") Integer id,ModelMap modelMap) {
  762. Template template = templateService.findById(id);
  763. Integer type_id = template.getType_id();
  764. Integer item_id = template.getItem_id();
  765. List<DictionaryType> typeList = new ArrayList<DictionaryType>();
  766. List<DictionaryItem> itemList = new ArrayList<DictionaryItem>();
  767. DictionaryType type = dictionaryTypeService.findById(type_id);
  768. if(null!=type) {
  769. typeList.add(type);
  770. }
  771. modelMap.put("typeList", typeList);
  772. modelMap.put("type_id", type_id);
  773. if(null != type_id && null != item_id && item_id > 0) {
  774. DictionaryItem item = dictionaryItemService.findById(item_id);
  775. if(null != item) {
  776. itemList.add(item);
  777. }
  778. }
  779. modelMap.put("itemList", itemList);
  780. modelMap.put("item_id", item_id);
  781. Template templateCondition = new Template();
  782. templateCondition.setType_id(type_id);
  783. templateCondition.setItem_id(item_id);
  784. PageInfo<Template> pageInfo = templateService.findPageByCondition(pageNum, PAGESIZE, keyword,templateCondition);
  785. modelMap.put("pageInfo", pageInfo);
  786. modelMap.put("fileUrl", setFileUrl());
  787. return BASE_SUPER_PATH + "template/template_add";
  788. }
  789. /**
  790. * 添加相应类型的模板文件
  791. * @param type_id
  792. * @param item_id
  793. * @param modelMap
  794. * @return
  795. */
  796. @GetMapping(value = "/template/addFile/{type_id}/{item_id}")
  797. public String addTemplateFilePage(@PathVariable("type_id") Integer type_id,@PathVariable("item_id") Integer item_id,ModelMap modelMap) {
  798. modelMap.put("type_id", type_id);
  799. modelMap.put("item_id", item_id);
  800. modelMap.put("fileUrl", setFileUrl());
  801. return BASE_SUPER_PATH + "template/template_file_add";
  802. }
  803. /**
  804. * 编辑模板文件
  805. * @param id
  806. * @param modelMap
  807. * @return
  808. */
  809. @GetMapping(value = "/template/editFile/{id}")
  810. public String editTemplateFilePage(@PathVariable("id") int id,ModelMap modelMap) {
  811. Template template = templateService.findById(id);
  812. templateService.setFile(template);
  813. modelMap.put("template", template);
  814. modelMap.put("fileUrl", setFileUrl());
  815. return BASE_SUPER_PATH + "template/template_file_edit";
  816. }
  817. @OperationLog(value = "模板文件保存")
  818. @ResponseBody
  819. @PostMapping(value = "/template/save")
  820. public ResponseMessage saveTemplate(Template template) throws Exception {
  821. if(IsTooFrequently()) {
  822. return ResponseMessage.success("操作过于频繁,请稍后再试!");
  823. }
  824. Boolean flag = false;
  825. if (template.getId() == null) {
  826. flag = templateService.saveTemplate(template);
  827. } else {
  828. flag = templateService.updateTemplate(template);
  829. }
  830. if (flag) {
  831. return ResponseMessage.success("操作成功!");
  832. }
  833. return ResponseMessage.success("操作失败!");
  834. }
  835. @OperationLog(value = "模板删除")
  836. @ResponseBody
  837. @DeleteMapping(value = "/template/delete/{id}")
  838. public ResponseMessage deleteTemplate(@PathVariable("id") int id,ModelMap modelMap) {
  839. Template template = templateService.findById(id);
  840. if (null == template) {
  841. return ResponseMessage.error("未找到相应的模板");
  842. }
  843. template.setDel_flag(true);
  844. Boolean flag = templateService.updateTemplate(template);
  845. if (flag) {
  846. return ResponseMessage.success("删除成功!");
  847. } else {
  848. return ResponseMessage.error("删除失败!");
  849. }
  850. }
  851. /**
  852. * 检验模板名称是否存在
  853. * @param
  854. * @param name
  855. * @return
  856. */
  857. @ResponseBody
  858. @GetMapping(value = "/isExistTemplateName")
  859. public Boolean isExistTemplateName(String id, String name,Integer typeId, Integer itemId) throws Exception {
  860. boolean flag = true;
  861. log.debug("检验模板名称是否存在参数! id= {}, name= {}", id, name);
  862. Template template= templateService.getTemplateByName(name,typeId,itemId);
  863. if (null != template) {
  864. if (StringUtils.isBlank(id)) {
  865. flag = false;
  866. } else {
  867. if (template.getId() != (Integer.parseInt(id))) {
  868. flag = false;
  869. }
  870. }
  871. }
  872. log.info("检验模板名称是否存在结果! flag = {}", flag);
  873. return flag;
  874. }
  875. /**
  876. * 模板管理列表展示
  877. *
  878. * @param pageNum
  879. * @param modelMap
  880. * @return
  881. * @throws Exception
  882. */
  883. @GetMapping(value = "/industry")
  884. public String industry(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, ModelMap modelMap) {
  885. // PageInfo<Template> pageInfo = templateService.findPage(pageNum, PAGESIZE, null);
  886. PageInfo<AttachmentDto> attachmentPageInfo = attachmentService.findByBusinessType(pageNum, PAGESIZE);
  887. modelMap.put("pageInfo", attachmentPageInfo);
  888. modelMap.put("fileUrl", setFileUrl());
  889. return BASE_SUPER_PATH + "industry/industry_file_list";
  890. }
  891. /**
  892. * 假日信息管理列表展示
  893. *
  894. * @param pageNum
  895. * @param modelMap
  896. * @return
  897. * @throws Exception
  898. */
  899. @OperationLog(value = "读取假日信息列表")
  900. @GetMapping(value = "/holidayList")
  901. public String holidayList(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
  902. ModelMap modelMap) throws Exception {
  903. PageInfo<SysConfig> pageInfo = sysConfigService.findPage(pageNum, PAGESIZE,"year_");
  904. modelMap.put("pageInfo", pageInfo);
  905. modelMap.put("fileUrl", setFileUrl());
  906. return BASE_SUPER_PATH + "holiday/holiday_list";
  907. }
  908. /**
  909. * 添加假日信息
  910. * @param pageNum
  911. * @param modelMap
  912. * @return
  913. */
  914. @OperationLog(value = "新增假日信息")
  915. @GetMapping(value = "/holiday/add")
  916. public String addHolidayPage(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,ModelMap modelMap) {
  917. Map<String,String> mapTemplateFileInfo = holidayExcelTemplateUtil.getTemplateFileInfo();
  918. modelMap.put("templateFileUrl",mapTemplateFileInfo.get("templateFileUrl"));
  919. modelMap.put("templateFileName",mapTemplateFileInfo.get("templateFileName"));
  920. modelMap.put("fileUrl", setFileUrl());
  921. return BASE_SUPER_PATH + "holiday/holiday_add";
  922. }
  923. /**
  924. * 修改相应假日信息
  925. * @param pageNum
  926. * @param modelMap
  927. * @return
  928. */
  929. @OperationLog(value = "编辑假日信息")
  930. @GetMapping(value = "/holiday/edit/{id}")
  931. public String editHolidayPage(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
  932. @PathVariable("id") Integer id,ModelMap modelMap) {
  933. SysConfig holidayInfo = sysConfigService.findById(id);
  934. modelMap.put("id", holidayInfo.getId());
  935. modelMap.put("configName", holidayInfo.getConfigName());
  936. modelMap.put("configKey", holidayInfo.getConfigKey());
  937. modelMap.put("configValue", holidayInfo.getConfigValue());
  938. Map<String,String> mapTemplateFileInfo = holidayExcelTemplateUtil.getTemplateFileInfo();
  939. modelMap.put("templateFileUrl",mapTemplateFileInfo.get("templateFileUrl"));
  940. modelMap.put("templateFileName",mapTemplateFileInfo.get("templateFileName"));
  941. modelMap.put("fileUrl", setFileUrl());
  942. return BASE_SUPER_PATH + "holiday/holiday_add";
  943. }
  944. @OperationLog(value = "节假日信息删除")
  945. @ResponseBody
  946. @DeleteMapping(value = "/holiday/delete/{id}")
  947. public ResponseMessage deleteHoliday(@PathVariable("id") int id,ModelMap modelMap) {
  948. SysConfig ent2Del = sysConfigService.findById(id);
  949. if (null == ent2Del) {
  950. return ResponseMessage.error("未找到相应的假日信息");
  951. }
  952. ent2Del.setDel_flag(true);
  953. sysConfigService.update(ent2Del);
  954. return ResponseMessage.success("删除成功!");
  955. }
  956. @OperationLog(value = "导入假日信息")
  957. @PostMapping(value = "/holiday/import")
  958. public ResponseEntity<String> importHoliday(HttpServletRequest request, @RequestParam("file") MultipartFile file) throws IOException {
  959. Map<String, String> mapParseRet;
  960. String retInfo = "";
  961. if (file.isEmpty()) {
  962. return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("文件不能为空");
  963. }
  964. List<ArrayList<String>> readExcel = new ArrayList<>();
  965. try {
  966. //调用util方法拿到解析的数据集合
  967. readExcel = new ReadExcelUtil().readExcel(file);
  968. // 进一步解析
  969. mapParseRet = HolidayExcelParser.parse(readExcel);
  970. if ("true".equals(mapParseRet.get("valid")))
  971. {
  972. retInfo = mapParseRet.get("data");
  973. }else
  974. {
  975. retInfo = mapParseRet.get("errMsg");
  976. }
  977. } catch (IOException e) {
  978. e.printStackTrace();
  979. }
  980. return ResponseEntity.status(HttpStatus.OK).body(retInfo);
  981. }
  982. @OperationLog(value = "假日信息保存")
  983. @ResponseBody
  984. @PostMapping(value = "/holiday/save")
  985. public ModelMap saveHoliday(@RequestParam(value = "id", defaultValue = "-1") int id,
  986. @RequestParam(value = "configName", defaultValue = "") String configName,
  987. @RequestParam(value = "configKey", defaultValue = "") String configKey,
  988. @RequestParam(value = "configValue", defaultValue = "") String configValue) throws Exception {
  989. ModelMap messagesMap = new ModelMap();
  990. if(IsTooFrequently()) {
  991. messagesMap.put("status", FAILURE);
  992. messagesMap.put("message", "操作过于频繁,请稍后再试!");
  993. return messagesMap;
  994. }
  995. SysConfig ent2Save;
  996. if (-1 < id)
  997. {
  998. ent2Save = sysConfigService.findById(id);
  999. }else{
  1000. ent2Save = new SysConfig();
  1001. }
  1002. ent2Save.setConfigName(configName);
  1003. ent2Save.setConfigKey(configKey);
  1004. ent2Save.setConfigValue(configValue.replace("&quot;","\""));
  1005. ent2Save.setDel_flag(false);
  1006. if (-1 < id)
  1007. {
  1008. sysConfigService.update(ent2Save);
  1009. }else{
  1010. sysConfigService.save(ent2Save);
  1011. }
  1012. messagesMap.put("status", SUCCESS);
  1013. messagesMap.put("message", "保存成功!");
  1014. return messagesMap;
  1015. }
  1016. /**
  1017. * 同一年份假日信息是否存在
  1018. *
  1019. * @param configKey
  1020. * @return
  1021. */
  1022. @OperationLog(value = "同一年份假日信息是否存在")
  1023. @ResponseBody
  1024. @GetMapping(value = "/isExistHoliday")
  1025. public Boolean isExistHoliday(String id, String configKey) throws Exception {
  1026. boolean flag = true;
  1027. log.debug("检验同一年份假日信息是否存在参数! id= {}, configKey= {}", id, configKey);
  1028. SysConfig entExist = sysConfigService.getByKey(configKey);
  1029. if (null != entExist) {
  1030. if (StringUtils.isBlank(id)) {
  1031. flag = false;
  1032. } else {
  1033. if (entExist.getId() != (Integer.parseInt(id))) {
  1034. flag = false;
  1035. }
  1036. }
  1037. }
  1038. log.info("检验假日信息年份是否存在结果! flag = {}", flag);
  1039. return flag;
  1040. }
  1041. }