| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569 |
- 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.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;
- @Autowired
- 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();
- 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)) {
- 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 = "/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";
- }
- /**
- * 用户登陆
- * 先根据用户名查询出一条用户记录再对比密码是否正确可以防止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);
- }
- }
- }
- 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();
- }
- }
|