RegisterApproval.java 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. package platform.modules.government.web;
  2. import com.github.pagehelper.PageInfo;
  3. import org.apache.commons.lang3.StringUtils;
  4. import org.springframework.beans.factory.annotation.Autowired;
  5. import org.springframework.stereotype.Controller;
  6. import org.springframework.ui.ModelMap;
  7. import org.springframework.web.bind.annotation.GetMapping;
  8. import org.springframework.web.bind.annotation.RequestMapping;
  9. import org.springframework.web.bind.annotation.RequestParam;
  10. import org.springframework.web.bind.annotation.ResponseBody;
  11. import platform.common.Constant;
  12. import platform.common.annotation.OperationLog;
  13. import platform.common.base.controller.BaseController;
  14. import platform.common.base.model.DictionaryItem;
  15. import platform.common.base.service.DictionaryItemService;
  16. import platform.common.util.ShiroUtils;
  17. import platform.modules.build.entity.BuildInfo;
  18. import platform.modules.build.entity.Company;
  19. import platform.modules.build.entity.CompanyMaterial;
  20. import platform.modules.build.service.BuildInfoService;
  21. import platform.modules.build.service.CompanyContactService;
  22. import platform.modules.build.service.CompanyMaterialService;
  23. import platform.modules.build.service.CompanyService;
  24. import platform.modules.company.service.CompanyInfoManageService;
  25. import platform.modules.government.dto.CompanyFileDto;
  26. import platform.modules.government.entity.Attachment;
  27. import platform.modules.government.entity.FileDown;
  28. import platform.modules.government.entity.Street;
  29. import platform.modules.government.entity.User;
  30. import platform.modules.government.service.AttachmentService;
  31. import platform.modules.government.service.BuildTypeService;
  32. import platform.modules.government.service.StreetService;
  33. import platform.modules.government.service.UserService;
  34. import platform.modules.sys.entity.Approval;
  35. import platform.modules.sys.service.ApprovalService;
  36. import platform.modules.sys.web.ResponseMessage;
  37. import tk.mybatis.mapper.entity.Example;
  38. import java.util.ArrayList;
  39. import java.util.List;
  40. import java.util.Objects;
  41. @Controller
  42. @RequestMapping("/register")
  43. public class RegisterApproval extends BaseController {
  44. @Autowired
  45. CompanyInfoManageService companyInfoManageService;
  46. @Autowired
  47. CompanyService companyService;
  48. @Autowired
  49. CompanyContactService companyContactService;
  50. @Autowired
  51. private BuildInfoService buildInfoService;
  52. @Autowired
  53. private StreetService streeService;
  54. @Autowired
  55. private DictionaryItemService dictionaryItemService;
  56. @Autowired
  57. private ApprovalService approvalService;
  58. @Autowired
  59. private UserService userService;
  60. @Autowired
  61. private AttachmentService attachmentService;
  62. @Autowired
  63. private CompanyMaterialService companyMaterialService;
  64. @OperationLog(value = "查看企业注册列表")
  65. @RequestMapping("/list")
  66. public String pageInfo(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, ModelMap modelMap, String keyword, Company searchCondition) {
  67. PageInfo<Company> pageInfo = companyInfoManageService.findRegisterPage(pageNum, PAGESIZE, keyword, searchCondition);
  68. modelMap.put("pageInfo", pageInfo);
  69. modelMap.put("keyword", keyword);
  70. modelMap.put("searchCondition", searchCondition);
  71. return "/admin/government/register/index";
  72. }
  73. @RequestMapping("/details")
  74. public String details(Integer id, ModelMap modelMap) {
  75. Company company = companyService.findById(id);
  76. //
  77. if (Objects.equals(company.getIndustry_code(), "Empty")) {
  78. company.setIndustry_code(company.getIndustry_name());
  79. } else {
  80. company.setIndustry_code(dictionaryItemService.findNameByTypeAndValue(Constant.DictionaryType.INDUSTRY_TYPE, company.getIndustry_code()));
  81. }
  82. modelMap.put("company", company);
  83. if (null != company) {
  84. company.setCompanyContacts(companyContactService.findByCompanyId(id));
  85. }
  86. List<Street> streetList = streeService.findList();
  87. modelMap.addAttribute("streetList", streetList);
  88. Example example = new Example(BuildInfo.class);
  89. Example.Criteria criteria = example.createCriteria();
  90. criteria.andEqualTo("del_flag", "0");
  91. //倒序
  92. example.orderBy("create_time").desc();
  93. List<BuildInfo> buildInfo = buildInfoService.selectByExample(example);
  94. modelMap.put("buildInfo", buildInfo);
  95. //查询企业性质
  96. List<DictionaryItem> companyTypeList = dictionaryItemService.findListByTypeName(Constant.DictionaryType.COMPANY_TYPE);
  97. modelMap.put("companyTypeList", companyTypeList);
  98. //查询币种单位数据
  99. List<DictionaryItem> itemList = dictionaryItemService.findListByTypeName(Constant.DictionaryType.CURRENCY_UNIT);
  100. modelMap.put("itemList", itemList);
  101. List<Approval> approvalList = approvalService.getRegisterApprovalList(id);
  102. modelMap.put("approvalList", approvalList);
  103. Example userexample = new Example(User.class);
  104. Example.Criteria usercriteria = userexample.createCriteria();
  105. usercriteria.andEqualTo("del_flag", "0");
  106. usercriteria.andEqualTo("user_type", Constant.UserType.COMPANY);
  107. usercriteria.andEqualTo("company_id", id);
  108. userexample.orderBy("create_time").asc();
  109. List<User> users = userService.selectByExample(userexample);
  110. if (null != users && users.size() > 0) {
  111. modelMap.put("user", users.get(0));
  112. } else {
  113. modelMap.put("user", new User());
  114. }
  115. modelMap.put("companyContract", companyContactService.findByCompanyId(id));
  116. modelMap.put("fileUrl", getFileDownloadUri());
  117. Example materialexample = new Example(CompanyMaterial.class);
  118. Example.Criteria materialcriteria = materialexample.createCriteria();
  119. materialcriteria.andEqualTo("del_flag", "0");
  120. materialcriteria.andEqualTo("company_id", id);
  121. List<CompanyFileDto> companyFileDtoList = new ArrayList<>();
  122. List<CompanyMaterial> materialList = companyMaterialService.selectByExample(materialexample);
  123. List<Attachment> attachments = attachmentService.selectByIdAndBusinessId(Constant.Attachment.COMPANY_MATERIAL, id, null);
  124. if (null != attachments && attachments.size() > 0 && null != materialList && materialList.size() > 0) {
  125. for (Attachment attachment : attachments) {
  126. for (CompanyMaterial material : materialList) {
  127. if (Objects.equals(material.getAttachment_id(), attachment.getId())) {
  128. CompanyFileDto companyFileDto = new CompanyFileDto();
  129. FileDown fileDown = new FileDown(attachment.getId(), attachment.getFile_name(), attachment.getFile_url(), attachment.getDownload_uri());
  130. companyFileDto.setFile_name(material.getFile_name());
  131. companyFileDto.setFileDown(fileDown);
  132. companyFileDtoList.add(companyFileDto);
  133. }
  134. }
  135. }
  136. }
  137. modelMap.put("companyMaterial", companyFileDtoList);
  138. return "/admin/government/register/details";
  139. }
  140. @RequestMapping("/approval")
  141. public String approval(Integer id, ModelMap modelMap) {
  142. Company company = companyService.findById(id);
  143. //
  144. if (Objects.equals(company.getIndustry_code(), "Empty")) {
  145. company.setIndustry_code(company.getIndustry_name());
  146. } else {
  147. company.setIndustry_code(dictionaryItemService.findNameByTypeAndValue(Constant.DictionaryType.INDUSTRY_TYPE, company.getIndustry_code()));
  148. }
  149. modelMap.put("company", company);
  150. if (null != company) {
  151. company.setCompanyContacts(companyContactService.findByCompanyId(id));
  152. }
  153. List<Street> streetList = streeService.findList();
  154. modelMap.addAttribute("streetList", streetList);
  155. Example example = new Example(BuildInfo.class);
  156. Example.Criteria criteria = example.createCriteria();
  157. criteria.andEqualTo("del_flag", "0");
  158. //倒序
  159. example.orderBy("create_time").desc();
  160. List<BuildInfo> buildInfo = buildInfoService.selectByExample(example);
  161. modelMap.put("buildInfo", buildInfo);
  162. //查询企业性质
  163. List<DictionaryItem> companyTypeList = dictionaryItemService.findListByTypeName(Constant.DictionaryType.COMPANY_TYPE);
  164. modelMap.put("companyTypeList", companyTypeList);
  165. //查询币种单位数据
  166. List<DictionaryItem> itemList = dictionaryItemService.findListByTypeName(Constant.DictionaryType.CURRENCY_UNIT);
  167. modelMap.put("itemList", itemList);
  168. List<Approval> approvalList = approvalService.getRegisterApprovalList(id);
  169. modelMap.put("approvalList", approvalList);
  170. Example userexample = new Example(User.class);
  171. Example.Criteria usercriteria = userexample.createCriteria();
  172. usercriteria.andEqualTo("del_flag", "0");
  173. usercriteria.andEqualTo("user_type", Constant.UserType.COMPANY);
  174. usercriteria.andEqualTo("company_id", id);
  175. userexample.orderBy("create_time").asc();
  176. List<User> users = userService.selectByExample(userexample);
  177. if (null != users && users.size() > 0) {
  178. modelMap.put("user", users.get(0));
  179. } else {
  180. modelMap.put("user", new User());
  181. }
  182. modelMap.put("companyContract", companyContactService.findByCompanyId(id));
  183. modelMap.put("fileUrl", getFileDownloadUri());
  184. Example materialexample = new Example(CompanyMaterial.class);
  185. Example.Criteria materialcriteria = materialexample.createCriteria();
  186. materialcriteria.andEqualTo("del_flag", "0");
  187. materialcriteria.andEqualTo("company_id", id);
  188. List<CompanyFileDto> companyFileDtoList = new ArrayList<>();
  189. List<CompanyMaterial> materialList = companyMaterialService.selectByExample(materialexample);
  190. List<Attachment> attachments = attachmentService.selectByIdAndBusinessId(Constant.Attachment.COMPANY_MATERIAL, id, null);
  191. if (null != attachments && attachments.size() > 0 && null != materialList && materialList.size() > 0) {
  192. for (Attachment attachment : attachments) {
  193. for (CompanyMaterial material : materialList) {
  194. if (Objects.equals(material.getAttachment_id(), attachment.getId())) {
  195. CompanyFileDto companyFileDto = new CompanyFileDto();
  196. FileDown fileDown = new FileDown(attachment.getId(), attachment.getFile_name(), attachment.getFile_url(), attachment.getDownload_uri());
  197. companyFileDto.setFile_name(material.getFile_name());
  198. companyFileDto.setFileDown(fileDown);
  199. companyFileDtoList.add(companyFileDto);
  200. }
  201. }
  202. }
  203. }
  204. modelMap.put("companyMaterial", companyFileDtoList);
  205. return "/admin/government/register/approval";
  206. }
  207. @OperationLog(value = "企业注册审核")
  208. @RequestMapping("/submit")
  209. @ResponseBody
  210. public ResponseMessage submit(Integer type, Integer id, String approval_comment) {
  211. try {
  212. if (IsTooFrequently()) {
  213. return ResponseMessage.error("操作过于频繁,请稍后再试!");
  214. }
  215. return companyService.approval(type, id, approval_comment);
  216. } catch (Exception e) {
  217. e.printStackTrace();
  218. return ResponseMessage.error("审核失败");
  219. }
  220. }
  221. @OperationLog(value = "查看企业注册审核列表")
  222. @RequestMapping("/already_list")
  223. public String already_pageInfo(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, ModelMap modelMap, String keyword, Company searchCondition) {
  224. PageInfo<Company> pageInfo = companyInfoManageService.findAlready_RegisterPage(pageNum, PAGESIZE, keyword, searchCondition);
  225. modelMap.put("pageInfo", pageInfo);
  226. modelMap.put("keyword", keyword);
  227. modelMap.put("searchCondition", searchCondition);
  228. return "/admin/government/register/index1";
  229. }
  230. /**
  231. * 检验手机号是否存在
  232. *
  233. * @param mobile
  234. * @return
  235. */
  236. @ResponseBody
  237. @GetMapping(value = "/isExistMobile")
  238. public Boolean isExistMobile(String id, String mobile) throws Exception {
  239. boolean flag = true;
  240. log.debug("检验手机号是否存在参数! id= {}, mobile= {}", id, mobile);
  241. User record = userService.findByMobile(mobile);
  242. if (null != record) {
  243. if (StringUtils.isBlank(id)) {
  244. flag = false;
  245. } else {
  246. if (record.getId() != (Integer.parseInt(id))) {
  247. flag = false;
  248. }
  249. }
  250. }
  251. log.info("检验用户名是否存在结果! flag = {}", flag);
  252. return flag;
  253. }
  254. /**
  255. * 检验用户名是否存在
  256. *
  257. * @param nick_name
  258. * @return
  259. */
  260. @ResponseBody
  261. @GetMapping(value = "/isExist")
  262. public Boolean isExist(String id, String nick_name) throws Exception {
  263. boolean flag = true;
  264. log.debug("检验用户名是否存在参数! id= {}, username= {}", id, nick_name);
  265. User record = userService.findByUserName(nick_name);
  266. if (null != record) {
  267. if (StringUtils.isBlank(id)) {
  268. flag = false;
  269. } else {
  270. if (record.getId() != (Integer.parseInt(id))) {
  271. flag = false;
  272. }
  273. }
  274. }
  275. log.info("检验用户名是否存在结果! flag = {}", flag);
  276. return flag;
  277. }
  278. /**
  279. * 检验组织机构代码是否存在
  280. *
  281. * @param organization_code
  282. * @return
  283. */
  284. /*@ResponseBody
  285. @GetMapping(value = "/isExistOrgCode")
  286. public Boolean isExistOrgCode(String id, String organization_code) throws Exception {
  287. boolean flag = true;
  288. log.debug("检验组织机构代码是否存在参数! id= {}, username= {}", id, organization_code);
  289. Company record = companyService.findByOrgCode(organization_code);
  290. if (null != record) {
  291. if (StringUtils.isBlank(id)) {
  292. flag = false;
  293. } else {
  294. if (record.getId() != (Integer.parseInt(id))) {
  295. flag = false;
  296. }
  297. }
  298. }
  299. log.info("检验组织机构代码是否存在结果! flag = {}", flag);
  300. return flag;
  301. }*/
  302. }