|
@@ -1,5 +1,8 @@
|
|
|
package thyyxxk.webserver.service.clockin;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -8,8 +11,11 @@ import thyyxxk.webserver.pojo.ResultVo;
|
|
|
import thyyxxk.webserver.pojo.clockin.ClockinPojo;
|
|
|
import thyyxxk.webserver.pojo.clockin.ClockinViewPojo;
|
|
|
import thyyxxk.webserver.pojo.clockin.QueryFromDbParam;
|
|
|
+import thyyxxk.webserver.utils.DateUtil;
|
|
|
+import thyyxxk.webserver.utils.ExcelUtil;
|
|
|
import thyyxxk.webserver.utils.ResultVoUtil;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
@@ -25,10 +31,45 @@ public class ClockinService {
|
|
|
this.dao = dao;
|
|
|
}
|
|
|
|
|
|
- public ResultVo<List<ClockinViewPojo>> getClockinDataFromDb(QueryFromDbParam param) {
|
|
|
- List<ClockinPojo> origin = (null == param.getUserList() || param.getUserList().isEmpty()) ?
|
|
|
- dao.getAllClockInDataFromDb(param) : dao.getClockInDataFromDb(param);
|
|
|
- return ResultVoUtil.success(combineData(origin));
|
|
|
+ public ResultVo<Map<String, Object>> getClockinDataFromDb(QueryFromDbParam param) {
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ IPage<ClockinPojo> iPage = getClockinIPage(param);
|
|
|
+ map.put("totalSize", iPage.getTotal());
|
|
|
+ map.put("list", combineData(iPage.getRecords()));
|
|
|
+ return ResultVoUtil.success(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void exportExcel(HttpServletResponse response, QueryFromDbParam param) {
|
|
|
+ log.info("导出打卡数据Excel: {}", JSON.toJSONString(param));
|
|
|
+ IPage<ClockinPojo> iPage = getClockinIPage(param);
|
|
|
+ List<ClockinViewPojo> list = combineData(iPage.getRecords());
|
|
|
+ String[] title = {"日期","姓名","工号","科室", "打卡次数", "工作时长", "上班打卡时间", "上班打卡地点",
|
|
|
+ "上班打卡状态", "上班打卡备注", "下班打卡时间", "下班打卡地点", "下班打卡状态", "下班打卡备注"};
|
|
|
+ String[][] content = new String[list.size()][];
|
|
|
+ for (int i = 0; i < list.size(); i++) {
|
|
|
+ content[i] = new String[title.length];
|
|
|
+ ClockinViewPojo pojo = list.get(i);
|
|
|
+ content[i][0] = pojo.getCheckinDate();
|
|
|
+ content[i][1] = pojo.getName();
|
|
|
+ content[i][2] = pojo.getUserid();
|
|
|
+ content[i][3] = pojo.getDept();
|
|
|
+ content[i][4] = String.valueOf(pojo.getTimes());
|
|
|
+ content[i][5] = pojo.getWorktime();
|
|
|
+ content[i][6] = pojo.getCheckinHourOn();
|
|
|
+ content[i][7] = pojo.getCheckinAddrOn();
|
|
|
+ content[i][8] = pojo.getCheckinStateOn();
|
|
|
+ content[i][9] = pojo.getNotesOn();
|
|
|
+ content[i][10] = pojo.getCheckinHourOff();
|
|
|
+ content[i][11] = pojo.getCheckinAddrOff();
|
|
|
+ content[i][12] = pojo.getCheckinStateOff();
|
|
|
+ content[i][13] = pojo.getNotesOff();
|
|
|
+ }
|
|
|
+ ExcelUtil.exportExcel(response, title, content);
|
|
|
+ }
|
|
|
+
|
|
|
+ private IPage<ClockinPojo> getClockinIPage(QueryFromDbParam param) {
|
|
|
+ IPage<ClockinPojo> iPage = new Page<>(param.getCurrentPage(), param.getPageSize());
|
|
|
+ return dao.getAllClockInDataFromDb(iPage, param.getStart(), param.getEnd());
|
|
|
}
|
|
|
|
|
|
private List<ClockinViewPojo> combineData(List<ClockinPojo> origin) {
|