Commit ee9dcc1b1f7b8f3be1c253a8e036164e4d5976fd

Authored by 陈杰
1 parent 557a2d5b
Exists in master

考勤推送

cloud/common/src/main/java/com/sincere/common/dto/smartCampus/CensusKqDto.java
... ... @@ -6,10 +6,19 @@ package com.sincere.common.dto.smartCampus;
6 6 * @date 2019/11/29 0029 14:27
7 7 */
8 8 public class CensusKqDto {
  9 + private int classId ;
9 10 private String className ;
10 11 private int allT ;
11 12 private int kqT ;
12 13  
  14 + public int getClassId() {
  15 + return classId;
  16 + }
  17 +
  18 + public void setClassId(int classId) {
  19 + this.classId = classId;
  20 + }
  21 +
13 22 public String getClassName() {
14 23 return className;
15 24 }
... ...
cloud/common/src/main/java/com/sincere/common/dto/smartCampus/KqDto.java 0 → 100644
... ... @@ -0,0 +1,46 @@
  1 +package com.sincere.common.dto.smartCampus;
  2 +
  3 +/**
  4 + * @author chen
  5 + * @version 1.0
  6 + * @date 2019/12/5 0005 11:01
  7 + */
  8 +public class KqDto {
  9 + private String userId ;
  10 + private String type ;
  11 + private String templateId ;
  12 + private String endTime ;
  13 +
  14 +
  15 + public String getUserId() {
  16 + return userId;
  17 + }
  18 +
  19 + public void setUserId(String userId) {
  20 + this.userId = userId;
  21 + }
  22 +
  23 + public String getType() {
  24 + return type;
  25 + }
  26 +
  27 + public void setType(String type) {
  28 + this.type = type;
  29 + }
  30 +
  31 + public String getTemplateId() {
  32 + return templateId;
  33 + }
  34 +
  35 + public void setTemplateId(String templateId) {
  36 + this.templateId = templateId;
  37 + }
  38 +
  39 + public String getEndTime() {
  40 + return endTime;
  41 + }
  42 +
  43 + public void setEndTime(String endTime) {
  44 + this.endTime = endTime;
  45 + }
  46 +}
... ...
cloud/quartz/src/main/java/com/sincere/quartz/feign/ScFeign.java
1 1 package com.sincere.quartz.feign;
2 2  
3   -import com.sincere.common.dto.smartCampus.AppDto;
4   -import com.sincere.common.dto.smartCampus.CensusKqDto;
5   -import com.sincere.common.dto.smartCampus.KqTeacherDto;
6   -import com.sincere.common.dto.smartCampus.TemplateDto;
  3 +import com.sincere.common.dto.smartCampus.*;
7 4 import org.springframework.cloud.openfeign.FeignClient;
  5 +import org.springframework.web.bind.annotation.RequestBody;
8 6 import org.springframework.web.bind.annotation.RequestMapping;
9 7 import org.springframework.web.bind.annotation.RequestMethod;
10 8 import org.springframework.web.bind.annotation.RequestParam;
... ... @@ -25,9 +23,15 @@ public interface ScFeign {
25 23 @RequestMapping(value = "/sm/kq/getTeacherList",method = RequestMethod.GET)
26 24 List<KqTeacherDto> getTeacherList(@RequestParam("schoolId")int schoolId);
27 25  
  26 + @RequestMapping(value = "/sm/kq/selectChamberTeacher",method = RequestMethod.GET)
  27 + List<KqTeacherDto> selectChamberTeacher(@RequestParam("schoolId")int schoolId);
  28 +
28 29 @RequestMapping(value = "/sm/kq/getApp",method = RequestMethod.GET)
29 30 AppDto getApp(@RequestParam("schoolId")int schoolId , @RequestParam("type") int type);
30 31  
31   - @RequestMapping(value = "/sm/kq/getCensusKq",method = RequestMethod.GET)
32   - List<CensusKqDto> getCensusKq(@RequestParam("userId") String userId , @RequestParam("type") int type);
  32 + @RequestMapping(value = "/sm/kq/getCensusKq",method = RequestMethod.POST)
  33 + List<CensusKqDto> getCensusKq(@RequestBody KqDto kqDto);
  34 +
  35 + @RequestMapping(value = "/sm/kq/selectCensusChamberKq",method = RequestMethod.POST)
  36 + List<CensusKqDto> selectCensusChamberKq(@RequestBody KqDto kqDto);
33 37 }
... ...
cloud/quartz/src/main/java/com/sincere/quartz/job/KQJob.java
1 1 package com.sincere.quartz.job;
2 2  
3   -import com.sincere.common.dto.smartCampus.AppDto;
4   -import com.sincere.common.dto.smartCampus.CensusKqDto;
5   -import com.sincere.common.dto.smartCampus.KqTeacherDto;
6   -import com.sincere.common.dto.smartCampus.TemplateDto;
  3 +import com.sincere.common.dto.smartCampus.*;
7 4 import com.sincere.common.util.DateUtils;
8 5 import com.sincere.quartz.enums.KqTypeEnums;
9 6 import com.sincere.quartz.enums.TypeEnums;
... ... @@ -57,17 +54,16 @@ public class KQJob {
57 54 for(Map.Entry<String, String> entity : map.entrySet()){
58 55 String endTime = entity.getValue().split("_")[1];
59 56 if(DateUtils.getDateDifference(new Date(),DateUtils.string2Date(now+" "+endTime+":00",DateUtils.format2),"m")>=2
60   - && DateUtils.getDateDifference(new Date(),DateUtils.string2Date(now+" "+endTime+":00",DateUtils.format2),"m")<5){
  57 + && DateUtils.getDateDifference(new Date(),DateUtils.string2Date(now+" "+endTime+":00",DateUtils.format2),"m") < 5 ){
61 58 String key = entity.getKey();
62 59 String[] messageArray = key.split("_");
63   - List<KqTeacherDto> list = scFeign.getTeacherList(Integer.valueOf(messageArray[1]));
64 60 if(messageArray[2].contains("5")){
65 61 logger.info("企业号推送:" + messageArray[0] + "__" + messageArray[1]);
66   - weChatPush(list,entity.getValue());
  62 + weChatBatchPush(messageArray[0],Integer.valueOf(messageArray[1]),entity.getValue());
67 63 }
68 64 if(messageArray[2].contains("4")){
69 65 logger.info(("盯盯推送:" + messageArray[0] + "__" + messageArray[1]));
70   - dingPush(list,entity.getValue());
  66 + dingBatchPush(messageArray[0],Integer.valueOf(messageArray[1]),entity.getValue());
71 67 }
72 68 keyList.add(key);
73 69 }
... ... @@ -105,13 +101,69 @@ public class KQJob {
105 101 }
106 102 }
107 103  
108   - private void dingPush(List<KqTeacherDto> list , String key){
  104 + private void dingBatchPush(String templateId , int schoolId , String key){
  105 + String[] times = key.split("_");
  106 + AppDto appDto = scFeign.getApp(schoolId,1);
  107 + if(Integer.valueOf(times[2]) < 7){
  108 + //出入校 推班主任
  109 + List<KqTeacherDto> list = scFeign.getTeacherList(schoolId);
  110 + for(KqTeacherDto teacher : list){
  111 + if(teacher.getName().equals("倪任佳")){
  112 + dingSchoolPush(templateId,teacher,key,appDto);
  113 + }
  114 + }
  115 + }else {
  116 + //出入寝 推班主任
  117 + List<KqTeacherDto> list = scFeign.getTeacherList(schoolId);
  118 + for(KqTeacherDto teacher : list){
  119 + if(teacher.getName().equals("倪任佳")) {
  120 + dingSchoolPush(templateId,teacher, key, appDto);
  121 + }
  122 + }
  123 + //推宿管
  124 + List<KqTeacherDto> chamberList = scFeign.selectChamberTeacher(schoolId);
  125 + for(KqTeacherDto teacher : chamberList){
  126 + if(teacher.getName().equals("倪任佳")) {
  127 + dingChamberPush(templateId,teacher, key, appDto);
  128 + }
  129 + }
  130 + }
  131 + }
  132 +
  133 + private void weChatBatchPush(String templateId , int schoolId , String key){
  134 + String[] times = key.split("_");
  135 + AppDto appDto = scFeign.getApp(schoolId, 0);
  136 + if(Integer.valueOf(times[2]) < 7) {
  137 + //出入校 推班主任
  138 + List<KqTeacherDto> list = scFeign.getTeacherList(schoolId);
  139 + for (KqTeacherDto teacher : list) {
  140 + weChatSchoolPush(templateId,teacher, key, appDto);
  141 + }
  142 + }else {
  143 + //出入寝 推班主任
  144 + List<KqTeacherDto> list = scFeign.getTeacherList(schoolId);
  145 + for (KqTeacherDto teacher : list) {
  146 + weChatSchoolPush(templateId,teacher, key, appDto);
  147 + }
  148 + //推宿管
  149 + List<KqTeacherDto> chamberList = scFeign.selectChamberTeacher(schoolId);
  150 + for(KqTeacherDto teacher : chamberList){
  151 + weChatChamberPush(templateId,teacher, key, appDto);
  152 + }
  153 + }
  154 + }
  155 +
  156 + private void dingSchoolPush(String templateId ,KqTeacherDto teacher , String key , AppDto appDto){
109 157 String[] times = key.split("_");
110 158 String tableSuffix = DateUtils.date2String(new Date(), DateUtils.format);
111   - AppDto appDto = scFeign.getApp(list.get(0).getSchoolId(),1);
112   - for(KqTeacherDto teacher : list){
113   - if(StringUtils.isNotBlank(teacher.getDingUserId())){
114   - List<CensusKqDto> censusKqDtos = scFeign.getCensusKq(teacher.getUserId(),Integer.valueOf(times[2]));
  159 + if(StringUtils.isNotBlank(teacher.getDingUserId())){
  160 + KqDto dto = new KqDto();
  161 + dto.setEndTime(times[1]);
  162 + dto.setTemplateId(templateId);
  163 + dto.setType(times[2]);
  164 + dto.setUserId(teacher.getUserId());
  165 + List<CensusKqDto> censusKqDtos = scFeign.getCensusKq(dto);
  166 + if(censusKqDtos != null &&censusKqDtos.size() > 0){
115 167 String message = "";
116 168 for(CensusKqDto censusKqDto : censusKqDtos){
117 169 int number = censusKqDto.getAllT() - censusKqDto.getKqT() ;
... ... @@ -121,43 +173,84 @@ public class KQJob {
121 173 dingSms.setName(teacher.getName());
122 174 dingSms.setTableName("DingSmsNew"+tableSuffix);
123 175 dingSms.setMsg("报告类型:"+KqTypeEnums.getName(Integer.valueOf(times[2])) + "出勤报告 \n - "+
124   - "签到日期:"+DateUtils.date2String(new Date(),DateUtils.format1)+ "("+DateUtils.getWeekName()+") \n - "+
125   - "签到时间:"+times[0]+"-"+ times[1] +" \n - "+
126   - "整体数据:" + message.substring(0,message.length()-1));
127   - dingSms.setSchoolId(teacher.getSchoolId());
128   - dingSms.setDingUserId(teacher.getDingUserId());
129   - dingSms.setAgentId(appDto.getAgentId());
  176 + "签到日期:"+DateUtils.date2String(new Date(),DateUtils.format1)+ "("+DateUtils.getWeekName()+") \n - "+
  177 + "签到时间:"+times[0]+"-"+ times[1] +" \n - "+
  178 + "整体数据:" + message.substring(0,message.length()-1));
130 179 String wapUrl = "http://campus.myjxt.com/studentRecord/znxwwebapp/index.html?" +
131 180 "schoolid="+teacher.getSchoolId()+"&userId="+teacher.getUserId()+"&name="+teacher.getName()+
132 181 "&data="+teacher.getDingUserId()+"&type=1&stype=4&mobile="+teacher.getMobile()+"&pass="+teacher.getPass()+
133   - "&face=&sourcetype=16&soutype=3&timestamp="+ DateUtils.getDate() ;
  182 + "&face=&sourcetype=16&soutype=3&timestamp="+ DateUtils.getDate()+"&time="+DateUtils.date2String(new Date(),DateUtils.format1) ;
  183 + dingSms.setSchoolId(teacher.getSchoolId());
  184 + dingSms.setDingUserId(teacher.getDingUserId());
  185 + dingSms.setAgentId(appDto.getAgentId());
134 186 dingSms.setWapUrl(wapUrl);
135 187 dingSms.setReceiveUserId(teacher.getUserId());
136 188 dingSms.setTdType(TypeEnums.kaoqing.getType());
137 189 smsMapper.insertDing(dingSms);
138 190 }
139   -
140 191 }
141 192 }
142 193  
143   - private void weChatPush(List<KqTeacherDto> list , String key){
  194 + private void dingChamberPush(String templateId, KqTeacherDto teacher , String key , AppDto appDto){
144 195 String[] times = key.split("_");
145 196 String tableSuffix = DateUtils.date2String(new Date(), DateUtils.format);
146   - AppDto appDto = scFeign.getApp(list.get(0).getSchoolId(),0);
147   - for(KqTeacherDto teacher : list){
148   - if (StringUtils.isNotBlank(teacher.getOpenId())) {
149   - List<CensusKqDto> censusKqDtos = scFeign.getCensusKq(teacher.getUserId(),Integer.valueOf(times[2]));
  197 + if(StringUtils.isNotBlank(teacher.getDingUserId())){
  198 + List<CensusKqDto> censusKqDtos ;
  199 + KqDto dto = new KqDto();
  200 + dto.setEndTime(times[1]);
  201 + dto.setTemplateId(templateId);
  202 + dto.setType(times[2]);
  203 + dto.setUserId(teacher.getUserId());
  204 + censusKqDtos = scFeign.selectCensusChamberKq(dto);
  205 + if(censusKqDtos != null &&censusKqDtos.size() > 0){
150 206 String message = "";
151 207 for(CensusKqDto censusKqDto : censusKqDtos){
152 208 int number = censusKqDto.getAllT() - censusKqDto.getKqT() ;
153 209 message += "[" + censusKqDto.getClassName() + "]未考勤" + number + "人;";
154 210 }
155   - WeChatSms weChatSms = new WeChatSms();
156   - weChatSms.setTableName("qyhSmsNew" + tableSuffix);
157   - weChatSms.setMsg("报告类型:"+KqTypeEnums.getName(Integer.valueOf(times[2])) + "出勤报告 \n - "+
  211 + DingSms dingSms = new DingSms();
  212 + dingSms.setName(teacher.getName());
  213 + dingSms.setTableName("DingSmsNew"+tableSuffix);
  214 + dingSms.setMsg("报告类型:"+KqTypeEnums.getName(Integer.valueOf(times[2])) + "出勤报告 \n - "+
158 215 "签到日期:"+DateUtils.date2String(new Date(),DateUtils.format1)+ "("+DateUtils.getWeekName()+") \n - "+
159 216 "签到时间:"+times[0]+"-"+ times[1] +" \n - "+
160 217 "整体数据:" + message.substring(0,message.length()-1));
  218 + String msgUrl = "http://campus.myjxt.com/studentRecord/znxwwebapp/index.html?" +
  219 + "schoolid=" + teacher.getSchoolId() + "&userId=" + teacher.getUserId() + "&name=" + teacher.getName() +
  220 + "&pass=" + teacher.getPass() + "&type=4&soutype=3&time="+DateUtils.date2String(new Date(),DateUtils.format1);
  221 + dingSms.setSchoolId(teacher.getSchoolId());
  222 + dingSms.setDingUserId(teacher.getDingUserId());
  223 + dingSms.setAgentId(appDto.getAgentId());
  224 + dingSms.setWapUrl(msgUrl);
  225 + dingSms.setReceiveUserId(teacher.getUserId());
  226 + dingSms.setTdType(TypeEnums.kaoqing.getType());
  227 + smsMapper.insertDing(dingSms);
  228 + }
  229 + }
  230 + }
  231 +
  232 + private void weChatSchoolPush(String templateId, KqTeacherDto teacher , String key , AppDto appDto){
  233 + String[] times = key.split("_");
  234 + String tableSuffix = DateUtils.date2String(new Date(), DateUtils.format);
  235 + if (StringUtils.isNotBlank(teacher.getOpenId())) {
  236 + KqDto dto = new KqDto();
  237 + dto.setEndTime(times[1]);
  238 + dto.setTemplateId(templateId);
  239 + dto.setType(times[2]);
  240 + dto.setUserId(teacher.getUserId());
  241 + List<CensusKqDto> censusKqDtos = scFeign.getCensusKq(dto);
  242 + if (censusKqDtos != null && censusKqDtos.size() > 0) {
  243 + String message = "";
  244 + for (CensusKqDto censusKqDto : censusKqDtos) {
  245 + int number = censusKqDto.getAllT() - censusKqDto.getKqT();
  246 + message += "[" + censusKqDto.getClassName() + "]未考勤" + number + "人;";
  247 + }
  248 + WeChatSms weChatSms = new WeChatSms();
  249 + weChatSms.setTableName("qyhSmsNew" + tableSuffix);
  250 + weChatSms.setMsg("报告类型:" + KqTypeEnums.getName(Integer.valueOf(times[2])) + "出勤报告 \n - " +
  251 + "签到日期:" + DateUtils.date2String(new Date(), DateUtils.format1) + "(" + DateUtils.getWeekName() + ") \n - " +
  252 + "签到时间:" + times[0] + "-" + times[1] + " \n - " +
  253 + "整体数据:" + message.substring(0, message.length() - 1));
161 254 weChatSms.setSchoolId(teacher.getSchoolId());
162 255 weChatSms.setName(teacher.getName());
163 256 weChatSms.setQiYeHaoUserId(teacher.getWeChatUserId());
... ... @@ -167,7 +260,46 @@ public class KQJob {
167 260 String msgUrl = "http://campus.myjxt.com/studentRecord/znxwwebapp/index.html?" +
168 261 "schoolid=" + teacher.getSchoolId() + "&userId=" + teacher.getUserId() + "&name=" + teacher.getName() +
169 262 "&data=" + teacher.getWeChatUserId() + "&type=1&stype=3&mobile=" + teacher.getMobile() + "&pass=" + teacher.getPass() +
170   - "&face=" + teacher.getFace() + "&sourcetype=16&soutype=2&timestamp=" + DateUtils.getDate();
  263 + "&face=" + teacher.getFace() + "&sourcetype=16&soutype=2&timestamp=" + DateUtils.getDate()+"&time="+DateUtils.date2String(new Date(),DateUtils.format1);
  264 + weChatSms.setMsgUrl(msgUrl);
  265 + weChatSms.setTdType(TypeEnums.kaoqing.getType());
  266 + smsMapper.insertWeChat(weChatSms);
  267 + }
  268 + }
  269 + }
  270 +
  271 + private void weChatChamberPush(String templateId, KqTeacherDto teacher , String key , AppDto appDto){
  272 + String[] times = key.split("_");
  273 + String tableSuffix = DateUtils.date2String(new Date(), DateUtils.format);
  274 + if (StringUtils.isNotBlank(teacher.getOpenId())) {
  275 + List<CensusKqDto> censusKqDtos ;
  276 + KqDto dto = new KqDto();
  277 + dto.setEndTime(times[1]);
  278 + dto.setTemplateId(templateId);
  279 + dto.setType(times[2]);
  280 + dto.setUserId(teacher.getUserId());
  281 + censusKqDtos = scFeign.selectCensusChamberKq(dto);
  282 + if (censusKqDtos != null && censusKqDtos.size() > 0) {
  283 + String message = "";
  284 + for (CensusKqDto censusKqDto : censusKqDtos) {
  285 + int number = censusKqDto.getAllT() - censusKqDto.getKqT();
  286 + message += "[" + censusKqDto.getClassName() + "]未考勤" + number + "人;";
  287 + }
  288 + WeChatSms weChatSms = new WeChatSms();
  289 + weChatSms.setTableName("qyhSmsNew" + tableSuffix);
  290 + weChatSms.setMsg("报告类型:" + KqTypeEnums.getName(Integer.valueOf(times[2])) + "出勤报告 \n - " +
  291 + "签到日期:" + DateUtils.date2String(new Date(), DateUtils.format1) + "(" + DateUtils.getWeekName() + ") \n - " +
  292 + "签到时间:" + times[0] + "-" + times[1] + " \n - " +
  293 + "整体数据:" + message.substring(0, message.length() - 1));
  294 + weChatSms.setSchoolId(teacher.getSchoolId());
  295 + weChatSms.setName(teacher.getName());
  296 + weChatSms.setQiYeHaoUserId(teacher.getWeChatUserId());
  297 + weChatSms.setReceiveUserId(teacher.getUserId());
  298 + weChatSms.setAppId(appDto.getAgentId());
  299 + weChatSms.setSecret(appDto.getAgentSecret());
  300 + String msgUrl = "http://campus.myjxt.com/studentRecord/znxwwebapp/index.html?" +
  301 + "schoolid=" + teacher.getSchoolId() + "&userId=" + teacher.getUserId() + "&name=" + teacher.getName() +
  302 + "&pass=" + teacher.getPass() + "&type=4&soutype=2&time="+DateUtils.date2String(new Date(),DateUtils.format1);
171 303 weChatSms.setMsgUrl(msgUrl);
172 304 weChatSms.setTdType(TypeEnums.kaoqing.getType());
173 305 smsMapper.insertWeChat(weChatSms);
... ...
cloud/search_smartCampus/src/main/java/com/sincere/smartSearch/controller/KqController.java
1 1 package com.sincere.smartSearch.controller;
2 2  
3   -import com.sincere.common.dto.smartCampus.AppDto;
4   -import com.sincere.common.dto.smartCampus.CensusKqDto;
5   -import com.sincere.common.dto.smartCampus.KqTeacherDto;
6   -import com.sincere.common.dto.smartCampus.TemplateDto;
  3 +import com.sincere.common.dto.smartCampus.*;
7 4 import com.sincere.common.util.DateUtils;
8 5 import com.sincere.smartSearch.model.KqTemplate;
9 6 import com.sincere.smartSearch.service.KqService;
10 7 import org.springframework.beans.factory.annotation.Autowired;
11   -import org.springframework.web.bind.annotation.RequestMapping;
12   -import org.springframework.web.bind.annotation.RequestMethod;
13   -import org.springframework.web.bind.annotation.RequestParam;
14   -import org.springframework.web.bind.annotation.RestController;
  8 +import org.springframework.web.bind.annotation.*;
15 9  
16 10 import java.util.*;
17 11  
... ... @@ -47,6 +41,11 @@ public class KqController {
47 41 return kqService.selectSchoolTeacher(schoolId);
48 42 }
49 43  
  44 + @RequestMapping(value = "selectChamberTeacher",method = RequestMethod.GET)
  45 + public List<KqTeacherDto> selectChamberTeacher(@RequestParam("schoolId")int schoolId){
  46 + return kqService.selectChamberTeacher(schoolId);
  47 + }
  48 +
50 49 @RequestMapping(value = "getApp",method = RequestMethod.GET)
51 50 public AppDto getApp(@RequestParam("schoolId")int schoolId , @RequestParam("type") int type){
52 51 Map<String ,Integer> map = new HashMap<>();
... ... @@ -55,13 +54,13 @@ public class KqController {
55 54 return kqService.selectApp(map);
56 55 }
57 56  
58   - @RequestMapping(value = "getCensusKq",method = RequestMethod.GET)
59   - public List<CensusKqDto> getCensusKq(@RequestParam("userId") String userId , @RequestParam("type") int type){
60   - String tableSuffix = DateUtils.date2String(new Date(), DateUtils.format);
61   - Map<String,String> map = new HashMap<>();
62   - map.put("userId",userId);
63   - map.put("tableName","SZ_AttendanceRecords"+tableSuffix);
64   - map.put("type",type+"");
65   - return kqService.selectCensusKq(map);
  57 + @RequestMapping(value = "getCensusKq",method = RequestMethod.POST)
  58 + public List<CensusKqDto> getCensusKq(@RequestBody KqDto kqDto){
  59 + return kqService.selectCensusKq(kqDto);
  60 + }
  61 +
  62 + @RequestMapping(value = "selectCensusChamberKq",method = RequestMethod.POST)
  63 + public List<CensusKqDto> selectCensusChamberKq(@RequestBody KqDto kqDto){
  64 + return kqService.selectCensusChamberKq(kqDto);
66 65 }
67 66 }
... ...
cloud/search_smartCampus/src/main/java/com/sincere/smartSearch/mapper/KqTemplateMapper.java
... ... @@ -3,6 +3,7 @@ package com.sincere.smartSearch.mapper;
3 3 import com.sincere.common.dto.smartCampus.AppDto;
4 4 import com.sincere.common.dto.smartCampus.CensusKqDto;
5 5 import com.sincere.common.dto.smartCampus.KqTeacherDto;
  6 +import com.sincere.smartSearch.model.KqChamber;
6 7 import com.sincere.smartSearch.model.KqTemplate;
7 8  
8 9 import java.util.List;
... ... @@ -19,7 +20,23 @@ public interface KqTemplateMapper {
19 20  
20 21 List<KqTeacherDto> selectSchoolTeacher(int schoolId);
21 22  
  23 + List<KqTeacherDto> selectChamberTeacher(int schoolId);
  24 +
22 25 AppDto selectApp(Map<String,Integer> map);
23 26  
24 27 List<CensusKqDto> selectCensusKq(Map<String ,String> map);
  28 +
  29 + List<KqChamber> selectChamberName(String userId);
  30 +
  31 + int selectChamberAllKq(Map<String,String> map);
  32 +
  33 + int selectChamberTrueKq(Map<String,String> map);
  34 +
  35 + int selectClassDealDate(Map<String,String> map);
  36 +
  37 + int selectClassLeave(Map<String,String> map);
  38 +
  39 + int selectChamberDealDate(Map<String,String> map);
  40 +
  41 + int selectChamberLeave(Map<String,String> map);
25 42 }
... ...
cloud/search_smartCampus/src/main/java/com/sincere/smartSearch/model/KqChamber.java 0 → 100644
... ... @@ -0,0 +1,27 @@
  1 +package com.sincere.smartSearch.model;
  2 +
  3 +/**
  4 + * @author chen
  5 + * @version 1.0
  6 + * @date 2019/12/5 0005 10:02
  7 + */
  8 +public class KqChamber {
  9 + private int id ;
  10 + private String name ;
  11 +
  12 + public int getId() {
  13 + return id;
  14 + }
  15 +
  16 + public void setId(int id) {
  17 + this.id = id;
  18 + }
  19 +
  20 + public String getName() {
  21 + return name;
  22 + }
  23 +
  24 + public void setName(String name) {
  25 + this.name = name;
  26 + }
  27 +}
... ...
cloud/search_smartCampus/src/main/java/com/sincere/smartSearch/service/KqService.java
... ... @@ -2,6 +2,7 @@ package com.sincere.smartSearch.service;
2 2  
3 3 import com.sincere.common.dto.smartCampus.AppDto;
4 4 import com.sincere.common.dto.smartCampus.CensusKqDto;
  5 +import com.sincere.common.dto.smartCampus.KqDto;
5 6 import com.sincere.common.dto.smartCampus.KqTeacherDto;
6 7 import com.sincere.smartSearch.model.KqTemplate;
7 8  
... ... @@ -19,7 +20,11 @@ public interface KqService {
19 20  
20 21 List<KqTeacherDto> selectSchoolTeacher(int schoolId);
21 22  
  23 + List<KqTeacherDto> selectChamberTeacher(int schoolId);
  24 +
22 25 AppDto selectApp(Map<String,Integer> map);
23 26  
24   - List<CensusKqDto> selectCensusKq(Map<String ,String> map);
  27 + List<CensusKqDto> selectCensusKq(KqDto kqDto);
  28 +
  29 + List<CensusKqDto> selectCensusChamberKq(KqDto kqDto);
25 30 }
... ...
cloud/search_smartCampus/src/main/java/com/sincere/smartSearch/service/impl/KqServiceImpl.java
... ... @@ -2,15 +2,17 @@ package com.sincere.smartSearch.service.impl;
2 2  
3 3 import com.sincere.common.dto.smartCampus.AppDto;
4 4 import com.sincere.common.dto.smartCampus.CensusKqDto;
  5 +import com.sincere.common.dto.smartCampus.KqDto;
5 6 import com.sincere.common.dto.smartCampus.KqTeacherDto;
  7 +import com.sincere.common.util.DateUtils;
6 8 import com.sincere.smartSearch.mapper.KqTemplateMapper;
  9 +import com.sincere.smartSearch.model.KqChamber;
7 10 import com.sincere.smartSearch.model.KqTemplate;
8 11 import com.sincere.smartSearch.service.KqService;
9 12 import org.springframework.beans.factory.annotation.Autowired;
10 13 import org.springframework.stereotype.Service;
11 14  
12   -import java.util.List;
13   -import java.util.Map;
  15 +import java.util.*;
14 16  
15 17 /**
16 18 * @author chen
... ... @@ -34,12 +36,63 @@ public class KqServiceImpl implements KqService {
34 36 }
35 37  
36 38 @Override
  39 + public List<KqTeacherDto> selectChamberTeacher(int schoolId) {
  40 + return kqTemplateMapper.selectChamberTeacher(schoolId);
  41 + }
  42 +
  43 + @Override
37 44 public AppDto selectApp(Map<String, Integer> map) {
38 45 return kqTemplateMapper.selectApp(map);
39 46 }
40 47  
41 48 @Override
42   - public List<CensusKqDto> selectCensusKq(Map<String, String> map) {
43   - return kqTemplateMapper.selectCensusKq(map);
  49 + public List<CensusKqDto> selectCensusKq(KqDto kqDto) {
  50 + String tableSuffix = DateUtils.date2String(new Date(), DateUtils.format);
  51 + Map<String,String> map = new HashMap<>();
  52 + map.put("userId",kqDto.getUserId());
  53 + map.put("tableName","SZ_AttendanceRecords"+tableSuffix);
  54 + map.put("type",kqDto.getType());
  55 + List<CensusKqDto> list = kqTemplateMapper.selectCensusKq(map);
  56 + for(CensusKqDto censusKqDto : list){
  57 + Map<String,String> sqlMap = new HashMap<>();
  58 + sqlMap.put("templateId",kqDto.getTemplateId());
  59 + sqlMap.put("classId",censusKqDto.getClassId()+"");
  60 + int i = kqTemplateMapper.selectClassDealDate(sqlMap);
  61 + String date = DateUtils.date2String(new Date(),DateUtils.format1);
  62 + sqlMap.put("endTime",date+" " + kqDto.getEndTime() +":00");
  63 + i = i + kqTemplateMapper.selectClassLeave(sqlMap);
  64 + censusKqDto.setKqT(censusKqDto.getKqT()+i);
  65 + }
  66 + return list ;
  67 + }
  68 +
  69 + @Override
  70 + public List<CensusKqDto> selectCensusChamberKq(KqDto kqDto) {
  71 + String tableSuffix = DateUtils.date2String(new Date(), DateUtils.format);
  72 + Map<String,String> map = new HashMap<>();
  73 + map.put("userId",kqDto.getUserId());
  74 + map.put("tableName","SZ_AttendanceRecords"+tableSuffix);
  75 + map.put("type",kqDto.getType());
  76 + List<CensusKqDto> list = new ArrayList<>();
  77 + List<KqChamber> chambers = kqTemplateMapper.selectChamberName(map.get("userId"));
  78 + for(KqChamber chamber :chambers){
  79 + CensusKqDto censusKqDto = new CensusKqDto();
  80 + map.put("id",chamber.getId()+"");
  81 + int allKq = kqTemplateMapper.selectChamberAllKq(map);
  82 + int trueKq = kqTemplateMapper.selectChamberTrueKq(map);
  83 + censusKqDto.setClassName(chamber.getName());
  84 + censusKqDto.setAllT(allKq);
  85 + Map<String,String> sqlMap = new HashMap<>();
  86 + sqlMap.put("templateId",kqDto.getTemplateId());
  87 + sqlMap.put("userId",kqDto.getUserId());
  88 + sqlMap.put("id",chamber.getId()+"");
  89 + int i = kqTemplateMapper.selectClassDealDate(sqlMap);
  90 + String date = DateUtils.date2String(new Date(),DateUtils.format1);
  91 + sqlMap.put("endTime",date+" " + kqDto.getEndTime() +":00");
  92 + i = i + kqTemplateMapper.selectChamberLeave(sqlMap);
  93 + censusKqDto.setKqT(trueKq+i);
  94 + list.add(censusKqDto);
  95 + }
  96 + return list;
44 97 }
45 98 }
... ...
cloud/search_smartCampus/src/main/resources/mapper/KqTemplateMapper.xml
... ... @@ -36,6 +36,13 @@
36 36 where a.role_state=1 and SZ_UserRole.userType = 0
37 37 </select>
38 38  
  39 + <select id="selectChamberTeacher" parameterType="java.lang.Integer" resultMap="TeacherMap">
  40 + select distinct a.user_id,a.school_id,a.name,a.mobile,a.face,a.pass, a.OpenId,a.QiYeHaoUserId,a.DingUserId
  41 + from SS_Room join SS_RoomManager on SS_Room.Id = SS_RoomManager.RoomId
  42 + join SZ_V_School_Teacher a on a.user_id = SS_RoomManager.ManagerId
  43 + where SS_Room.SchoolId = #{schoolId} and SS_Room.Status = 1
  44 + </select>
  45 +
39 46 <resultMap id="AppMap" type="com.sincere.common.dto.smartCampus.AppDto">
40 47 <result column="AgentId" property="agentId"/>
41 48 <result column="AgentSecret" property="agentSecret"/>
... ... @@ -46,12 +53,13 @@
46 53 </select>
47 54  
48 55 <resultMap id="KqMap" type="com.sincere.common.dto.smartCampus.CensusKqDto">
  56 + <result column="class_id" property="classId"/>
49 57 <result column="class_name" property="className"/>
50 58 <result column="allT" property="allT"/>
51 59 <result column="kqT" property="kqT"/>
52 60 </resultMap>
53 61 <select id="selectCensusKq" parameterType="java.util.Map" resultMap="KqMap">
54   - select distinct b.class_name,
  62 + select distinct b.class_id , b.class_name,
55 63 (select count(distinct user_id) from SZ_V_School_Student x where c.class_id=x.class_id) as allT,
56 64 (select count(distinct customerid) from dblan27.xiaoanhxy.dbo.${tableName} y
57 65 where convert(varchar(10),y.intime,120)=convert(varchar(10),getdate(),120) and y.class_id=c.class_id and y.card_type=#{type}) as kqT
... ... @@ -60,4 +68,76 @@
60 68 inner join SZ_V_School_Teacher a on a.user_id=c.user_id and c.usertype=0
61 69 where a.role_state=1 and a.user_id=#{userId}
62 70 </select>
  71 +
  72 + <select id="selectClassDealDate" parameterType="java.util.Map" resultType="java.lang.Integer">
  73 + select count(0) from EQ_DealData join SZ_V_School_Student on EQ_DealData.UserId = SZ_V_School_Student.user_id
  74 + where EQ_DealData.DealState in ('出勤','请假')
  75 + and EQ_DealData.TemplateId = #{templateId} and DealDate = CONVERT ( VARCHAR ( 10 ), getdate(), 120 )
  76 + and SZ_V_School_Student.class_id = #{classId}
  77 + </select>
  78 +
  79 + <select id="selectClassLeave" parameterType="java.util.Map" resultType="java.lang.Integer">
  80 + select count(0) from HS_LeaveExamine join SZ_V_School_Student on HS_LeaveExamine.StudentId = SZ_V_School_Student.student_id
  81 + where HS_LeaveExamine.State in (2,7,8,9,10,11) and HS_LeaveExamine.ReturnTime &gt; #{endTime}
  82 + and SZ_V_School_Student.class_id = #{classId}
  83 + </select>
  84 +
  85 + <resultMap id="ChamberMap" type="com.sincere.smartSearch.model.KqChamber">
  86 + <result column="Id" property="id"/>
  87 + <result column="name" property="name"/>
  88 + </resultMap>
  89 + <select id="selectChamberName" parameterType="java.lang.String" resultMap="ChamberMap">
  90 + select SS_Room.Id , SS_Room.name as name from SS_RoomManager join SS_Room on SS_Room.Id = SS_RoomManager.RoomId
  91 + where SS_RoomManager.ManagerId = #{userId}
  92 + </select>
  93 +
  94 + <select id="selectChamberAllKq" parameterType="java.util.Map" resultType="java.lang.Integer">
  95 + select count(0) as allT from SS_Room join SS_RoomNumber on SS_Room.Id = SS_RoomNumber.Pid
  96 + where SS_Room.Pid in (
  97 + select SS_Room.ID from SS_RoomManager join SS_Room on SS_Room.Id = SS_RoomManager.RoomId
  98 + where SS_RoomManager.ManagerId = #{userId} and SS_Room.Id = ${id}
  99 + ) and SS_RoomNumber.StudentId != 0
  100 + </select>
  101 +
  102 + <select id="selectChamberTrueKq" parameterType="java.util.Map" resultType="java.lang.Integer">
  103 + SELECT COUNT ( DISTINCT customerid ) AS kqT FROM dblan27.xiaoanhxy.dbo.${tableName} y
  104 + WHERE CONVERT ( VARCHAR ( 10 ), y.intime, 120 ) = CONVERT ( VARCHAR ( 10 ), getdate(), 120 )
  105 + AND y.card_type= #{type}
  106 + AND y.customerId IN (
  107 + SELECT SS_RoomNumber.StudentId AS customerId
  108 + FROM SS_RoomNumber JOIN SS_Room ON SS_Room.Id = SS_RoomNumber.Pid
  109 + WHERE SS_Room.Pid IN (
  110 + SELECT SS_Room.ID FROM SS_RoomManager JOIN SS_Room ON SS_Room.Id = SS_RoomManager.RoomId
  111 + WHERE SS_RoomManager.ManagerId = #{userId} and SS_Room.Id = ${id}
  112 + )
  113 + AND SS_RoomNumber.StudentId != 0
  114 + )
  115 + </select>
  116 +
  117 + <select id="selectChamberDealDate" parameterType="java.util.Map" resultType="java.lang.Integer">
  118 + select count(0) from EQ_DealData join SZ_V_School_Student on EQ_DealData.UserId = SZ_V_School_Student.user_id
  119 + where EQ_DealData.DealState in ('出勤','请假')
  120 + and EQ_DealData.TemplateId = #{templateId} and DealDate = CONVERT ( VARCHAR ( 10 ), getdate(), 120 )
  121 + and SZ_V_School_Student.student_id in (
  122 + select SS_RoomNumber.StudentId from SS_Room join SS_RoomNumber on SS_Room.Id = SS_RoomNumber.Pid
  123 + where SS_Room.Pid in (
  124 + select SS_Room.ID from SS_RoomManager join SS_Room on SS_Room.Id = SS_RoomManager.RoomId
  125 + where SS_RoomManager.ManagerId = #{userId} and SS_Room.Id = ${id}
  126 + ) and SS_RoomNumber.StudentId != 0
  127 + )
  128 + </select>
  129 +
  130 + <select id="selectChamberLeave" parameterType="java.util.Map" resultType="java.lang.Integer">
  131 + select count(0) from HS_LeaveExamine join SZ_V_School_Student on HS_LeaveExamine.StudentId = SZ_V_School_Student.student_id
  132 + where HS_LeaveExamine.State in (2,7,8,9,10,11) and HS_LeaveExamine.ReturnTime &gt; #{endTime}
  133 + and SZ_V_School_Student.student_id in (
  134 + select SS_RoomNumber.StudentId from SS_Room join SS_RoomNumber on SS_Room.Id = SS_RoomNumber.Pid
  135 + where SS_Room.Pid in (
  136 + select SS_Room.ID from SS_RoomManager join SS_Room on SS_Room.Id = SS_RoomManager.RoomId
  137 + where SS_RoomManager.ManagerId = #{userId} and SS_Room.Id = ${id}
  138 + ) and SS_RoomNumber.StudentId != 0
  139 + )
  140 + </select>
  141 +
  142 +
63 143 </mapper>
... ...