|
|
@@ -0,0 +1,143 @@
|
|
|
+package com.jpsoft.employment.modules.job.controller;
|
|
|
+
|
|
|
+
|
|
|
+import com.jpsoft.employment.modules.base.dto.HrIndexDataDTO;
|
|
|
+import com.jpsoft.employment.modules.base.entity.Company;
|
|
|
+import com.jpsoft.employment.modules.base.service.CompanyService;
|
|
|
+import com.jpsoft.employment.modules.common.dto.MessageResult;
|
|
|
+import com.jpsoft.employment.modules.job.entity.Resume;
|
|
|
+import com.jpsoft.employment.modules.job.entity.ResumeDeliver;
|
|
|
+import com.jpsoft.employment.modules.job.service.*;
|
|
|
+import com.jpsoft.employment.modules.sys.entity.User;
|
|
|
+import com.jpsoft.employment.modules.sys.service.UserService;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+@RestController
|
|
|
+@RequestMapping("/job/hrIndex")
|
|
|
+public class HrIndexController {
|
|
|
+ private Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
+ @Autowired
|
|
|
+ private UserService userService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private CompanyService companyService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ResumeDeliverService resumeDeliverService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private RecruitmentCollectionService recruitmentCollectionService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private UserBrowseService userBrowseService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private UserBrowseHrService userBrowseHrService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private RecruitmentService recruitmentService;
|
|
|
+
|
|
|
+ @ApiOperation(value="首页数据")
|
|
|
+ @PostMapping("indexData")
|
|
|
+ public MessageResult<HrIndexDataDTO> indexData(String token,@RequestAttribute String subject) {
|
|
|
+ MessageResult<HrIndexDataDTO> msgResult = new MessageResult<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+
|
|
|
+ User user = userService.get(subject);
|
|
|
+
|
|
|
+ if (user == null) {
|
|
|
+ throw new Exception("用户未登录,请先登录!");
|
|
|
+ }
|
|
|
+
|
|
|
+ Company company = companyService.get(user.getCompanyId());
|
|
|
+
|
|
|
+ if (company == null) {
|
|
|
+ throw new Exception("未查询到登录人员所在公司!");
|
|
|
+ }
|
|
|
+
|
|
|
+ HrIndexDataDTO dto = new HrIndexDataDTO();
|
|
|
+ dto.setRealName(user.getRealName());
|
|
|
+ dto.setPhoto(user.getPhoto());
|
|
|
+ dto.setCompanyName(company.getName());
|
|
|
+
|
|
|
+
|
|
|
+ //简历投递数量
|
|
|
+ int resumeDeliverNum = resumeDeliverService.countByCompanyId(company.getId());
|
|
|
+
|
|
|
+ dto.setResumeDeliverNum(resumeDeliverNum);
|
|
|
+
|
|
|
+ //收藏的简历
|
|
|
+ int recruitmentCollectionNum = recruitmentCollectionService.countByUserId(company.getId(),subject);
|
|
|
+
|
|
|
+ dto.setRecruitmentCollectionNum(recruitmentCollectionNum);
|
|
|
+
|
|
|
+ //对我感兴趣
|
|
|
+ int userBrowseNum = userBrowseService.countByCompanyId(company.getId());
|
|
|
+
|
|
|
+ dto.setUserBrowseNum(userBrowseNum);
|
|
|
+
|
|
|
+ //昨日浏览
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ Date now = new Date();
|
|
|
+ Calendar cal = Calendar.getInstance();
|
|
|
+ cal.setTime(now);
|
|
|
+ cal.add(Calendar.DATE,-1);
|
|
|
+ Date lastDate = cal.getTime();
|
|
|
+
|
|
|
+ String beginTime = sdf.format(lastDate)+" 00:00:00";
|
|
|
+ String endTime = beginTime + " 23:59:59";
|
|
|
+
|
|
|
+ int yesterdayBrowseNum = userBrowseHrService.countBySysUserId(subject,beginTime,endTime);
|
|
|
+
|
|
|
+ dto.setYesterdayBrowseNum(yesterdayBrowseNum);
|
|
|
+
|
|
|
+ int recruitmentNum = recruitmentService.countByCompanyId(company.getId());
|
|
|
+
|
|
|
+ //流量数据漏斗图
|
|
|
+ List<Map<String,Object>> list = new ArrayList<>();
|
|
|
+
|
|
|
+ Map<String,Object> map = new HashMap<>();
|
|
|
+ map.put("name","recruitmentNum");
|
|
|
+ map.put("value",recruitmentNum);
|
|
|
+
|
|
|
+ list.add(map);
|
|
|
+
|
|
|
+ Map<String,Object> map1 = new HashMap<>();
|
|
|
+ map1.put("name","userBrowseNum");
|
|
|
+ map1.put("value",userBrowseNum);
|
|
|
+
|
|
|
+ list.add(map1);
|
|
|
+
|
|
|
+ Map<String,Object> map2 = new HashMap<>();
|
|
|
+ map2.put("name","resumeDeliverNum");
|
|
|
+ map2.put("value",resumeDeliverNum);
|
|
|
+
|
|
|
+ list.add(map2);
|
|
|
+
|
|
|
+ dto.setPositionDataFlow(list);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ msgResult.setResult(true);
|
|
|
+ msgResult.setData(dto);
|
|
|
+ }
|
|
|
+ catch(Exception ex){
|
|
|
+ logger.error(ex.getMessage(),ex);
|
|
|
+
|
|
|
+ msgResult.setResult(false);
|
|
|
+ msgResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return msgResult;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|