| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- package cn.com.lzt.userclock.service.impl;
- import cn.com.lzt.common.util.StringUtil;
- import cn.com.lzt.overtimerecord.entity.OvertimeRecordEntity;
- import cn.com.lzt.overtimerecord.service.OvertimeRecordServiceI;
- import cn.com.lzt.userclock.service.UserClockService;
- import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
- import com.baomidou.mybatisplus.core.metadata.IPage;
- import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
- import com.daju.common.util.DataPage;
- import com.daju.mix.dao.entity.TBUserClock;
- import com.daju.mix.dao.mapper.TBUserClockMapper;
- import com.daju.mix.dao.service.impl.BaseServiceImpl;
- import com.daju.mix.dto.TBUserClockDto;
- import org.springframework.stereotype.Service;
- import javax.annotation.Resource;
- import java.util.List;
- import java.util.Map;
- /**
- * @author :sahib.kio.m
- * @date :Created in 2021/8/9 下午1:52
- */
- @Service
- public class UserClockServiceImpl extends BaseServiceImpl<TBUserClockMapper, TBUserClock> implements UserClockService {
- // 上班
- private static final String WORKING = "1";
- // 下班
- private static final String STOP_WORKING = "2";
- // 加班
- private static final String OVER_WORKING = "1";
- @Resource
- private OvertimeRecordServiceI overtimeRecordServiceI;
- public DataPage clockList(Map<String, String> param) {
- DataPage result = new DataPage();
- int page = 1;
- if (param.containsKey("page")) {
- page = Integer.valueOf(param.get("page"));
- }
- int rows = 50;
- if (param.containsKey("rows")) {
- rows = Integer.valueOf(param.get("rows"));
- }
- String code = param.get("code");
- String userNum = param.get("userNum");
- String userId = param.get("user.id");
- String userName = param.get("user.id.str");
- String depart = param.get("depart");
- String post = param.get("post");
- String start = param.get("clock_time_begin1");
- String end = param.get("clock_time_end2");
- QueryWrapper<?> queryWrapper = new QueryWrapper<>();
- String selectSql = " SELECT TBUC.*, TSBU.REALNAME AS NAME, tbup.in_postid as post, tsbu.departid as depart,TSU.USERNUM as userNum\n" +
- "FROM T_B_USER_CLOCK TBUC\n" +
- " left join t_bus_user_personnel tbup on TBUC.user_id = tbup.userid\n" +
- " left join t_bus_post tbp on tbup.in_postid = tbp.id\n" +
- " LEFT JOIN T_S_BASE_USER TSBU ON TBUC.USER_ID = TSBU.ID\n" +
- " LEFT JOIN T_S_USER TSU ON TBUC.USER_ID = TSU.ID " +
- "WHERE 1 = 1 ";
- if (!StringUtil.isEmpty(code)) {
- selectSql += "AND TBUC.code like '%" + code + "%' ";
- }
- if (!StringUtil.isEmpty(userNum)) {
- selectSql += "AND TSU.USERNUM like '%" + userNum + "%' ";
- }
- if (!StringUtil.isEmpty(userName)) {
- selectSql += "and TBUC.user_id in (select id from t_s_base_user where realname like '%"+userName+"%') ";
- }
- if (!StringUtil.isEmpty(userId)) {
- selectSql += "and TBUC.user_id = '" + userId + "' ";
- }
- if (!StringUtil.isEmpty(depart)) {
- selectSql += "and tsbu.departid = '" + depart + "' ";
- }
- if (!StringUtil.isEmpty(post)) {
- selectSql += "and tbup.in_postid = '" + post + "' ";
- }
- if (!StringUtil.isEmpty(start)) {
- selectSql += "and TBUC.clock_time >= '" + start + "' ";
- }
- if (!StringUtil.isEmpty(end)) {
- selectSql += "and TBUC.clock_time <= '" + end + "' ";
- }
- IPage<Map<String, Object>> mapPage = getBaseMapper().queryMapPageBySql(new Page<>(page, rows), queryWrapper, selectSql);
- result.setList(mapPage.getRecords());
- result.setTotalCount((int) mapPage.getTotal());
- return result;
- }
- @Override
- public List<TBUserClockDto> listOrderByUserIdAndTime(String YearAndMonth, String userId) throws Exception {
- List<TBUserClockDto> tbUserClockDtos = baseMapper.listOrderByUserIdAndTime(YearAndMonth, userId);
- List<OvertimeRecordEntity> overtimeRecordEntities = overtimeRecordServiceI.getOvertimeRecordEntities(userId,YearAndMonth);
- tbUserClockDtos.forEach(tbUserClockDto -> {
- if (OVER_WORKING.equals(tbUserClockDto.getWorkType())) {
- // 加班
- if (WORKING.equals(tbUserClockDto.getClockType())) {
- tbUserClockDto.setOverTime(tbUserClockDto.getClockTime());
- }
- if (STOP_WORKING.equals(tbUserClockDto.getClockType())) {
- tbUserClockDto.setStopOvertime(tbUserClockDto.getClockTime());
- }
- } else {
- if (WORKING.equals(tbUserClockDto.getClockType())) {
- tbUserClockDto.setWorkingTime(tbUserClockDto.getClockTime());
- }
- if (STOP_WORKING.equals(tbUserClockDto.getClockType())) {
- tbUserClockDto.setStopWorkingTime(tbUserClockDto.getClockTime());
- }
- }
- });
- return tbUserClockDtos;
- }
- }
|