Crunchy
2024-05-08 2e770d5ad27afd5cec0ea8759ca37504a883b42f
2024-5-8 绩效管理-班次后端开发完成
已修改5个文件
58 ■■■■ 文件已修改
performance-server/src/main/java/com/yuanchu/mom/controller/PerformanceShiftController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
performance-server/src/main/java/com/yuanchu/mom/mapper/PerformanceShiftMapper.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
performance-server/src/main/java/com/yuanchu/mom/service/PerformanceShiftService.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
performance-server/src/main/java/com/yuanchu/mom/service/impl/PerformanceShiftServiceImpl.java 39 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
performance-server/src/main/resources/mapper/PerformanceShiftMapper.xml 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
performance-server/src/main/java/com/yuanchu/mom/controller/PerformanceShiftController.java
@@ -37,7 +37,7 @@
    @ApiOperation(value = "绩效管理-班次-分页查询")
    @PostMapping("page")
    public Result<?> performanceShiftPage(Integer size, Integer current, LocalDateTime time, String userName, String laboratory) {
    public Result<?> performanceShiftPage(Integer size, Integer current, String time, String userName, String laboratory) {
        return Result.success(performanceShiftService.performanceShiftPage(new Page<>(current, size), time, userName, laboratory));
    }
performance-server/src/main/java/com/yuanchu/mom/mapper/PerformanceShiftMapper.java
@@ -1,12 +1,11 @@
package com.yuanchu.mom.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yuanchu.mom.pojo.PerformanceShift;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springframework.data.repository.query.Param;
import java.time.LocalDateTime;
import java.util.Map;
/**
@@ -21,7 +20,7 @@
    IPage<Map<String, Object>> performanceShiftPage(
            Page<Object> page,
            @Param("time") LocalDateTime time,
            @Param("time") String time,
            @Param("userName") String userName,
            @Param("laboratory") String laboratory
    );
performance-server/src/main/java/com/yuanchu/mom/service/PerformanceShiftService.java
@@ -6,7 +6,6 @@
import com.yuanchu.mom.dto.PerformanceShiftAddDto;
import com.yuanchu.mom.pojo.PerformanceShift;
import java.time.LocalDateTime;
import java.util.Map;
/**
@@ -21,7 +20,7 @@
    void performanceShiftAdd(PerformanceShiftAddDto performanceShiftAddDto);
    IPage<Map<String, Object>> performanceShiftPage(Page<Object> page, LocalDateTime time, String userName, String laboratory);
    IPage<Map<String, Object>> performanceShiftPage(Page<Object> page, String time, String userName, String laboratory);
    void performanceShiftUpdate(String shift, Integer id);
}
performance-server/src/main/java/com/yuanchu/mom/service/impl/PerformanceShiftServiceImpl.java
@@ -48,35 +48,36 @@
    }
    @Override
    public IPage<Map<String, Object>> performanceShiftPage(Page<Object> page, LocalDateTime time, String userName, String laboratory) {
    public IPage<Map<String, Object>> performanceShiftPage(Page<Object> page, String time, String userName, String laboratory) {
        IPage<Map<String, Object>> mapIPage = baseMapper.performanceShiftPage(page, time, userName, laboratory);
        List<Enums> shiftType = enumService.selectEnumByCategory("班次类型");
        for (Map<String, Object> i : mapIPage.getRecords()) {
            String[] shiftTimes = i.get("shiftTime").toString().split(";");
            int totalAttendance = 0;
            Map<Object, Object> map = new HashMap<>();
            for (Enums enums : shiftType) {
                int num = 0;
                // 分割日期
                for (String shiftTime : shiftTimes) {
                    Map<Object, Object> hashMap = new HashMap<>();
                    String[] shiftTimeAndShift = shiftTime.split(":");
            List<Object> map = new ArrayList<>();
            // 分割日期
            for (String shiftTime : shiftTimes) {
                Map<Object, Object> hashMap = new HashMap<>();
                String[] shiftTimeAndShift = shiftTime.split(":");
                for (Enums enums : shiftType) {
                    int num = 0;
                    if (enums.getValue().equals(shiftTimeAndShift[1])) {
                        num++;
                    }
                    hashMap.put("id", shiftTimeAndShift[2]);
                    hashMap.put("shift", shiftTimeAndShift[1]);
                    hashMap.put("weekly", DateUtil.weekOfYear(DateUtil.parse(shiftTimeAndShift[0])));
                    hashMap.put("time", shiftTimeAndShift[0]);
                    map.put(getWeek(shiftTimeAndShift[0]), hashMap);
                    i.put(enums.getLabel(), num);
                    if (!enums.getValue().equals("3") && !enums.getValue().equals("4")) {
                        i.put("totalAttendance", totalAttendance += num);
                    }
                }
                i.put(enums.getLabel(), num);
                i.put("list", map);
                if(!enums.getValue().equals("3") && !enums.getValue().equals("4")) {
                    i.put("totalAttendance", totalAttendance += num);
                }
                i.remove("shiftTime");
                hashMap.put("id", shiftTimeAndShift[2]);
                hashMap.put("shift", shiftTimeAndShift[1]);
                hashMap.put("weekly", DateUtil.weekOfYear(DateUtil.parse(shiftTimeAndShift[0])));
                hashMap.put("time", shiftTimeAndShift[0]);
                hashMap.put("headerTime", getWeek(shiftTimeAndShift[0]));
                map.add(hashMap);
            }
            i.put("list", map);
            i.remove("shiftTime");
        }
        return mapIPage;
    }
performance-server/src/main/resources/mapper/PerformanceShiftMapper.xml
@@ -8,15 +8,16 @@
        GROUP_CONCAT(s.work_time, ':', s.shift, ':', s.id SEPARATOR ';') AS shiftTime
        FROM performance_shift s
        LEFT JOIN user u on u.id = s.user_id
        GROUP BY u.id
        <where>
            <if test="time != null and time != ''">
                and s.work_time in DATE_FORMAT(#{time}, '%Y-%m-%d')
                and DATE_FORMAT(s.work_time, '%Y-%m') = DATE_FORMAT(#{time}, '%Y-%m' )
            </if>
            <if test="userName != null and userName != ''">
                and s.name concat('%', #{userName}, '%')
                and u.name like concat('%', #{userName}, '%')
            </if>
            <if test="laboratory != null and laboratory != ''"></if>
            <if test="laboratory != null and laboratory != ''">
            </if>
        </where>
        GROUP BY u.id
    </select>
</mapper>