package platform.modules.government.web; import com.github.pagehelper.PageInfo; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import platform.common.Constant; import platform.common.annotation.OperationLog; import platform.common.base.controller.BaseController; import platform.common.base.model.DictionaryItem; import platform.common.base.service.DictionaryItemService; import platform.common.util.ShiroUtils; import platform.modules.build.entity.BuildInfo; import platform.modules.build.entity.Company; import platform.modules.build.entity.CompanyMaterial; import platform.modules.build.service.BuildInfoService; import platform.modules.build.service.CompanyContactService; import platform.modules.build.service.CompanyMaterialService; import platform.modules.build.service.CompanyService; import platform.modules.company.service.CompanyInfoManageService; import platform.modules.government.dto.CompanyFileDto; import platform.modules.government.entity.Attachment; import platform.modules.government.entity.FileDown; import platform.modules.government.entity.Street; import platform.modules.government.entity.User; import platform.modules.government.service.AttachmentService; import platform.modules.government.service.BuildTypeService; import platform.modules.government.service.StreetService; import platform.modules.government.service.UserService; import platform.modules.sys.entity.Approval; import platform.modules.sys.service.ApprovalService; import platform.modules.sys.web.ResponseMessage; import tk.mybatis.mapper.entity.Example; import java.util.ArrayList; import java.util.List; import java.util.Objects; @Controller @RequestMapping("/register") public class RegisterApproval extends BaseController { @Autowired CompanyInfoManageService companyInfoManageService; @Autowired CompanyService companyService; @Autowired CompanyContactService companyContactService; @Autowired private BuildInfoService buildInfoService; @Autowired private StreetService streeService; @Autowired private DictionaryItemService dictionaryItemService; @Autowired private ApprovalService approvalService; @Autowired private UserService userService; @Autowired private AttachmentService attachmentService; @Autowired private CompanyMaterialService companyMaterialService; @OperationLog(value = "查看企业注册列表") @RequestMapping("/list") public String pageInfo(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, ModelMap modelMap, String keyword, Company searchCondition) { PageInfo pageInfo = companyInfoManageService.findRegisterPage(pageNum, PAGESIZE, keyword, searchCondition); modelMap.put("pageInfo", pageInfo); modelMap.put("keyword", keyword); modelMap.put("searchCondition", searchCondition); return "/admin/government/register/index"; } @RequestMapping("/details") public String details(Integer id, ModelMap modelMap) { Company company = companyService.findById(id); // if (Objects.equals(company.getIndustry_code(), "Empty")) { company.setIndustry_code(company.getIndustry_name()); } else { company.setIndustry_code(dictionaryItemService.findNameByTypeAndValue(Constant.DictionaryType.INDUSTRY_TYPE, company.getIndustry_code())); } modelMap.put("company", company); if (null != company) { company.setCompanyContacts(companyContactService.findByCompanyId(id)); } List streetList = streeService.findList(); modelMap.addAttribute("streetList", streetList); Example example = new Example(BuildInfo.class); Example.Criteria criteria = example.createCriteria(); criteria.andEqualTo("del_flag", "0"); //倒序 example.orderBy("create_time").desc(); List buildInfo = buildInfoService.selectByExample(example); modelMap.put("buildInfo", buildInfo); //查询企业性质 List companyTypeList = dictionaryItemService.findListByTypeName(Constant.DictionaryType.COMPANY_TYPE); modelMap.put("companyTypeList", companyTypeList); //查询币种单位数据 List itemList = dictionaryItemService.findListByTypeName(Constant.DictionaryType.CURRENCY_UNIT); modelMap.put("itemList", itemList); List approvalList = approvalService.getRegisterApprovalList(id); modelMap.put("approvalList", approvalList); Example userexample = new Example(User.class); Example.Criteria usercriteria = userexample.createCriteria(); usercriteria.andEqualTo("del_flag", "0"); usercriteria.andEqualTo("user_type", Constant.UserType.COMPANY); usercriteria.andEqualTo("company_id", id); userexample.orderBy("create_time").asc(); List users = userService.selectByExample(userexample); if (null != users && users.size() > 0) { modelMap.put("user", users.get(0)); } else { modelMap.put("user", new User()); } modelMap.put("companyContract", companyContactService.findByCompanyId(id)); modelMap.put("fileUrl", getFileDownloadUri()); Example materialexample = new Example(CompanyMaterial.class); Example.Criteria materialcriteria = materialexample.createCriteria(); materialcriteria.andEqualTo("del_flag", "0"); materialcriteria.andEqualTo("company_id", id); List companyFileDtoList = new ArrayList<>(); List materialList = companyMaterialService.selectByExample(materialexample); List attachments = attachmentService.selectByIdAndBusinessId(Constant.Attachment.COMPANY_MATERIAL, id, null); if (null != attachments && attachments.size() > 0 && null != materialList && materialList.size() > 0) { for (Attachment attachment : attachments) { for (CompanyMaterial material : materialList) { if (Objects.equals(material.getAttachment_id(), attachment.getId())) { CompanyFileDto companyFileDto = new CompanyFileDto(); FileDown fileDown = new FileDown(attachment.getId(), attachment.getFile_name(), attachment.getFile_url(), attachment.getDownload_uri()); companyFileDto.setFile_name(material.getFile_name()); companyFileDto.setFileDown(fileDown); companyFileDtoList.add(companyFileDto); } } } } modelMap.put("companyMaterial", companyFileDtoList); return "/admin/government/register/details"; } @RequestMapping("/approval") public String approval(Integer id, ModelMap modelMap) { Company company = companyService.findById(id); // if (Objects.equals(company.getIndustry_code(), "Empty")) { company.setIndustry_code(company.getIndustry_name()); } else { company.setIndustry_code(dictionaryItemService.findNameByTypeAndValue(Constant.DictionaryType.INDUSTRY_TYPE, company.getIndustry_code())); } modelMap.put("company", company); if (null != company) { company.setCompanyContacts(companyContactService.findByCompanyId(id)); } List streetList = streeService.findList(); modelMap.addAttribute("streetList", streetList); Example example = new Example(BuildInfo.class); Example.Criteria criteria = example.createCriteria(); criteria.andEqualTo("del_flag", "0"); //倒序 example.orderBy("create_time").desc(); List buildInfo = buildInfoService.selectByExample(example); modelMap.put("buildInfo", buildInfo); //查询企业性质 List companyTypeList = dictionaryItemService.findListByTypeName(Constant.DictionaryType.COMPANY_TYPE); modelMap.put("companyTypeList", companyTypeList); //查询币种单位数据 List itemList = dictionaryItemService.findListByTypeName(Constant.DictionaryType.CURRENCY_UNIT); modelMap.put("itemList", itemList); List approvalList = approvalService.getRegisterApprovalList(id); modelMap.put("approvalList", approvalList); Example userexample = new Example(User.class); Example.Criteria usercriteria = userexample.createCriteria(); usercriteria.andEqualTo("del_flag", "0"); usercriteria.andEqualTo("user_type", Constant.UserType.COMPANY); usercriteria.andEqualTo("company_id", id); userexample.orderBy("create_time").asc(); List users = userService.selectByExample(userexample); if (null != users && users.size() > 0) { modelMap.put("user", users.get(0)); } else { modelMap.put("user", new User()); } modelMap.put("companyContract", companyContactService.findByCompanyId(id)); modelMap.put("fileUrl", getFileDownloadUri()); Example materialexample = new Example(CompanyMaterial.class); Example.Criteria materialcriteria = materialexample.createCriteria(); materialcriteria.andEqualTo("del_flag", "0"); materialcriteria.andEqualTo("company_id", id); List companyFileDtoList = new ArrayList<>(); List materialList = companyMaterialService.selectByExample(materialexample); List attachments = attachmentService.selectByIdAndBusinessId(Constant.Attachment.COMPANY_MATERIAL, id, null); if (null != attachments && attachments.size() > 0 && null != materialList && materialList.size() > 0) { for (Attachment attachment : attachments) { for (CompanyMaterial material : materialList) { if (Objects.equals(material.getAttachment_id(), attachment.getId())) { CompanyFileDto companyFileDto = new CompanyFileDto(); FileDown fileDown = new FileDown(attachment.getId(), attachment.getFile_name(), attachment.getFile_url(), attachment.getDownload_uri()); companyFileDto.setFile_name(material.getFile_name()); companyFileDto.setFileDown(fileDown); companyFileDtoList.add(companyFileDto); } } } } modelMap.put("companyMaterial", companyFileDtoList); return "/admin/government/register/approval"; } @OperationLog(value = "企业注册审核") @RequestMapping("/submit") @ResponseBody public ResponseMessage submit(Integer type, Integer id, String approval_comment) { try { if (IsTooFrequently()) { return ResponseMessage.error("操作过于频繁,请稍后再试!"); } return companyService.approval(type, id, approval_comment); } catch (Exception e) { e.printStackTrace(); return ResponseMessage.error("审核失败"); } } @OperationLog(value = "查看企业注册审核列表") @RequestMapping("/already_list") public String already_pageInfo(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, ModelMap modelMap, String keyword, Company searchCondition) { PageInfo pageInfo = companyInfoManageService.findAlready_RegisterPage(pageNum, PAGESIZE, keyword, searchCondition); modelMap.put("pageInfo", pageInfo); modelMap.put("keyword", keyword); modelMap.put("searchCondition", searchCondition); return "/admin/government/register/index1"; } /** * 检验手机号是否存在 * * @param mobile * @return */ @ResponseBody @GetMapping(value = "/isExistMobile") public Boolean isExistMobile(String id, String mobile) throws Exception { boolean flag = true; log.debug("检验手机号是否存在参数! id= {}, mobile= {}", id, mobile); User record = userService.findByMobile(mobile); if (null != record) { if (StringUtils.isBlank(id)) { flag = false; } else { if (record.getId() != (Integer.parseInt(id))) { flag = false; } } } log.info("检验用户名是否存在结果! flag = {}", flag); return flag; } /** * 检验用户名是否存在 * * @param nick_name * @return */ @ResponseBody @GetMapping(value = "/isExist") public Boolean isExist(String id, String nick_name) throws Exception { boolean flag = true; log.debug("检验用户名是否存在参数! id= {}, username= {}", id, nick_name); User record = userService.findByUserName(nick_name); if (null != record) { if (StringUtils.isBlank(id)) { flag = false; } else { if (record.getId() != (Integer.parseInt(id))) { flag = false; } } } log.info("检验用户名是否存在结果! flag = {}", flag); return flag; } /** * 检验组织机构代码是否存在 * * @param organization_code * @return */ /*@ResponseBody @GetMapping(value = "/isExistOrgCode") public Boolean isExistOrgCode(String id, String organization_code) throws Exception { boolean flag = true; log.debug("检验组织机构代码是否存在参数! id= {}, username= {}", id, organization_code); Company record = companyService.findByOrgCode(organization_code); if (null != record) { if (StringUtils.isBlank(id)) { flag = false; } else { if (record.getId() != (Integer.parseInt(id))) { flag = false; } } } log.info("检验组织机构代码是否存在结果! flag = {}", flag); return flag; }*/ }