| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672 |
- package platform.modules.home;
- import com.alibaba.fastjson.JSONObject;
- import com.aliyuncs.exceptions.ClientException;
- import com.xiaoleilu.hutool.crypto.SecureUtil;
- import org.apache.commons.collections.CollectionUtils;
- import org.apache.commons.lang3.StringEscapeUtils;
- import org.apache.commons.lang3.StringUtils;
- import org.apache.shiro.authc.*;
- import org.apache.shiro.subject.Subject;
- import org.springframework.beans.BeanUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.beans.factory.annotation.Value;
- import org.springframework.boot.autoconfigure.AutoConfigurationPackage;
- import org.springframework.stereotype.Controller;
- import org.springframework.ui.ModelMap;
- import org.springframework.web.bind.annotation.*;
- 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.exception.BaseException;
- import platform.common.util.*;
- import platform.modules.api.dto.SyncUserDto;
- import platform.modules.api.service.SkyImageApiService;
- import platform.modules.build.DTO.HomeSlideDto;
- import platform.modules.build.entity.Company;
- import platform.modules.build.entity.CompanyContact;
- 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.carrier.entity.Building;
- import platform.modules.carrier.service.BuildingService;
- import platform.modules.carrier.service.ParkService;
- import platform.modules.company.service.CompanyInfoManageService;
- import platform.modules.company.service.ProjectApplicationService;
- import platform.modules.company.service.StockLandService;
- import platform.modules.government.dao.AttachmentDao;
- import platform.modules.government.dto.ParamRegistration;
- import platform.modules.government.entity.*;
- import platform.modules.government.service.*;
- import platform.modules.home.request.FindRequest;
- import platform.modules.home.response.FindResponse;
- import platform.modules.home.response.FindResponseProject;
- import platform.modules.home.response.ListResponse;
- import platform.modules.home.service.WxMicroappService;
- import platform.modules.sys.entity.ActivityDetail;
- import platform.modules.sys.entity.ActivityFavourite;
- import platform.modules.sys.entity.ActivityRegistration;
- import platform.modules.sys.entity.Approval;
- import platform.modules.sys.entity.Group;
- import platform.modules.sys.entity.UserGroup;
- import platform.modules.sys.service.ActivityFavouriteService;
- import platform.modules.sys.service.ActivityRegistrationService;
- import platform.modules.sys.service.ActivityService;
- import platform.modules.sys.service.ApprovalService;
- import platform.modules.sys.service.*;
- import platform.modules.sys.shiro.UsernamePasswordToken;
- import platform.modules.sys.web.ResponseMessage;
- import sun.misc.BASE64Decoder;
- import javax.annotation.Resource;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import javax.servlet.http.HttpSession;
- import java.io.BufferedInputStream;
- import java.io.File;
- import java.io.FileInputStream;
- import java.io.OutputStream;
- import java.util.*;
- import static platform.common.Constant.HEAD_SESSION_STATUS_KEY;
- import static platform.common.Constant.HEAD_SESSION_STATUS_VALUE;
- @Controller
- @RequestMapping(value = "/home")
- public class HomeController extends BaseController {
- private static String profiles;
- @Value("${spring.profiles}")
- public void setProfiles(String param) {
- this.profiles = param;
- }
- @Autowired
- private ContentService contentService;
- @Autowired
- private CompanyService companyService;
- @Autowired
- private NavigationService navigationService;
- @Autowired
- private SlidesService slidesService;
- @Autowired
- private FriendLinkService friendLinkService;
- @Autowired
- private LogoService logoService;
- @Autowired
- private AttachmentService attachmentService;
- @Autowired
- private BuildInfoService buildInfoService;
- @Autowired
- StreetService streetService;
- @Autowired
- DictionaryItemService dictionaryItemService;
- @Autowired
- CompanyInfoManageService companyInfoManageService;
- @Autowired
- CompanyContactService companyContactService;
- @Autowired
- StockLandService stockLandService;
- @Autowired
- ApprovalService approvalService;
- @Autowired
- UserService userService;
- @Autowired
- private ActivityService activityService;
- @Autowired
- private ActivityFavouriteService activityFavouriteService;
- @Autowired
- private ActivityRegistrationService activityRegistrationService;
- @Autowired
- private ProjectDeclarationService projectDeclarationService;
- @Autowired
- private ProjectApplicationService projectApplicationService;
- @Autowired
- private ProjectFillingDeclarationService projectFillingDeclarationService;
- @Resource
- private AttachmentDao attachmentDao;
- @Autowired
- private CompanyMaterialService companyMaterialService;
- @Autowired
- private VerificationCodeUtil verificationCodeUtil;
- @Autowired
- private WaitToDoService waitToDoService;
- @Autowired
- private StatisticsService statisticsService;
- @Autowired
- private ProjectProvincesDeclarationService projectProvincesDeclarationService;
- @Autowired
- private ProjectServiceTypeService projectServiceTypeService;
- @Autowired
- private ProjectIntelligentDeclarationService projectIntelligentDeclarationService;
- @Autowired
- private SkyImageApiService skyImageApiService;
- @Autowired
- private ParkService parkService;
- @Autowired
- private BuildingService buildingService;
- @Autowired
- private WxMicroappService wxMicroappService;
- // @GetMapping(value = "")
- // public String homePage(ModelMap modelMap) throws Exception {
- // //获取幻灯片
- // List<HomeSlideDto> slideDtoList = slidesService.showHomeSlides();
- //
- // modelMap.put("slideDtoList", slideDtoList);
- // // 获取导航
- // List<Navigation> navigations = navigationService.findContents();
- // modelMap.put("navigations", navigations);
- // this.commonObject(modelMap, false);
- // modelMap.put("buildCount", buildInfoService.countAllBuild());
- // modelMap.put("companyCount", companyService.countAllCompany());
- // modelMap.put("contentCount", contentService.countContent());
- // modelMap.put("contentServices", contentService.findContentsByNavigationId());
- //
- // //服务联盟
- // Navigation nav = navigationService.findByName(Constant.Navigation_Name.SERVICE);
- // FindRequest request = new FindRequest();
- // request.setId(nav.getId());
- // modelMap.put("servicesCount", contentService.findContentsCount(request));
- // //专题活动
- // modelMap.put("activityCount", activityService.getAllActivityCount());
- // //项目申报
- // modelMap.put("projectCount", projectApplicationService.getPassedProjectTotalNum());
- // return BASE_HOME_PATH + "html/home";
- // }
- @GetMapping(value = "")
- public String homePage() {
- // LocalStorage.removeItem("INDUSTRIAL_CARRIER");
- return "redirect:/index";
- }
- @GetMapping(value = "/informList/{id}")
- public String informList(@PathVariable Integer id, ModelMap modelMap) throws Exception {
- try {
- // 获取导航
- modelMap.put("navigation_id", id);
- modelMap.put("navigation_name", navigationService.getName(id));
- this.commonObject(modelMap, true);
- } catch (Exception e) {
- e.printStackTrace();
- }
- String navigationName = navigationService.getName(id);
- if (navigationName.equals(Constant.Navigation_Name.POLICY)) {
- return BASE_HOME_PATH + "html/policy/policyIndex";
- }
- return BASE_HOME_PATH + "html/contents";
- }
- @GetMapping(value = "/unionCompany")
- public String unionCompany(ModelMap modelMap) throws Exception {
- Navigation navigation = navigationService.findById(2);
- if (null != navigation) {
- List<Attachment> attachments = attachmentService.selectByIdAndBusinessId(Constant.Attachment.DH, navigation.getId(), null);
- if (null != attachments && attachments.size() > 0) {
- FileDown fileDown = new FileDown(attachments.get(0).getId(), attachments.get(0).getFile_name(), attachments.get(0).getFile_url(), attachments.get(0).getDownload_uri());
- navigation.setFileDown(fileDown);
- }
- }
- modelMap.put("navigation", navigation);
- modelMap.put("contentServices", contentService.findContentsByNavigationId());
- this.commonObject(modelMap, true);
- return BASE_HOME_PATH + "html/unionCompany";
- }
- @PostMapping(value = "/contentList")
- @ResponseBody
- public ResponseMessage findContents(FindRequest request) throws Exception {
- FindResponse response = new FindResponse();
- try {
- response = contentService.findContents(request);
- } catch (Exception e) {
- e.printStackTrace();
- }
- return ResponseMessage.success("查询成功", response);
- }
- @PostMapping(value = "/activityList")
- @ResponseBody
- public ResponseMessage findActivity(FindRequest request) throws Exception {
- ListResponse response = new ListResponse();
- response.setFile_url(setFileUrl());
- try {
- response = activityService.findContents(request);
- List<DictionaryItem> activityTypeList = dictionaryItemService.findListByTypeName(Constant.DictionaryType.ACTIVITY_TYPE);
- response.setTypeList(activityTypeList);
- } catch (Exception e) {
- e.printStackTrace();
- }
- return ResponseMessage.success("查询成功", response);
- }
- @PostMapping(value = "/projectList")
- @ResponseBody
- public ResponseMessage findProject(FindRequest request) {
- FindResponseProject response = new FindResponseProject();
- try {
- response = projectDeclarationService.findProejctsOnHome(request);
- List<DictionaryItem> projectSourceList = dictionaryItemService.findListByTypeName(Constant.DictionaryType.PROJECT_SOURCE);
- List<DictionaryItem> projectStatusList = dictionaryItemService.findListByTypeName(Constant.DictionaryType.PROJECT_STATUS);
- response.setProjectSourceList(projectSourceList);
- response.setProjectStatusList(projectStatusList);
- } catch (Exception e) {
- e.printStackTrace();
- }
- return ResponseMessage.success("查询成功", response);
- }
- @GetMapping(value = "/logout")
- public String logout(ModelMap modelMap) throws Exception {
- ShiroUtils.logout();
- this.commonObject(modelMap, true);
- return "redirect:/" + BASE_HOME_PATH;
- }
- /**
- * 跳转到内容查看页面
- *
- * @return
- */
- @GetMapping(value = "/contentDetail/{id}")
- public String check(@PathVariable("id") int id, ModelMap modelMap) throws Exception {
- log.info("跳转到内容查看页面!id = {}", id);
- Content content = contentService.findById(id);
- if (null == content) {
- modelMap.put("status", FAILURE);
- modelMap.put("message", "内容不存在!");
- return BASE_HOME_PATH + "html/informAnnouncement";
- }
- if (null == content.getBrowse_count()) {
- content.setBrowse_count(0);
- }
- List<Attachment> files = attachmentService.selectByIdAndBusinessId(Constant.Attachment.CONTENT_FILE, content.getId(), null);
- if (null != files && files.size() > 0) {
- FileDown fileDown = new FileDown(files.get(0).getId(), files.get(0).getFile_name(), files.get(0).getFile_url(), files.get(0).getDownload_uri());
- content.setAddFileDown(fileDown);
- }
- content.setContent(StringEscapeUtils.unescapeHtml4(content.getContent()));
- //更新数量
- content.setBrowse_count(content.getBrowse_count() + 1);
- contentService.updateSelective(content);
- modelMap.put("content", content);
- // 获取导航
- modelMap.put("navigation_id", content.getNavigation_id());
- modelMap.put("navigation_name", navigationService.getName(content.getNavigation_id()));
- modelMap.addAttribute("navigationList", navigationService.findList());
- this.commonObject(modelMap, true);
- return BASE_HOME_PATH + "html/contentDetail";
- }
- /**
- * 跳转到内容查看页面
- *
- * @return
- */
- @GetMapping(value = "/activityDetail/{id}")
- public String activityDetail(@PathVariable("id") int id, ModelMap modelMap) throws Exception {
- log.info("跳转到内容查看页面!id = {}", id);
- ActivityDetail activityDetail = activityService.findOne(id + "");
- Content content = new Content();
- content.setTitle("");
- content.setCreate_time("");
- content.setBrowse_count(0);
- content.setResource("");
- content.setCreate_name("");
- if (!Objects.equals(activityDetail, null)) {
- content.setContent(activityDetail.getContent());
- }
- content.setTitle(id + "");
- modelMap.put("content", content);
- modelMap.addAttribute("activity", activityDetail);
- // 获取导航
- modelMap.put("navigation_id", 1);
- modelMap.put("navigation_name", navigationService.getName(1));
- modelMap.addAttribute("navigationList", navigationService.findList());
- this.commonObject(modelMap, true);
- return BASE_HOME_PATH + "html/contentDetail";
- }
- /**
- * 跳转到活动日历
- *
- * @return
- */
- @GetMapping(value = "/calendar")
- public String activityCalendar(ModelMap modelMap) throws Exception {
- log.info("跳转到活动日历");
- Content content = new Content();
- content.setTitle("");
- content.setCreate_time("");
- content.setBrowse_count(0);
- content.setResource("");
- content.setCreate_name("");
- modelMap.put("content", content);
- // 获取导航
- modelMap.put("navigation_id", 1);
- modelMap.put("navigation_name", navigationService.getName(1));
- modelMap.addAttribute("navigationList", navigationService.findList());
- this.commonObject(modelMap, true);
- return BASE_HOME_PATH + "html/calendar";
- }
- /**
- * 跳转到内容查看页面
- *
- * @return
- */
- @ResponseBody
- @GetMapping(value = "/activityDetails/{id}")
- public ResponseMessage getActivityDetail(@PathVariable("id") int id, ModelMap modelMap) throws Exception {
- log.info("跳转到内容查看页面!id = {}", id);
- ActivityDetail activityDetail = activityService.findOne(id + "");
- activityService.increment(id + "");
- List<ActivityRegistration> registrationList = activityRegistrationService.findRegistrationList(id);
- int num = 0;
- String quota = activityDetail.getActivity_quota();
- if (StringUtils.isBlank(quota)) quota = "0";
- for (ActivityRegistration activityRegistration : registrationList) {
- if (Objects.equals(activityRegistration.getReview_state(), "1")) {
- num++;
- }
- }
- int remain = Integer.parseInt(quota) - num;
- if (remain < 0) {
- remain = 0;
- }
- activityDetail.setActivity_remain(remain + "");
- List<Attachment> attachments = attachmentService.selectByIdAndBusinessId(Constant.Attachment.ACTIVITY, activityDetail.getId(), null);
- if (null != attachments && attachments.size() > 0) {
- FileDown fileDown = new FileDown(attachments.get(0).getId(), attachments.get(0).getFile_name(), attachments.get(0).getFile_url(), attachments.get(0).getDownload_uri());
- activityDetail.setFileDown(fileDown);
- }
- return ResponseMessage.success("查询成功!", activityDetail);
- }
- /**
- * 获取已报名的用户
- *
- * @return
- */
- @ResponseBody
- @GetMapping(value = "/getRegUsers")
- public ResponseMessage getRegUsers(@RequestParam("activity_id") String activity_id, ModelMap modelMap) throws Exception {
- log.info("获取已报名的用户!");
- return ResponseMessage.success("查询成功!", activityRegistrationService.getCurrRegUsers(activity_id));
- }
- /**
- * 查询是否收藏
- *
- * @return
- */
- @ResponseBody
- @GetMapping(value = "/isFavourite/{id}")
- public ResponseMessage isFavourite(@PathVariable("id") int id, ModelMap modelMap) throws Exception {
- log.info("查询是否收藏!id = {}", id);
- if (!ShiroUtils.isLogin()) return ResponseMessage.success("请先登录!", 2);
- ActivityFavourite activityFavourite = activityFavouriteService.selectByActivityIdAndUserId(id + "", ShiroUtils.getUserId() + "");
- if (Objects.equals(activityFavourite, null)) return ResponseMessage.success("查询成功!", 1);
- return ResponseMessage.success("查询成功!", 0);
- }
- /**
- * 添加收藏
- *
- * @return
- */
- @OperationLog(value = "收藏活动")
- @ResponseBody
- @GetMapping(value = "/addFavourite/{id}")
- public ResponseMessage addFavourite(@PathVariable("id") int id, ModelMap modelMap) throws Exception {
- log.info("查询是否收藏!id = {}", id);
- if (!ShiroUtils.isLogin()) return ResponseMessage.success("请先登录!", 2);
- ActivityFavourite activityFavourite = new ActivityFavourite();
- activityFavourite.setActivity_id(id);
- int count = activityFavouriteService.saveActivityFavourite(activityFavourite);
- if (count > 0) return ResponseMessage.success("收藏成功!");
- return ResponseMessage.success("收藏失败!");
- }
- /**
- * 取消收藏
- *
- * @return
- */
- @OperationLog(value = "取消收藏活动")
- @ResponseBody
- @GetMapping(value = "/removeFavourite/{id}")
- public ResponseMessage removeFavourite(@PathVariable("id") int id, ModelMap modelMap) throws Exception {
- log.info("查询是否收藏!id = {}", id);
- boolean b = activityFavouriteService.deleteByActivityIdAndUserId(id + "", ShiroUtils.getUserId() + "");
- if (b) return ResponseMessage.success("取消收藏成功!");
- return ResponseMessage.success("取消收藏失败!");
- }
- /**
- * 检查是否登录
- *
- * @return
- */
- @ResponseBody
- @GetMapping(value = "/checkLogin")
- public ResponseMessage checkLogin(ModelMap modelMap) throws Exception {
- log.info("检查是否登录");
- if (!ShiroUtils.isLogin()) {
- modelMap.put("isLogin", false);
- return ResponseMessage.success("请先登录!", false);
- }
- modelMap.put("isLogin", true);
- modelMap.put("userType", ShiroUtils.getUserType());
- modelMap.put("userName", ShiroUtils.getNickName());
- return ResponseMessage.success("", modelMap);
- }
- /**
- * 活动报名
- *
- * @return
- */
- @OperationLog(value = "报名活动")
- @PostMapping(value = "/joinActivity")
- @ResponseBody
- public ResponseMessage joinActivity(@RequestBody ParamRegistration paramRegistration) throws Exception {
- log.info("活动报名");
- Integer id = paramRegistration.getRegistrationList().get(0).getActivity_id();
- Integer userId = paramRegistration.getRegistrationList().get(0).getUser_id();
- ActivityDetail activityDetail = activityService.findById(id);
- String quota = activityDetail.getActivity_quota();
- String isReview = activityDetail.getIs_review();
- int registrationNumber = 0;
- if (!Objects.equals(quota, null) && !Objects.equals(quota, "")) {
- //名额有限
- if (Objects.equals(isReview, "1")) {
- //需要审核
- //已报名人数
- registrationNumber = activityRegistrationService.getActivityRegistrationNumber(id);
- if (registrationNumber >= Integer.parseInt(quota)) {
- return ResponseMessage.success("名额不足,仅剩" + (Integer.parseInt(quota) - registrationNumber) + "个名额,请修改人数!", false);
- }
- }
- }
- List<ActivityRegistration> registrationList = paramRegistration.getRegistrationList();
- if (!CollectionUtils.isEmpty(registrationList)) {
- activityRegistrationService.deleteOldCancelRegist(String.valueOf(id), null, String.valueOf(userId));
- for (ActivityRegistration registration : registrationList) {
- if (registration.getId() == null) {
- activityRegistrationService.saveActivityRegistration(registration);
- }
- }
- List<User> pusers = userService.findUsersByPermission("G_ACTIVITY_MANAGE");
- waitToDoService.completeAllTODO(activityDetail.getId(), Constant.DictionaryType.ACTIVITY_APPLICATION);
- for (User puser : pusers) {
- waitToDoService.newTODO(activityDetail.getActivity_title() + "审核", "/government/activity/review/" + activityDetail.getId(), Constant.WaitToDo_OperType.AUDIT, activityDetail.getId(),
- Constant.DictionaryType.ACTIVITY_APPLICATION, null, puser.getId().toString(), Constant.WaitToDo_IsSerial.IS_SERIAL, false);
- }
- }
- if (!Objects.equals(quota, null) && !Objects.equals(quota, "")) {
- //名额有限
- if (Objects.equals(isReview, "1")) {
- //需要审核
- //已报名人数
- registrationNumber = activityRegistrationService.getActivityRegistrationNumber(id);
- return ResponseMessage.success("报名成功,剩余" + (Integer.parseInt(quota) - registrationNumber) + "个名额!", true);
- }
- }
- return ResponseMessage.success("报名成功!", true);
- }
- /*********************项目申报*************************/
- /**
- * 跳转到项目申报查看页面
- *
- * @return
- */
- @GetMapping(value = "/projectDetail/{id}/{isFilling}")
- public String checkProject(@PathVariable("id") int id, @PathVariable("isFilling") int isFilling, ModelMap modelMap) throws Exception {
- log.info("跳转到项目申报查看页面!id = {}", id);
- //获取导航
- Navigation nav = navigationService.findByName(Constant.Navigation_Name.PROJECT);
- modelMap.put("navigation_id", nav.getId());
- modelMap.put("navigation_name", nav.getName());
- modelMap.addAttribute("navigationList", navigationService.findList());
- this.commonObject(modelMap, true);
- if (isFilling == 0) {
- //项目申报
- ProjectDeclaration project = projectDeclarationService.selectById(String.valueOf(id));
- if (null == project) {
- modelMap.put("status", FAILURE);
- modelMap.put("message", "内容不存在!");
- return BASE_HOME_PATH + "html/informAnnouncement";
- }
- String sourceName = dictionaryItemService.findNameByTypeAndValue(Constant.DictionaryType.PROJECT_SOURCE, project.getProject_source());
- project.setProject_source_name(sourceName);
- project.setProject_content(StringEscapeUtils.unescapeHtml4(project.getProject_content()));
- if (null == project.getBrowse_count()) {
- project.setBrowse_count(0);
- }
- //更新数量
- project.setBrowse_count(project.getBrowse_count() + 1);
- projectDeclarationService.updateSelective(project);
- modelMap.put("content", project);
- return BASE_HOME_PATH + "html/projectDetail";
- } else if (isFilling == 2) {
- modelMap.put("navigation_id", 77);
- modelMap.put("navigation_name", "报表填报");
- //项目填报内申报
- ProjectFillingDeclaration project = projectFillingDeclarationService.selectById(String.valueOf(id));
- if (null == project) {
- modelMap.put("status", FAILURE);
- modelMap.put("message", "内容不存在!");
- return BASE_HOME_PATH + "html/informAnnouncement";
- }
- String sourceName = dictionaryItemService.findNameByTypeAndValue(Constant.DictionaryType.PROJECT_SOURCE, project.getProject_source());
- project.setProject_source_name(sourceName);
- project.setProject_content(StringEscapeUtils.unescapeHtml4(project.getProject_content()));
- if (null == project.getBrowse_count()) {
- project.setBrowse_count(0);
- }
- //更新数量
- project.setBrowse_count(project.getBrowse_count() + 1);
- projectFillingDeclarationService.updateSelective(project);
- modelMap.put("content", project);
- return BASE_HOME_PATH + "html/projectFillingDetail";
- } else if (isFilling == 1) {
- ProjectProvincesDeclaration provinces = projectProvincesDeclarationService.selectById(String.valueOf(id));
- if (null == provinces) {
- modelMap.put("status", FAILURE);
- modelMap.put("message", "内容不存在!");
- return BASE_HOME_PATH + "html/informAnnouncement";
- }
- String sourceName = dictionaryItemService.findNameByTypeAndValue(Constant.DictionaryType.PROJECT_SOURCE, provinces.getProject_source());
- provinces.setProject_source_name(sourceName);
- provinces.setContent(StringEscapeUtils.unescapeHtml4(provinces.getContent()));
- if (null == provinces.getBrowse_count()) {
- provinces.setBrowse_count(0);
- }
- //更新数量
- provinces.setBrowse_count(provinces.getBrowse_count() + 1);
- projectProvincesDeclarationService.updateSelective(provinces);
- modelMap.put("content", provinces);
- return BASE_HOME_PATH + "html/projectProvincesDetail";
- } else {
- ProjectIntelligentDeclaration intelligentDeclaration = projectIntelligentDeclarationService.selectById(String.valueOf(id));
- if (null == intelligentDeclaration) {
- modelMap.put("status", FAILURE);
- modelMap.put("message", "内容不存在!");
- return BASE_HOME_PATH + "html/informAnnouncement";
- }
- String sourceName = dictionaryItemService.findNameByTypeAndValue(Constant.DictionaryType.PROJECT_SOURCE, intelligentDeclaration.getProject_source());
- intelligentDeclaration.setProject_source_name(sourceName);
- intelligentDeclaration.setContent(StringEscapeUtils.unescapeHtml4(intelligentDeclaration.getContent()));
- if (null == intelligentDeclaration.getBrowse_count()) {
- intelligentDeclaration.setBrowse_count(0);
- }
- //更新数量
- intelligentDeclaration.setBrowse_count(intelligentDeclaration.getBrowse_count() + 1);
- projectIntelligentDeclarationService.updateSelective(intelligentDeclaration);
- modelMap.put("content", intelligentDeclaration);
- return BASE_HOME_PATH + "html/projectIntelligentDetail";
- }
- }
- @GetMapping(value = "/ajax/projectDetail/{id}/{isFilling}")
- @ResponseBody
- public ResponseMessage checkProjectAjax(@PathVariable("id") int id, @PathVariable("isFilling") int isFilling, ModelMap modelMap) throws Exception {
- log.info("跳转到项目申报查看页面!id = {}", id);
- //获取导航
- Navigation nav = navigationService.findByName(Constant.Navigation_Name.PROJECT);
- modelMap.put("navigation_id", nav.getId());
- modelMap.put("navigation_name", nav.getName());
- modelMap.addAttribute("navigationList", navigationService.findList());
- this.commonObject(modelMap, true);
- if (isFilling == 0) {
- //项目申报
- ProjectDeclaration project = projectDeclarationService.selectById(String.valueOf(id));
- if (null == project) {
- modelMap.put("status", FAILURE);
- modelMap.put("message", "内容不存在!");
- return ResponseMessage.success("success", modelMap);
- }
- String sourceName = dictionaryItemService.findNameByTypeAndValue(Constant.DictionaryType.PROJECT_SOURCE, project.getProject_source());
- project.setProject_source_name(sourceName);
- project.setProject_content(StringEscapeUtils.unescapeHtml4(project.getProject_content()));
- if (null == project.getBrowse_count()) {
- project.setBrowse_count(0);
- }
- //更新数量
- project.setBrowse_count(project.getBrowse_count() + 1);
- projectDeclarationService.updateSelective(project);
- modelMap.put("content", project);
- return ResponseMessage.success("success", modelMap);
- } else if (isFilling == 2) {
- modelMap.put("navigation_id", 77);
- modelMap.put("navigation_name", "报表填报");
- //项目填报内申报
- ProjectFillingDeclaration project = projectFillingDeclarationService.selectById(String.valueOf(id));
- if (null == project) {
- modelMap.put("status", FAILURE);
- modelMap.put("message", "内容不存在!");
- return ResponseMessage.success("success", modelMap);
- }
- String sourceName = dictionaryItemService.findNameByTypeAndValue(Constant.DictionaryType.PROJECT_SOURCE, project.getProject_source());
- project.setProject_source_name(sourceName);
- project.setProject_content(StringEscapeUtils.unescapeHtml4(project.getProject_content()));
- if (null == project.getBrowse_count()) {
- project.setBrowse_count(0);
- }
- //更新数量
- project.setBrowse_count(project.getBrowse_count() + 1);
- projectFillingDeclarationService.updateSelective(project);
- modelMap.put("content", project);
- return ResponseMessage.success("success", modelMap);
- } else if (isFilling == 1) {
- ProjectProvincesDeclaration provinces = projectProvincesDeclarationService.selectById(String.valueOf(id));
- if (null == provinces) {
- modelMap.put("status", FAILURE);
- modelMap.put("message", "内容不存在!");
- return ResponseMessage.success("success", modelMap);
- }
- String sourceName = dictionaryItemService.findNameByTypeAndValue(Constant.DictionaryType.PROJECT_SOURCE, provinces.getProject_source());
- provinces.setProject_source_name(sourceName);
- provinces.setContent(StringEscapeUtils.unescapeHtml4(provinces.getContent()));
- if (null == provinces.getBrowse_count()) {
- provinces.setBrowse_count(0);
- }
- //更新数量
- provinces.setBrowse_count(provinces.getBrowse_count() + 1);
- projectProvincesDeclarationService.updateSelective(provinces);
- modelMap.put("content", provinces);
- return ResponseMessage.success("success", modelMap);
- } else {
- ProjectIntelligentDeclaration intelligentDeclaration = projectIntelligentDeclarationService.selectById(String.valueOf(id));
- if (null == intelligentDeclaration) {
- modelMap.put("status", FAILURE);
- modelMap.put("message", "内容不存在!");
- return ResponseMessage.success("success", modelMap);
- }
- String sourceName = dictionaryItemService.findNameByTypeAndValue(Constant.DictionaryType.PROJECT_SOURCE, intelligentDeclaration.getProject_source());
- intelligentDeclaration.setProject_source_name(sourceName);
- intelligentDeclaration.setContent(StringEscapeUtils.unescapeHtml4(intelligentDeclaration.getContent()));
- if (null == intelligentDeclaration.getBrowse_count()) {
- intelligentDeclaration.setBrowse_count(0);
- }
- //更新数量
- intelligentDeclaration.setBrowse_count(intelligentDeclaration.getBrowse_count() + 1);
- projectIntelligentDeclarationService.updateSelective(intelligentDeclaration);
- modelMap.put("content", intelligentDeclaration);
- return ResponseMessage.success("success", modelMap);
- }
- }
- /*********************项目申报结束*************************/
- /**********************政策雷达***********************/
- @GetMapping(value = "/policyList")
- public String policyList(ModelMap modelMap) throws Exception {
- try {
- //TODO
- //int id=66;
- Navigation nav = navigationService.findByName(Constant.Navigation_Name.POLICY);
- // 获取导航
- modelMap.put("navigation_id", nav.getId());
- modelMap.put("navigation_name", nav.getName());
- this.commonObject(modelMap, true);
- } catch (Exception e) {
- e.printStackTrace();
- }
- return BASE_HOME_PATH + "html/policy/policyList";
- }
- @GetMapping(value = "/policyDetail")
- public String checkPolicy(ModelMap modelMap) throws Exception {
- //获取导航
- Navigation nav = navigationService.findByName(Constant.Navigation_Name.POLICY);
- modelMap.put("navigation_id", nav.getId());
- modelMap.put("navigation_name", nav.getName());
- modelMap.addAttribute("navigationList", navigationService.findList());
- this.commonObject(modelMap, true);
- return BASE_HOME_PATH + "html/policy/policyDetail";
- }
- @GetMapping(value = "/policySpecialDetail")
- public String checkSpecialPolicy(ModelMap modelMap) throws Exception {
- //log.info("跳转到政策内容查看页面!id = {}", id);
- //获取导航
- Navigation nav = navigationService.findByName(Constant.Navigation_Name.POLICY);
- modelMap.put("navigation_id", nav.getId());
- modelMap.put("navigation_name", nav.getName());
- modelMap.addAttribute("navigationList", navigationService.findList());
- this.commonObject(modelMap, true);
- return BASE_HOME_PATH + "html/policy/policySpecialDetail";
- }
- @GetMapping(value = "/policyQuestionList")
- public String policyQuestionList(ModelMap modelMap) throws Exception {
- try {
- //获取导航
- Navigation nav = navigationService.findByName(Constant.Navigation_Name.POLICY);
- modelMap.put("navigation_id", nav.getId());
- modelMap.put("navigation_name", nav.getName());
- this.commonObject(modelMap, true);
- } catch (Exception e) {
- e.printStackTrace();
- }
- return BASE_HOME_PATH + "html/policy/policyQuestionList";
- }
- @GetMapping(value = "/policySearchList")
- public String policySearchList(ModelMap modelMap) throws Exception {
- try {
- //获取导航
- Navigation nav = navigationService.findByName(Constant.Navigation_Name.POLICY);
- modelMap.put("navigation_id", nav.getId());
- modelMap.put("navigation_name", nav.getName());
- this.commonObject(modelMap, true);
- } catch (Exception e) {
- e.printStackTrace();
- }
- return BASE_HOME_PATH + "html/policy/policySearchList";
- }
- @GetMapping(value = "/policyQuestDetail")
- public String policyQuestDetail(ModelMap modelMap) throws Exception {
- //log.info("跳转到政策内容查看页面!id = {}", id);
- //获取导航
- Navigation nav = navigationService.findByName(Constant.Navigation_Name.POLICY);
- modelMap.put("navigation_id", nav.getId());
- modelMap.put("navigation_name", nav.getName());
- modelMap.addAttribute("navigationList", navigationService.findList());
- this.commonObject(modelMap, true);
- return BASE_HOME_PATH + "html/policy/policyQuestDetail";
- }
- /**********************政策雷达***********************/
- /**
- * 跳转到登录页面
- *
- * @return
- */
- @RequestMapping(value = "/login")
- public String toLogin(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) throws Exception {
- log.info("跳转到登录页面!");
- //Ajax登录超时校验,如果超时,进行前台响应提示
- if (WebUtil.isAjaxRequest(request)) {
- response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
- response.setHeader(HEAD_SESSION_STATUS_KEY, HEAD_SESSION_STATUS_VALUE);
- response.setContentType("text/html;charset=utf-8");
- }
- this.commonObject(modelMap, false);
- return BASE_HOME_PATH + "html/login";
- // return "/index";
- }
- /**
- * 用户登陆
- * 先根据用户名查询出一条用户记录再对比密码是否正确可以防止sql注入
- *
- * @param username 用户名
- * @param password 密码
- * @return
- */
- @OperationLog(value = "用户登录")
- @PostMapping(value = "/login")
- @ResponseBody
- public ResponseMessage login(HttpServletRequest request, String username, String password, Boolean isMobile) {
- try {
- //changeNewSession(request);
- BASE64Decoder decoder = new BASE64Decoder();
- username = new String(decoder.decodeBuffer(username), "UTF-8");
- password = new String(decoder.decodeBuffer(password), "UTF-8");
- //获取当前的Subject
- Subject currentUser = ShiroUtils.getSubject();
- UsernamePasswordToken token = new UsernamePasswordToken(username, password, isMobile, false);
- //在调用了login方法后,SecurityManager会收到AuthenticationToken,并将其发送给已配置的Realm执行必须的认证检查
- //每个Realm都能在必要时对提交的AuthenticationTokens作出反应
- //所以这一步在调用login(token)方法时,它会走到MyRealm.doGetAuthenticationInfo()方法中,具体验证方式详见此方法
- log.info("对用户进行登录验证..验证开始! username = {}", username);
- currentUser.login(token);
- //验证是否登录成功
- if (currentUser.isAuthenticated()) {
- log.info("对用户进行登录验证..验证通过! username = {}", username);
- ModelMap modelMap = new ModelMap();
- this.commonObject(modelMap, false);
- //获取token
- modelMap.put("token", userService.createToken());
- return ResponseMessage.success(Constant.USER_LOGIN_IN, modelMap);
- }
- } catch (UnknownAccountException e) { //账号不存在
- log.info("! username = {}", username);
- return ResponseMessage.error(Constant.USER_NOT_FIND);
- } catch (IncorrectCredentialsException e) {
- log.info("对用户进行登录验证..验证未通过,错误的凭证! username = {}", username);
- return ResponseMessage.error(Constant.USER_INVALID);
- } catch (LockedAccountException e) {
- log.info("对用户进行登录验证..验证未通过,账户已锁定! username = {}", username);
- return ResponseMessage.error(Constant.USER_HAS_REGISTERING);
- } catch (ExcessiveAttemptsException eae) {
- log.info("对用户进行登录验证..验证未通过,错误次数过多! username = {}", username);
- return ResponseMessage.error(Constant.USER_ERROR_MANY);
- } catch (AuthenticationException e) {
- return ResponseMessage.error(Constant.SYSTEM_ERRORS);
- } catch (Exception e) {
- log.error("对用户进行登录验证失败! username = {} e = {}", username, e);
- }
- return ResponseMessage.error(Constant.SYSTEM_ERRORS);
- }
- /**
- * 改变session
- *
- * @param request
- */
- private void changeNewSession(HttpServletRequest request) {
- if (request.getSession() != null) {
- //--------复制 session到临时变量
- HttpSession session = request.getSession();
- HashMap<String, Object> old = new HashMap<String, Object>();
- Enumeration keys = session.getAttributeNames();
- while (keys.hasMoreElements()) {
- String key = (String) keys.nextElement();
- old.put(key, session.getAttribute(key));
- session.removeAttribute(key);
- }
- session.invalidate();
- session = request.getSession(true);
- //-----------------复制session
- for (Iterator it = old.entrySet().iterator(); it.hasNext(); ) {
- Map.Entry entry = (Map.Entry) it.next();
- session.setAttribute((String) entry.getKey(), entry.getValue());
- }
- }
- }
- public void commonObject(ModelMap modelMap, Boolean isNav) throws Exception {
- Logo logo = logoService.findLogo();
- modelMap.put("fileUrl", setFileUrl());
- modelMap.put("logo", logo);
- modelMap.put("isLogin", ShiroUtils.isLogin());
- modelMap.put("userType", ShiroUtils.getUserType());
- modelMap.put("userName", ShiroUtils.getNickName());
- modelMap.put("userId", ShiroUtils.getUserId());
- User user = ShiroUtils.getUserEntity();
- if (user != null) {
- modelMap.put("firstLogin", user.getFist_login());
- if (StringUtils.isBlank(user.getUser_name()) || StringUtils.isBlank(user.getNick_name()) || StringUtils.isBlank(user.getPhone())) {
- modelMap.put("isComplete", false);
- } else {
- modelMap.put("isComplete", true);
- }
- }
- //获取有亲链接
- List<FriendLink> friendLinks = friendLinkService.findList();
- modelMap.put("friendLinks", friendLinks);
- if (isNav) {
- // 获取导航
- List<Navigation> navigations = navigationService.findList();
- modelMap.put("navigations", navigations);
- }
- }
- /**
- * 选择注册
- *
- * @param request
- * @param response
- * @param modelMap
- * @return
- * @throws Exception
- */
- @RequestMapping(value = "/chooseRegister")
- public String chooseRegister(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) throws Exception {
- log.info("跳转到注册页面!");
- //Ajax登录超时校验,如果超时,进行前台响应提示
- if (WebUtil.isAjaxRequest(request)) {
- response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
- response.setHeader(HEAD_SESSION_STATUS_KEY, HEAD_SESSION_STATUS_VALUE);
- response.setContentType("text/html;charset=utf-8");
- }
- this.commonObject(modelMap, false);
- return BASE_HOME_PATH + "html/choose_register";
- }
- /**
- * 个人注册
- *
- * @param request
- * @param response
- * @param modelMap
- * @return
- * @throws Exception
- */
- @RequestMapping(value = "/personal")
- public String persional(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) throws Exception {
- log.info("跳转到注册页面!");
- //Ajax登录超时校验,如果超时,进行前台响应提示
- if (WebUtil.isAjaxRequest(request)) {
- response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
- response.setHeader(HEAD_SESSION_STATUS_KEY, HEAD_SESSION_STATUS_VALUE);
- response.setContentType("text/html;charset=utf-8");
- }
- this.commonObject(modelMap, false);
- return BASE_HOME_PATH + "html/personal_register";
- }
- @RequestMapping(value = "/toRegister")
- public String toRegister(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) throws Exception {
- log.info("跳转到注册页面!");
- //Ajax登录超时校验,如果超时,进行前台响应提示
- if (WebUtil.isAjaxRequest(request)) {
- response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
- response.setHeader(HEAD_SESSION_STATUS_KEY, HEAD_SESSION_STATUS_VALUE);
- response.setContentType("text/html;charset=utf-8");
- }
- List<Street> streetList = streetService.findList();
- modelMap.addAttribute("streetList", streetList);
- //查询企业性质
- List<DictionaryItem> companyTypeList = dictionaryItemService.findListByTypeName(Constant.DictionaryType.COMPANY_TYPE);
- modelMap.put("companyTypeList", companyTypeList);
- //modelMap.put("companyTypeList", buildTypeService.findList(Constant.DictType.COMPANY));
- //查询币种单位数据
- List<DictionaryItem> itemList = dictionaryItemService.findListByTypeName(Constant.DictionaryType.CURRENCY_UNIT);
- modelMap.put("itemList", itemList);
- //查询行业类型
- List<DictionaryItem> industryTypeList = dictionaryItemService.findListByTypeName(Constant.DictionaryType.INDUSTRY_TYPE);
- modelMap.put("industryTypeList", industryTypeList);
- this.commonObject(modelMap, false);
- return BASE_HOME_PATH + "html/register";
- }
- @RequestMapping(value = "/toReset")
- public String toReset(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) throws Exception {
- log.info("跳转到忘记密码页面!");
- //Ajax登录超时校验,如果超时,进行前台响应提示
- if (WebUtil.isAjaxRequest(request)) {
- response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
- response.setHeader(HEAD_SESSION_STATUS_KEY, HEAD_SESSION_STATUS_VALUE);
- response.setContentType("text/html;charset=utf-8");
- }
- this.commonObject(modelMap, false);
- return BASE_HOME_PATH + "html/reset";
- }
- /**
- * 账号名是否存在
- */
- @ResponseBody
- @GetMapping(value = "/getNickName")
- public boolean getNickName(@RequestParam("id") String id, @RequestParam("nick_name") String nickName) throws Exception {
- boolean flag = true;
- log.debug("检验账号名是否存在! id= {}, nickName= {}", id, nickName);
- User record = userService.findByNickName(nickName);
- 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 userInfo
- * @return
- */
- @RequestMapping("/personalRegister")
- @ResponseBody
- public ResponseMessage personalRegister(User userInfo) {
- try {
- if (!Constant.Environment.PROD_TEST.equals(profiles) && !Constant.Environment.TEST.equals(profiles)) {
- if (!verificationCodeUtil.validateVerificationCode(userInfo.getPhone(), userInfo.getValidateNum())) {
- return ResponseMessage.error("验证码错误!");
- }
- }
- User user = new User();
- user.setUser_name(userInfo.getUser_name());
- user.setNick_name(userInfo.getNick_name().trim());
- user.setPassword(SecureUtil.md5().digestHex(userInfo.getPassword().trim()));
- user.setPhone(userInfo.getPhone());
- user.setUser_type(Constant.UserType.PERSONAL);
- user.setIs_register(1);
- user.setFist_login(1);
- user.setIs_start(true);
- user.setIs_admin(false);
- user.setCreate_name(userInfo.getUser_name());
- user.setCreate_time(DateUtil.getTimeString(new Date()));
- userService.insertAndGetId(user);
- } catch (Exception e) {
- e.printStackTrace();
- return ResponseMessage.error("注册失败" + e.getMessage());
- }
- return ResponseMessage.success("注册成功");
- }
- @GetMapping("/validate")
- @ResponseBody
- public ResponseMessage wechatRegist(@RequestParam("phone") String phone, @RequestParam("code") String code) {
- return ResponseMessage.success("请求成功", verificationCodeUtil.validateVerificationCode(phone, code));
- }
- /**
- * 微信注册
- *
- * @param userInfo
- * @return
- */
- @PostMapping("/wechatRegist")
- @ResponseBody
- public ResponseMessage wechatRegist(@RequestBody User userInfo) {
- User user_o = userService.findByMobile(userInfo.getPhone());
- if (user_o != null) {
- return ResponseMessage.success("注册成功", user_o.getId());
- }
- User user = new User();
- user.setUser_name(userInfo.getPhone());
- user.setNick_name(userInfo.getPhone());
- user.setPassword(SecureUtil.md5().digestHex("123456".trim()));
- user.setPhone(userInfo.getPhone());
- user.setUser_type(Constant.UserType.WECHAT);
- user.setIs_register(1);
- user.setFist_login(1);
- user.setIs_start(true);
- user.setIs_admin(false);
- user.setCreate_name("wechat_" + userInfo.getPhone());
- user.setCreate_time(DateUtil.getTimeString(new Date()));
- Integer id = userService.insertAndGetId(user);
- return ResponseMessage.success("注册成功", id);
- }
- /**
- * 微信小程序登录
- */
- @GetMapping("/wxapp/login")
- @ResponseBody
- public ResponseMessage wxAppLogin(
- @RequestParam String code
- ) {
- return ResponseMessage.success("登录成功", wxMicroappService.wxAppLogin(code));
- }
- /**
- * 微信小程序获取用户信息
- */
- @GetMapping("/wxapp/phone")
- @ResponseBody
- public ResponseMessage wxAppUserinfo(
- @RequestParam String code,
- @RequestParam String encryptedData,
- @RequestParam String iv
- ) {
- return ResponseMessage.success("获取用户信息成功", wxMicroappService.getPhoneNumber(code, encryptedData, iv));
- }
- /**
- * 企业注册
- *
- * @param information
- * @param userInfo
- * @return
- * @throws Exception
- */
- @RequestMapping("/register")
- @ResponseBody
- public ResponseMessage register(Company information, User userInfo) throws Exception {
- try {
- Approval approval = new Approval();
- if (!Constant.Environment.PROD_TEST.equals(profiles) && !Constant.Environment.TEST.equals(profiles)) {
- if (!verificationCodeUtil.validateVerificationCode(information.getPhone(), information.getValidateNum())) {
- return ResponseMessage.error("验证码错误!");
- }
- }
- /*
- if (StringUtils.isNotBlank(stockLandService.getCompanyRegister(information.getStreet_id()))) {
- approval.setNextchecker(stockLandService.getCompanyRegister(information.getStreet_id()));
- }
- //20180418-yl- 街道没有审批人也可以注册,分菜单给某角色,某个角色的人就可以审批
- else {
- return ResponseMessage.error("注册失败,本公司所属街道企业注册审核组没有配置人员,请联系街道管理员配置!");
- }*/
- approval.setOper_type(Constant.OperType.SUBMIT);
- approval.setType(Constant.DictionaryType.COMPANY_REGISTER);
- information.setIs_start(false);
- information.setIs_register(0);
- //查看是否已经存在企业
- // Company company = companyService.findByParkIdAndCompanyName(information.getCompany_name(), information.getBuild_id());
- Company company = companyService.findByCompanyName(information.getCompany_name());
- if (company != null) {
- information.setId(company.getId());
- information.setIs_register(0);
- companyService.update(information);
- } else {
- companyService.insertAndGetId(information);
- }
- approval.setApply_id(information.getId());
- approval.setDeal_time(DateUtil.getTimeString(new Date()));
- approval.setDel_flag(false);
- approval.setBefore_approvalstatus("0");
- approval.setCreate_name(information.getUser_name());
- //approvalService.insertAndGetId(approval);
- /*List<CompanyContact> companyContactList = information.getCompanyContacts();
- if (companyContactList != null && companyContactList.size() > 0) {
- for (CompanyContact companyContacts : companyContactList) {
- companyContacts.setCompany_id(information.getId());
- companyContactService.saveSelective(companyContacts);
- }
- }*/
- CompanyContact contact = new CompanyContact();
- contact.setCompany_id(information.getId());
- contact.setContact(information.getUser_name());
- contact.setPhone(information.getPhone());
- contact.setDel_flag(false);
- companyContactService.saveSelective(contact);
- List<CompanyContact> companyContactList = information.getContactList();
- if (companyContactList != null && companyContactList.size() > 0) {
- for (CompanyContact companyContacts : companyContactList) {
- if (companyContacts != null) {
- companyContacts.setCompany_id(information.getId());
- companyContactService.saveSelective(companyContacts);
- }
- }
- }
- List<FileDown> files = information.getFileDownList();
- if (files != null && files.size() > 0) {
- for (FileDown file : files) {
- if (file != null) {
- //attachmentDao.deleteByBusiness(Constant.Attachment.COMPANY_MATERIAL, information.getId());
- attachmentDao.updateAttachment(Constant.Attachment.COMPANY_MATERIAL, information.getId(), file.getFile_id());
- CompanyMaterial companyMaterial = new CompanyMaterial();
- companyMaterial.setAttachment_id(file.getFile_id());
- companyMaterial.setCompany_id(information.getId());
- companyMaterial.setFile_name(file.getFile_name());
- companyMaterialService.insertAndGetId(companyMaterial);
- }
- }
- }
- // todo 创建多个用户可以通过这里去改进
- User user = new User();
- user.setUser_name(information.getUser_name());
- user.setNick_name(information.getNick_name().trim());
- user.setPassword(SecureUtil.md5().digestHex(information.getPassword().trim()));
- user.setPhone(information.getPhone());
- user.setUser_type(Constant.UserType.COMPANY);
- user.setIs_register(0);
- user.setFist_login(1);
- user.setIs_start(false);
- user.setIs_admin(true);
- user.setCompany_id(information.getId());
- user.setCompany_name(information.getCompany_name());
- if (null != information.getBuild_id()) {
- user.setBuild_id(information.getBuild_id());
- user.setBuild_name(information.getBuild_name());
- }
- user.setStreet_id(information.getStreet_id());
- user.setStreet_name(information.getStreet_name());
- user.setCreate_name(information.getUser_name());
- userService.insertAndGetId(user);
- approval.setCreate_by(user.getId());
- approvalService.insertAndGetId(approval);
- information.setCreate_by(user.getId());
- information.setCreate_name(user.getUser_name());
- companyService.updateSelective(information);
- //同步信息天启
- SyncUserDto dto = new SyncUserDto();
- dto.setAction(Constant.METHOD_STATUS.INSERT);
- dto.setOldUserName("");
- dto.setUserName(user.getUser_name());
- dto.setUserLoginName(user.getNick_name());
- dto.setPassword(information.getPassword().trim());
- dto.setCompanyName(information.getCompany_name());
- if (null != information.getStreet_id()) {
- Street street = streetService.findById(information.getStreet_id());
- dto.setStreetName(street.getName());
- }
- dto.setToken(skyImageApiService.accessToken());
- skyImageApiService.syncUserInfo(dto);
- //新增街道待办
- addWaitToDo(information);
- //发送短信
- Map<String, String> params = new HashMap<>();
- params.put("user", user.getNick_name());
- params.put("street", information.getStreet_name());
- String templatCode = Constant.SMS_TemplateCode.REGISTER_REMIND;
- String templateParam = JSONObject.toJSONString(params);
- AlibabaSMSUtil.sendSMS(information.getPhone(), templatCode, Constant.SINGNAMW, templateParam);
- } catch (Exception e) {
- e.printStackTrace();
- return ResponseMessage.error("注册失败" + e.getMessage());
- }
- return ResponseMessage.success("您的申请正在属地审核中,审核通过后,您将收到消息提醒。");
- }
- //企业注册审核待办
- private void addWaitToDo(Company information) {
- if (null != information.getStreet_id()) {
- List<User> users = userService.findUsersByStreetId(information.getStreet_id());
- List<User> pusers = userService.findUsersByPermission("REGISTER_APPROVE");
- for (User user : users) {
- for (User puser : pusers) {
- if (Objects.equals(user.getId(), puser.getId())) {
- waitToDoService.newTODO("企业注册审核", "/register/approval?id=" + information.getId(), Constant.WaitToDo_OperType.AUDIT, information.getId(),
- Constant.DictionaryType.COMPANY_REGISTER, "", user.getId().toString(), Constant.WaitToDo_IsSerial.IS_SERIAL, false);
- //发送短信提醒
- Map<String, String> params = new HashMap<>();
- params.put("companyName", information.getCompany_name());
- String templatCode = Constant.SMS_TemplateCode.S_REGISTER_REMIND;
- String templateParam = JSONObject.toJSONString(params);
- try {
- AlibabaSMSUtil.sendSMS(information.getPhone(), templatCode, Constant.SINGNAMW, templateParam);
- } catch (ClientException | InterruptedException e) {
- e.printStackTrace();
- }
- }
- }
- }
- }
- }
- /**
- * 企业重置密码
- *
- * @param information
- * @param userInfo
- * @return
- * @throws Exception
- */
- @RequestMapping("/reset")
- @ResponseBody
- public ResponseMessage reset(Company information, User userInfo) {
- try {
- if (!verificationCodeUtil.validateVerificationCode(information.getPhone(), information.getValidateNum())) {
- return ResponseMessage.error("验证码错误!");
- }
- User user = userService.getUserByNickname(information.getNick_name());
- user.setPassword(SecureUtil.md5().digestHex(information.getPassword()));
- userService.updateSelective(user);
- // 同步密码到天启
- SyncUserDto dto = new SyncUserDto();
- dto.setAction(Constant.METHOD_STATUS.UPDATE);
- dto.setOldUserName(user.getNick_name());
- dto.setUserName(user.getUser_name());
- dto.setUserLoginName(user.getNick_name());
- dto.setPassword(information.getPassword());
- dto.setToken(skyImageApiService.accessToken());
- skyImageApiService.syncUserInfo(dto);
- } catch (Exception e) {
- e.printStackTrace();
- return ResponseMessage.error("修改失败" + e.getMessage());
- }
- return ResponseMessage.success("密码修改成功!系统将跳转到登陆页进行登录");
- }
- @RequestMapping(value = "/toComplete")
- public String toComplete(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) throws Exception {
- log.info("跳转到完成信息页面!");
- //Ajax登录超时校验,如果超时,进行前台响应提示
- if (WebUtil.isAjaxRequest(request)) {
- response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
- response.setHeader(HEAD_SESSION_STATUS_KEY, HEAD_SESSION_STATUS_VALUE);
- response.setContentType("text/html;charset=utf-8");
- }
- User user = ShiroUtils.getUserEntity();
- modelMap.put("user", user);
- ShiroUtils.logout();
- return BASE_HOME_PATH + "html/complete";
- }
- @RequestMapping("/complete")
- @ResponseBody
- public ResponseMessage complete(Company information, User userInfo) throws Exception {
- try {
- if (!verificationCodeUtil.validateVerificationCode(information.getPhone(), information.getValidateNum())) {
- return ResponseMessage.error("验证码错误!");
- }
- User user = new User();
- user.setId(Integer.parseInt(information.getUser_id()));
- user.setUser_name(information.getUser_name());
- user.setNick_name(information.getNick_name());
- user.setPhone(information.getPhone());
- userService.updateSelective(user);
- } catch (Exception e) {
- e.printStackTrace();
- return ResponseMessage.error("注册失败" + e.getMessage());
- }
- return ResponseMessage.success("完善信息成功!请重新登录!");
- }
- /**
- * 发送验证码
- *
- * @param phone
- * @return
- * @throws Exception
- */
- @RequestMapping("/sendVerificationCode")
- @ResponseBody
- public ResponseMessage sendVerificationCode(String phone) throws Exception {
- int t = verificationCodeUtil.validateVerificationTime(phone, 60L);
- if (t > 0) {
- return ResponseMessage.error("操作过于频繁!请" + t + "秒后再尝试!");
- }
- /* String phone = user.getPhone();
- String nick_name = user.getNick_name();
- String company_name = user.getCompany_name();
- String templateParam = "{\"nick_name\":\""+nick_name+"\",\"company_name\":\""+company_name+"\"}";
- AlibabaSMSUtil.sendSMS(phone, Constant.SMS_TemplateCode.COMPANY_USER_REGISTER_PASSED, Constant.SINGNAMW,templateParam);*/
- verificationCodeUtil.setVerificationCode(phone);
- return ResponseMessage.success("发送成功!请注意查收!");
- }
- /**
- * 校验账户名手机号是否匹配后发送验证码
- *
- * @param phone
- * @param name
- * @return
- * @throws Exception
- */
- @RequestMapping("/sendVerificationCodePhoneAndName")
- @ResponseBody
- public ResponseMessage sendVerificationCodePhoneAndName(@RequestParam("phone") String phone, @RequestParam("nickname") String name) throws Exception {
- User user = userService.getUserByNickname(name);
- if (null == user) {
- //throw new BaseException("该账号名不存在!");
- return ResponseMessage.error("该账号名不存在!");
- } else if (!phone.equals(user.getPhone())) {
- //throw new BaseException("账号名与手机号码不匹配!");
- return ResponseMessage.error("账号名与手机号码不匹配!");
- }
- int t = verificationCodeUtil.validateVerificationTime(phone, 60L);
- if (t > 0) {
- return ResponseMessage.error("操作过于频繁!请" + t + "秒后再尝试!");
- }
- verificationCodeUtil.setVerificationCode(phone);
- return ResponseMessage.success("发送成功!请注意查收!");
- }
- /**
- * 获取当前用户是否有待办权限
- */
- @RequestMapping("/getWaitToDoPermission")
- @ResponseBody
- public ResponseMessage getWaitToDoPermission() {
- if (ShiroUtils.isLogin()) {
- User usere = ShiroUtils.getUserEntity();
- if (usere.getIs_admin()) {
- return ResponseMessage.success(null, true);
- }
- int userid = ShiroUtils.getUserId();
- Integer usertype = ShiroUtils.getUserType();
- List<User> pusers = new ArrayList<>();
- switch (usertype) {
- case 0:
- pusers = userService.findUsersByPermission("G_WAITTODO");
- break;
- case 4:
- pusers = userService.findUsersByPermission("S_WAITTODO");
- break;
- case 1:
- pusers = userService.findUsersByPermission("Y_WAITTODO");
- break;
- case 3:
- pusers = userService.findUsersByPermission("C_WAITTODO");
- break;
- }
- for (User user : pusers) {
- if (Objects.equals(user.getId(), userid)) return ResponseMessage.success(null, true);
- }
- }
- return ResponseMessage.success(null, false);
- }
- @GetMapping(value = "/mobileIndex")
- public String mobileIndex(ModelMap modelMap) throws Exception {
- return BASE_MOBIl_PATH + "mobileIndex";
- }
- @GetMapping(value = "/mobileProjectIndex")
- public String mobileProjectIndex(ModelMap modelMap) throws Exception {
- return BASE_MOBIl_PATH + "mobileProjectIndex";
- }
- @GetMapping(value = "/serverDetail/{id}")
- public String serverDetail(@PathVariable("id") Integer navigationId, ModelMap modelMap) throws Exception {
- List<ProjectServiceType> projectServiceTypeList = projectServiceTypeService.findBySuperType("3");
- modelMap.put("projectServiceTypeList", projectServiceTypeList);
- //获取导航
- modelMap.put("navigation_id", navigationId);
- modelMap.put("navigation_name", navigationService.getName(navigationId));
- modelMap.addAttribute("navigationList", navigationService.findList());
- this.commonObject(modelMap, true);
- return BASE_HOME_PATH + "html/serverDetail";
- }
- @GetMapping(value = "/statistic")
- @ResponseBody
- public ResponseMessage getStatistic() {
- return ResponseMessage.success(null, statisticsService.getStatistics());
- }
- @GetMapping(value = "/addLiveness")
- @ResponseBody
- public ResponseMessage addLiveness() {
- statisticsService.insertLiveness();
- return ResponseMessage.success(null, null);
- }
- @GetMapping(value = "/wait")
- public String wait(ModelMap modelMap) throws Exception {
- return BASE_SYS_PATH + "wait";
- }
- @Value("${apk_url}")
- private String apk_url;
- @GetMapping(value = "/download/android/latest")
- @ResponseBody
- public void getLatestVersion(HttpServletRequest req, HttpServletResponse response) throws Exception {
- String name = "", version = "", date = "";
- List<DictionaryItem> appInfoList = dictionaryItemService.findListByTypeName(Constant.DictionaryType.APPLICATION_PACKAGE);
- for (DictionaryItem item : appInfoList) {
- if (Objects.equals(Constant.DictionaryType.APPLICATION_NAME, item.getName())) {
- name = item.getValue();
- } else if (Objects.equals(Constant.DictionaryType.APPLICATION_VERSION, item.getName())) {
- version = item.getValue();
- } else if (Objects.equals(Constant.DictionaryType.APPLICATION_DATE, item.getName())) {
- date = item.getValue();
- }
- }
- String filePath = apk_url + name + "-" + version + "-" + date + ".apk";
- File f = new File(filePath);
- OutputStream out = response.getOutputStream();
- if (!f.exists()) {
- response.setCharacterEncoding("UTF-8");
- String notFileHtml = getNotFileHtml();
- out.write(notFileHtml.getBytes("UTF-8"));
- out.flush();
- return;
- }
- String ua = ((HttpServletRequest) req).getHeader("user-agent").toLowerCase();
- if (ua.indexOf("micromessenger") > 0) {// 是微信浏览器
- response.setCharacterEncoding("UTF-8");
- String html = getWeixinTipsHtml();
- out.write(html.getBytes("UTF-8"));
- out.flush();
- return;
- }
- BufferedInputStream br = new BufferedInputStream(new FileInputStream(f));
- byte[] buf = new byte[1024];
- int len = 0;
- response.reset(); // 非常重要
- response.setContentType("application/x-msdownload");
- response.setHeader("Content-Disposition", "attachment; filename=" + name + "-" + version + "-" + date + ".apk");
- while ((len = br.read(buf)) > 0)
- out.write(buf, 0, len);
- br.close();
- out.close();
- }
- public static String getNotFileHtml() {
- StringBuffer sb = new StringBuffer();
- sb.append("<html>");
- sb.append("<head>");
- sb.append("<meta http-equiv='Content-Type' content='text/html;charset=UTF-8'>");
- sb.append("</head>");
- sb.append("<body>");
- sb.append("<div id='errorInfo' style='font-size: 130px;'>");
- sb.append("文件不存在");
- sb.append("</div>");
- sb.append("</body>");
- sb.append("</html>");
- return sb.toString();
- }
- public static String getWeixinTipsHtml() {
- StringBuffer sb = new StringBuffer();
- sb.append("<html>");
- sb.append("<head>");
- sb.append("<meta http-equiv='Content-Type' content='text/html;charset=UTF-8'>");
- sb.append("<style type='text/css'>*{margin:0;padding:0;}a{text-decoration: none;}img{max-width: 100%;height: auto;} .weixin-tip{display: none;position: fixed;" +
- "left:0;top:0;bottom:0;background: rgba(0,0,0,0.8);filter:alpha(opacity=80);height: 100%;width: 100%;z-index: 100;}.weixin-tip p{text-align: center;" +
- "margin-top: 10%;padding:0 5%;}</style>");
- sb.append("</head>");
- sb.append("<body>");
- sb.append("<div class='weixin-tip'><p><img src='../../image/live_weixin.png' alt='微信打开'/></p></div>");
- //sb.append("<div id='errorInfo' style='font-size: 130px;'>");
- //sb.append("请点击右上角,使用浏览器打开");
- //sb.append("</div><img src='../../image/appCode.png'>");
- //sb.append("<script>alert(this.location.href)</script>");
- sb.append("<script src='../../plugin/jquery-1.11.3.min.js' type='text/javascript'></script>");
- sb.append("<script type='text/javascript'>$(window).on('load',function(){var winHeight = $(window).height();function is_weixin() {var ua = navigator.userAgent.toLowerCase();" +
- "if (ua.match(/MicroMessenger/i) == 'micromessenger') {return true;} else {return false;}}var isWeixin = is_weixin();if(isWeixin){$('.weixin-tip').css('height',winHeight);" +
- "$('.weixin-tip').show();}})</script>");
- sb.append("</body>");
- sb.append("</html>");
- return sb.toString();
- }
- }
|