|
@@ -1,19 +1,34 @@
|
|
|
package com.jeeplus.modules.wexintheorder.web;
|
|
|
|
|
|
import com.google.common.collect.Lists;
|
|
|
+import com.jeeplus.common.config.Global;
|
|
|
+import com.jeeplus.common.persistence.Page;
|
|
|
+import com.jeeplus.common.utils.DateUtils;
|
|
|
+import com.jeeplus.common.utils.StringUtils;
|
|
|
+import com.jeeplus.common.utils.excel.ExportExcel;
|
|
|
import com.jeeplus.common.web.BaseController;
|
|
|
+import com.jeeplus.modules.sys.entity.User;
|
|
|
+import com.jeeplus.modules.sys.service.UserService;
|
|
|
+import com.jeeplus.modules.sys.utils.UserUtils;
|
|
|
import com.jeeplus.modules.wexinpackage.access.util.encryption.AesException;
|
|
|
import com.jeeplus.modules.wexinpackage.access.util.encryption.WXBizMsgCrypt;
|
|
|
import com.jeeplus.modules.wexintheorder.Utils.OrderUtils;
|
|
|
+import com.jeeplus.modules.wexintheorder.entity.ClockInRecordInfo;
|
|
|
import com.jeeplus.modules.wexintheorder.service.ClockInRecordService;
|
|
|
+import com.jeeplus.modules.workclientinfo.entity.WorkClientInfo;
|
|
|
+import com.jeeplus.modules.workclientinfo.entity.WorkClientLinkman;
|
|
|
+import com.jeeplus.modules.workdevicerecord.entity.WorkDeviceRecord;
|
|
|
import net.sf.json.JSONObject;
|
|
|
+import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.ui.Model;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
+import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
@@ -45,80 +60,144 @@ public class ClockInRecordController extends BaseController {
|
|
|
|
|
|
@Autowired
|
|
|
private ClockInRecordService clockInRecordService;
|
|
|
+ @Autowired
|
|
|
+ private UserService userService;
|
|
|
|
|
|
|
|
|
-
|
|
|
- @RequestMapping(value = "getTest")
|
|
|
- public void list(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
|
|
- // 微信加密签名
|
|
|
- String msg_signature = request.getParameter("msg_signature");
|
|
|
- // 时间戳
|
|
|
- String timestamp = request.getParameter("timestamp");
|
|
|
- // 随机数
|
|
|
- String nonce = request.getParameter("nonce");
|
|
|
- // 随机字符串
|
|
|
- String echostr = request.getParameter("echostr");
|
|
|
-
|
|
|
- System.out.println("request=" + request.getRequestURL());
|
|
|
-
|
|
|
- PrintWriter out = response.getWriter();
|
|
|
- // 通过检验msg_signature对请求进行校验,若校验成功则原样返回echostr,表示接入成功,否则接入失败
|
|
|
- String result = null;
|
|
|
- try {
|
|
|
- WXBizMsgCrypt wxcpt = new WXBizMsgCrypt(TOKEN, ENCODINGAES_KEY, CORP_ID);
|
|
|
- result = wxcpt.VerifyURL(msg_signature, timestamp, nonce, echostr);
|
|
|
- } catch (AesException e) {
|
|
|
- e.printStackTrace();
|
|
|
+ /**
|
|
|
+ * 客户管理列表页面
|
|
|
+ */
|
|
|
+ @RequiresPermissions("clockInRecord:clockInRecord:list")
|
|
|
+ @RequestMapping(value = {"list", ""})
|
|
|
+ public String list(ClockInRecordInfo clockInRecordInfo, HttpServletRequest request, HttpServletResponse response, Model model) {
|
|
|
+ //进行查询之后进行任何操作,返回还是查询之后的数据页面
|
|
|
+ if (StringUtils.isNotBlank(clockInRecordInfo.getToflag())){
|
|
|
+ if (clockInRecordInfo.getToflag().equals("1")){
|
|
|
+ request.getSession().removeAttribute("clockInRecordInfo");
|
|
|
+ ClockInRecordInfo search=clockInRecordInfo;
|
|
|
+ request.getSession().setAttribute("clockInRecordInfo",search);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ if (request.getSession().getAttribute("clockInRecordInfo")!=null){
|
|
|
+ clockInRecordInfo= (ClockInRecordInfo) request.getSession().getAttribute("clockInRecordInfo");
|
|
|
+ model.addAttribute("clockInRecordInfo", clockInRecordInfo);
|
|
|
+ }
|
|
|
}
|
|
|
- if (result == null) {
|
|
|
- result = TOKEN;
|
|
|
+
|
|
|
+ if(UserUtils.isManager()){
|
|
|
+ model.addAttribute("flag","1");
|
|
|
}
|
|
|
- out.print(result);
|
|
|
- out.close();
|
|
|
- out = null;
|
|
|
+ Page<ClockInRecordInfo> page = clockInRecordService.findPage(new Page<ClockInRecordInfo>(request, response), clockInRecordInfo);
|
|
|
+ model.addAttribute("page", page);
|
|
|
+ return "modules/qw/clickInRecode/ClickInRecordList";
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 查询打卡记录信息
|
|
|
- * @param model
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "getClockInRecord")
|
|
|
@ResponseBody
|
|
|
@Transactional(readOnly = false)
|
|
|
- public Map<String,Object> getClockInRecord(Model model, @RequestParam String startDate, @RequestParam String endDate){
|
|
|
+ public Map<String,Object> getClockInRecord(@RequestParam Integer day){
|
|
|
Map<String,Object> map = new HashMap<>();
|
|
|
String accessToken = OrderUtils.getToken(CORP_ID, CORPSECRET);
|
|
|
+ List<User> includeQwUserIdAllUserList = userService.getIncludeQwUserIdAllUserList();
|
|
|
|
|
|
-
|
|
|
+ //获取当前日期前指定天数的时间信息
|
|
|
+ Map<String,String> dateMap = OrderUtils.getBeforeDayDate(day);
|
|
|
+ String startDate = dateMap.get("startDate");
|
|
|
+ String endDate = dateMap.get("endDate");
|
|
|
List<String> userIdList = Lists.newArrayList();
|
|
|
- userIdList.add("XuTeng");
|
|
|
//分批处理
|
|
|
- if(null!=userIdList && userIdList.size()>0){
|
|
|
+ if(null!=includeQwUserIdAllUserList && includeQwUserIdAllUserList.size()>0){
|
|
|
int pointsDataLimit = 100;//限制条数
|
|
|
- Integer size = userIdList.size();
|
|
|
+ Integer size = includeQwUserIdAllUserList.size();
|
|
|
//判断是否有必要分批
|
|
|
if(pointsDataLimit<size){
|
|
|
int part = size/pointsDataLimit;//分批数
|
|
|
//
|
|
|
for (int i = 0; i < part; i++) {
|
|
|
//100条
|
|
|
- List<String> userIds = userIdList.subList(0, pointsDataLimit);
|
|
|
+ List<User> userList = includeQwUserIdAllUserList.subList(0, pointsDataLimit);
|
|
|
+ for (User user : userList) {
|
|
|
+ userIdList.add(user.getQwUserId());
|
|
|
+ }
|
|
|
+ JSONObject checkInData = OrderUtils.getCheckInData(accessToken, userIdList,startDate,endDate);
|
|
|
+ clockInRecordService.disposeClockInRecordInfo(checkInData);
|
|
|
|
|
|
//剔除
|
|
|
- userIdList.subList(0, pointsDataLimit).clear();
|
|
|
+ includeQwUserIdAllUserList.subList(0, pointsDataLimit).clear();
|
|
|
}
|
|
|
- if(!userIdList.isEmpty()){
|
|
|
- String userIds = String.join(", ", userIdList);
|
|
|
+ if(!includeQwUserIdAllUserList.isEmpty()){
|
|
|
+ for (User user : includeQwUserIdAllUserList) {
|
|
|
+ userIdList.add(user.getQwUserId());
|
|
|
+ }
|
|
|
+ JSONObject checkInData = OrderUtils.getCheckInData(accessToken, userIdList,startDate,endDate);
|
|
|
+ clockInRecordService.disposeClockInRecordInfo(checkInData);
|
|
|
}
|
|
|
}else{
|
|
|
- String userIds = String.join(", ", userIdList);
|
|
|
+ for (User user : includeQwUserIdAllUserList) {
|
|
|
+ userIdList.add(user.getQwUserId());
|
|
|
+ }
|
|
|
+ JSONObject checkInData = OrderUtils.getCheckInData(accessToken, userIdList,startDate,endDate);
|
|
|
+ clockInRecordService.disposeClockInRecordInfo(checkInData);
|
|
|
}
|
|
|
}
|
|
|
- JSONObject checkInData = OrderUtils.getCheckInData(accessToken, userIdList,startDate,endDate);
|
|
|
- clockInRecordService.disposeClockInRecordInfo(checkInData);
|
|
|
- map.put("返回结果",checkInData);
|
|
|
+ map.put("返回结果","数据处理成功");
|
|
|
return map;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 导出excel文件
|
|
|
+ */
|
|
|
+ @RequiresPermissions("clockInRecord:clockInRecord:export")
|
|
|
+ @RequestMapping(value = "export", method= RequestMethod.POST)
|
|
|
+ public String exportFile(ClockInRecordInfo clockInRecordInfo, HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes) {
|
|
|
+ try {
|
|
|
+ String fileName = "打卡记录"+ DateUtils.getDate("yyyyMMddHHmmss")+".xlsx";
|
|
|
+ Page<ClockInRecordInfo> page = clockInRecordService.findPage(new Page<ClockInRecordInfo>(request, response, -1), clockInRecordInfo);
|
|
|
+ new ExportExcel("打卡记录", ClockInRecordInfo.class).setDataList(page.getList()).write(response, fileName).dispose();
|
|
|
+ return null;
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.error("Exception e:"+e);
|
|
|
+ addMessage(redirectAttributes, "导出打卡记录失败!失败信息:"+e.getMessage());
|
|
|
+ }
|
|
|
+ return "redirect:"+ Global.getAdminPath()+"/clockInRecordController/?repage";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @RequestMapping(value = "getTest")
|
|
|
+ public void list(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
|
|
+ // 微信加密签名
|
|
|
+ String msg_signature = request.getParameter("msg_signature");
|
|
|
+ // 时间戳
|
|
|
+ String timestamp = request.getParameter("timestamp");
|
|
|
+ // 随机数
|
|
|
+ String nonce = request.getParameter("nonce");
|
|
|
+ // 随机字符串
|
|
|
+ String echostr = request.getParameter("echostr");
|
|
|
+
|
|
|
+ System.out.println("request=" + request.getRequestURL());
|
|
|
+
|
|
|
+ PrintWriter out = response.getWriter();
|
|
|
+ // 通过检验msg_signature对请求进行校验,若校验成功则原样返回echostr,表示接入成功,否则接入失败
|
|
|
+ String result = null;
|
|
|
+ try {
|
|
|
+ WXBizMsgCrypt wxcpt = new WXBizMsgCrypt(TOKEN, ENCODINGAES_KEY, CORP_ID);
|
|
|
+ result = wxcpt.VerifyURL(msg_signature, timestamp, nonce, echostr);
|
|
|
+ } catch (AesException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ if (result == null) {
|
|
|
+ result = TOKEN;
|
|
|
+ }
|
|
|
+ out.print(result);
|
|
|
+ out.close();
|
|
|
+ out = null;
|
|
|
+ }
|
|
|
}
|