فهرست منبع

员工绩效统计

wukai 4 ماه پیش
والد
کامیت
e1fec91917

+ 6 - 5
jjt-admin/src/test/java/com/jjt/task/TaskTest.java

@@ -4,6 +4,8 @@ import com.jjt.JjtApplication;
 import com.jjt.biz.service.IApiService;
 import com.jjt.calc.service.ITwinCalcDayService;
 import com.jjt.calc.service.ITwinCalcHourService;
+import com.jjt.common.utils.DateUtils;
+import com.jjt.emp.service.ITwinEmpCalcService;
 import org.junit.jupiter.api.Test;
 import org.springframework.boot.test.context.SpringBootTest;
 
@@ -27,6 +29,8 @@ public class TaskTest {
     private ITwinCalcHourService calcHourService;
     @Resource
     private ITwinCalcDayService dayService;
+    @Resource
+    private ITwinEmpCalcService empCalcService;
 
     @Test
     public void curr() {
@@ -38,12 +42,9 @@ public class TaskTest {
     public void last() {
 
         String date = "2025-01-17";
-//        for (int i = 3; i < 6; i++) {
-//            calcHourService.calc("2025-01-18", i);
-//        }
-//        calcHourService.calc(date, 22);
         LocalDate localDate = LocalDate.parse(date);
-        dayService.day(localDate);
+        empCalcService.calc(DateUtils.toDate(localDate));
+//        dayService.day(localDate);
 //        LocalDateTime ldt = LocalDateTime.of(localDate, LocalTime.MIN);
 //        ldt = ldt.plusHours(7);
 //        for (int i = 0; i < 24; i++) {

+ 12 - 0
jjt-biz/src/main/java/com/jjt/calc/domain/TwinCalcHourSpec.java

@@ -93,4 +93,16 @@ public class TwinCalcHourSpec extends BaseEntity {
     @Excel(name = "单价")
     private BigDecimal price;
 
+    @ApiModelProperty("班组")
+    private String team;
+
+    public void setTeam() {
+        if (this.hour >= 7 && this.hour < 19) {
+            //A班
+            this.team = "A";
+        } else {
+            //B班
+            this.team = "B";
+        }
+    }
 }

+ 9 - 0
jjt-biz/src/main/java/com/jjt/calc/service/ITwinCalcDayService.java

@@ -89,4 +89,13 @@ public interface ITwinCalcDayService {
      * @return 列表
      */
     List<TwinCalcDay> selectTwinCalcDayListByTime(Date sd);
+
+    /**
+     * 查询指定日期的数据
+     *
+     * @param sd 开始日期
+     * @param ed 结束日期
+     * @return 列表
+     */
+    List<TwinCalcDay> selectTwinCalcDayListByTime(Date sd, Date ed);
 }

+ 8 - 0
jjt-biz/src/main/java/com/jjt/calc/service/ITwinCalcHourSpecService.java

@@ -1,5 +1,6 @@
 package com.jjt.calc.service;
 
+import java.util.Date;
 import java.util.List;
 import com.jjt.calc.domain.TwinCalcHourSpec;
 
@@ -57,4 +58,11 @@ public interface ITwinCalcHourSpecService {
      * @return 结果
      */
     public int deleteTwinCalcHourSpecById(Long id);
+    /**
+     * 根据日期获取统计数据
+     *
+     * @param date 日期
+     * @return 结果
+     */
+    List<TwinCalcHourSpec> selectTwinCalcHourSpecListByDate(Date date);
 }

+ 12 - 0
jjt-biz/src/main/java/com/jjt/calc/service/impl/TwinCalcDayServiceImpl.java

@@ -368,4 +368,16 @@ public class TwinCalcDayServiceImpl implements ITwinCalcDayService {
     public List<TwinCalcDay> selectTwinCalcDayListByTime(Date sd) {
         return twinCalcDayMapper.selectTwinCalcDayListByTime(sd, null);
     }
+
+    /**
+     * 查询指定日期的数据
+     *
+     * @param sd 开始日期
+     * @param ed 结束日期
+     * @return 列表
+     */
+    @Override
+    public List<TwinCalcDay> selectTwinCalcDayListByTime(Date sd, Date ed) {
+        return twinCalcDayMapper.selectTwinCalcDayListByTime(sd, ed);
+    }
 }

+ 33 - 4
jjt-biz/src/main/java/com/jjt/calc/service/impl/TwinCalcHourSpecServiceImpl.java

@@ -1,11 +1,19 @@
 package com.jjt.calc.service.impl;
 
-import java.util.List;
-import org.springframework.stereotype.Service;
-import com.jjt.calc.mapper.TwinCalcHourSpecMapper;
 import com.jjt.calc.domain.TwinCalcHourSpec;
+import com.jjt.calc.mapper.TwinCalcHourSpecMapper;
 import com.jjt.calc.service.ITwinCalcHourSpecService;
+import com.jjt.common.utils.DateUtils;
+import com.jjt.utils.Tools;
+import javafx.util.Pair;
+import org.springframework.stereotype.Service;
+
 import javax.annotation.Resource;
+import java.time.LocalDate;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 /**
  * 按配方1小时统计数据Service业务层处理
@@ -48,7 +56,7 @@ public class TwinCalcHourSpecServiceImpl implements ITwinCalcHourSpecService {
      */
     @Override
     public int insertTwinCalcHourSpec(TwinCalcHourSpec twinCalcHourSpec) {
-            return twinCalcHourSpecMapper.insertTwinCalcHourSpec(twinCalcHourSpec);
+        return twinCalcHourSpecMapper.insertTwinCalcHourSpec(twinCalcHourSpec);
     }
 
     /**
@@ -83,4 +91,25 @@ public class TwinCalcHourSpecServiceImpl implements ITwinCalcHourSpecService {
     public int deleteTwinCalcHourSpecById(Long id) {
         return twinCalcHourSpecMapper.deleteTwinCalcHourSpecById(id);
     }
+
+    /**
+     * 根据日期获取统计数据
+     *
+     * @param date 日期
+     * @return 结果
+     */
+    @Override
+    public List<TwinCalcHourSpec> selectTwinCalcHourSpecListByDate(Date date) {
+        LocalDate localDate = DateUtils.toLocalDate(date);
+        //计算统计时间
+        Pair<Date, Date> pair = Tools.calcDay(localDate);
+        Date sTime = pair.getKey();
+        Date eTime = pair.getValue();
+        TwinCalcHourSpec hour = new TwinCalcHourSpec();
+        Map<String, Object> params = new HashMap<>(16);
+        params.put("sTime", sTime);
+        params.put("eTime", eTime);
+        hour.setParams(params);
+        return selectTwinCalcHourSpecList(hour);
+    }
 }

+ 47 - 22
jjt-biz/src/main/java/com/jjt/emp/domain/TwinEmpCalc.java

@@ -1,16 +1,15 @@
 package com.jjt.emp.domain;
 
-import java.math.BigDecimal;
-import java.util.Date;
-import com.fasterxml.jackson.annotation.JsonFormat;
 import com.baomidou.mybatisplus.annotation.TableId;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.jjt.common.annotation.Excel;
+import com.jjt.common.core.domain.BaseEntity;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
-import org.apache.commons.lang3.builder.ToStringBuilder;
-import org.apache.commons.lang3.builder.ToStringStyle;
-import com.jjt.common.annotation.Excel;
-import com.jjt.common.core.domain.BaseEntity;
+
+import java.math.BigDecimal;
+import java.util.Date;
 
 /**
  * 员工产量统计对象 TWIN_EMP_CALC
@@ -20,71 +19,97 @@ import com.jjt.common.core.domain.BaseEntity;
  */
 @ApiModel(value = "TwinEmpCalc", description = "员工产量统计")
 @Data
-public class TwinEmpCalc extends BaseEntity{
+public class TwinEmpCalc extends BaseEntity {
     private static final long serialVersionUID = 1L;
 
-    /** 统计ID */
+    /**
+     * 统计ID
+     */
     @ApiModelProperty("统计ID")
     @TableId
     private Long calcId;
 
-    /** 姓名 */
+    /**
+     * 姓名
+     */
     @ApiModelProperty("姓名")
     @Excel(name = "姓名")
     private String empName;
 
-    /** 时间 */
+    /**
+     * 时间
+     */
     @ApiModelProperty("时间")
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     @Excel(name = "时间", width = 30, dateFormat = "yyyy-MM-dd")
     private Date empDate;
 
-    /** 班组 */
+    /**
+     * 班组
+     */
     @ApiModelProperty("班组")
     @Excel(name = "班组")
     private String empTeam;
 
-    /** 机台号 */
+    /**
+     * 机台号
+     */
     @ApiModelProperty("机台号")
     @Excel(name = "机台号")
     private Long deviceId;
 
-    /** 稼动率 */
+    /**
+     * 稼动率
+     */
     @ApiModelProperty("稼动率")
     @Excel(name = "稼动率")
     private BigDecimal efficiency;
 
-    /** 规格 */
+    /**
+     * 规格
+     */
     @ApiModelProperty("规格")
     @Excel(name = "规格")
     private String spec;
 
-    /** 米克重 */
+    /**
+     * 米克重
+     */
     @ApiModelProperty("米克重")
     @Excel(name = "米克重")
-    private Long mick;
+    private Integer mick;
 
-    /** 密度 */
+    /**
+     * 密度
+     */
     @ApiModelProperty("密度")
     @Excel(name = "密度")
     private BigDecimal density;
 
-    /** 产量 */
+    /**
+     * 产量
+     */
     @ApiModelProperty("产量")
     @Excel(name = "产量")
     private BigDecimal length;
 
-    /** 毛高 */
+    /**
+     * 毛高
+     */
     @ApiModelProperty("毛高")
     @Excel(name = "毛高")
     private BigDecimal height;
 
-    /** 单价 */
+    /**
+     * 单价
+     */
     @ApiModelProperty("单价")
     @Excel(name = "单价")
     private BigDecimal price;
 
-    /** 总价 */
+    /**
+     * 总价
+     */
     @ApiModelProperty("总价")
     @Excel(name = "总价")
     private BigDecimal totalPrice;

+ 16 - 7
jjt-biz/src/main/java/com/jjt/emp/mapper/TwinEmpCalcMapper.java

@@ -1,12 +1,13 @@
 package com.jjt.emp.mapper;
 
+import java.util.Date;
 import java.util.List;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.jjt.emp.domain.TwinEmpCalc;
 
 /**
  * 员工产量统计Mapper接口
- * 
+ *
  * @author wukai
  * @date 2025-01-18
  */
@@ -14,7 +15,7 @@ public interface TwinEmpCalcMapper extends BaseMapper<TwinEmpCalc>
 {
     /**
      * 查询员工产量统计
-     * 
+     *
      * @param calcId 员工产量统计主键
      * @return 员工产量统计
      */
@@ -22,7 +23,7 @@ public interface TwinEmpCalcMapper extends BaseMapper<TwinEmpCalc>
 
     /**
      * 查询员工产量统计列表
-     * 
+     *
      * @param twinEmpCalc 员工产量统计
      * @return 员工产量统计集合
      */
@@ -30,7 +31,7 @@ public interface TwinEmpCalcMapper extends BaseMapper<TwinEmpCalc>
 
     /**
      * 新增员工产量统计
-     * 
+     *
      * @param twinEmpCalc 员工产量统计
      * @return 结果
      */
@@ -38,7 +39,7 @@ public interface TwinEmpCalcMapper extends BaseMapper<TwinEmpCalc>
 
     /**
      * 修改员工产量统计
-     * 
+     *
      * @param twinEmpCalc 员工产量统计
      * @return 结果
      */
@@ -46,7 +47,7 @@ public interface TwinEmpCalcMapper extends BaseMapper<TwinEmpCalc>
 
     /**
      * 删除员工产量统计
-     * 
+     *
      * @param calcId 员工产量统计主键
      * @return 结果
      */
@@ -54,9 +55,17 @@ public interface TwinEmpCalcMapper extends BaseMapper<TwinEmpCalc>
 
     /**
      * 批量删除员工产量统计
-     * 
+     *
      * @param calcIds 需要删除的数据主键集合
      * @return 结果
      */
     public int deleteTwinEmpCalcByCalcIds(Long[] calcIds);
+    /**
+     * 按日期删除
+     *
+     * @param date 日期
+     */
+    void deleteTwinEmpCalcByDate(Date date);
+
+    List<TwinEmpCalc> selectTwinEmpCalcListByMonth(String month);
 }

+ 23 - 0
jjt-biz/src/main/java/com/jjt/emp/service/ITwinEmpCalcService.java

@@ -1,5 +1,6 @@
 package com.jjt.emp.service;
 
+import java.util.Date;
 import java.util.List;
 import com.jjt.emp.domain.TwinEmpCalc;
 
@@ -57,4 +58,26 @@ public interface ITwinEmpCalcService {
      * @return 结果
      */
     public int deleteTwinEmpCalcByCalcId(Long calcId);
+
+    /**
+     * 按日统计
+     *
+     * @param date 日期
+     * @return 结果
+     */
+    int calc(Date date);
+    /**
+     * 按日查询
+     *
+     * @param date 日期
+     * @return 结果
+     */
+    List<TwinEmpCalc> selectTwinEmpCalcListByDate(Date date);
+    /**
+     * 按月查询
+     *
+     * @param month 月份
+     * @return 结果
+     */
+    List<TwinEmpCalc> selectTwinEmpCalcListByMonth(String  month);
 }

+ 8 - 0
jjt-biz/src/main/java/com/jjt/emp/service/ITwinEmpService.java

@@ -1,5 +1,6 @@
 package com.jjt.emp.service;
 
+import java.util.Date;
 import java.util.List;
 import com.jjt.emp.domain.TwinEmp;
 
@@ -57,4 +58,11 @@ public interface ITwinEmpService {
      * @return 结果
      */
     public int deleteTwinEmpByEmpId(Long empId);
+    /**
+     * 按日期查询排班
+     *
+     * @param date 日期
+     * @return 排班结果
+     */
+    TwinEmp selectTwinEmpByDate(Date date);
 }

+ 168 - 4
jjt-biz/src/main/java/com/jjt/emp/service/impl/TwinEmpCalcServiceImpl.java

@@ -1,11 +1,29 @@
 package com.jjt.emp.service.impl;
 
-import java.util.List;
-import org.springframework.stereotype.Service;
-import com.jjt.emp.mapper.TwinEmpCalcMapper;
+import com.jjt.calc.domain.TwinCalcDay;
+import com.jjt.calc.domain.TwinCalcHourSpec;
+import com.jjt.calc.service.ITwinCalcDayService;
+import com.jjt.calc.service.ITwinCalcHourSpecService;
+import com.jjt.common.utils.StringUtils;
+import com.jjt.emp.domain.TwinEmp;
 import com.jjt.emp.domain.TwinEmpCalc;
+import com.jjt.emp.domain.TwinEmpConfig;
+import com.jjt.emp.domain.TwinEmpDetail;
+import com.jjt.emp.mapper.TwinEmpCalcMapper;
 import com.jjt.emp.service.ITwinEmpCalcService;
+import com.jjt.emp.service.ITwinEmpConfigService;
+import com.jjt.emp.service.ITwinEmpService;
+import com.jjt.utils.Tools;
+import org.apache.ibatis.session.ExecutorType;
+import org.apache.ibatis.session.SqlSession;
+import org.apache.ibatis.session.SqlSessionFactory;
+import org.springframework.stereotype.Service;
+
 import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * 员工产量统计Service业务层处理
@@ -17,6 +35,16 @@ import javax.annotation.Resource;
 public class TwinEmpCalcServiceImpl implements ITwinEmpCalcService {
     @Resource
     private TwinEmpCalcMapper twinEmpCalcMapper;
+    @Resource
+    private ITwinCalcHourSpecService hourSpecService;
+    @Resource
+    private ITwinEmpService empService;
+    @Resource
+    private ITwinEmpConfigService empConfigService;
+    @Resource
+    private ITwinCalcDayService twinCalcDayService;
+    @Resource
+    private SqlSessionFactory factory;
 
     /**
      * 查询员工产量统计
@@ -48,7 +76,7 @@ public class TwinEmpCalcServiceImpl implements ITwinEmpCalcService {
      */
     @Override
     public int insertTwinEmpCalc(TwinEmpCalc twinEmpCalc) {
-            return twinEmpCalcMapper.insertTwinEmpCalc(twinEmpCalc);
+        return twinEmpCalcMapper.insertTwinEmpCalc(twinEmpCalc);
     }
 
     /**
@@ -83,4 +111,140 @@ public class TwinEmpCalcServiceImpl implements ITwinEmpCalcService {
     public int deleteTwinEmpCalcByCalcId(Long calcId) {
         return twinEmpCalcMapper.deleteTwinEmpCalcByCalcId(calcId);
     }
+
+    /**
+     * 按日统计
+     *
+     * @param date 日期
+     * @return 结果
+     */
+    @Override
+    public int calc(Date date) {
+        //先删除
+        twinEmpCalcMapper.deleteTwinEmpCalcByDate(date);
+
+        //获取统计数据
+        List<TwinCalcHourSpec> specHourList = hourSpecService.selectTwinCalcHourSpecListByDate(date);
+        specHourList.forEach(obj -> obj.setTeam());
+        // 按照deviceId、density、mick、team,并统计每组的length总和
+        Map<String, List<TwinCalcHourSpec>> specHourMap = specHourList.stream().collect(Collectors.groupingBy(o -> o.getDeviceId() + "-" + o.getTeam(), LinkedHashMap::new, Collectors.toList()));
+        List<TwinCalcDay> twinCalcDays = twinCalcDayService.selectTwinCalcDayListByTime(date, date);
+        Map<Long, TwinCalcDay> calcMap = twinCalcDays.stream().collect(Collectors.toMap(TwinCalcDay::getDeviceId, o -> o));
+        TwinEmp emp = empService.selectTwinEmpByDate(date);
+
+        List<TwinEmpConfig> configs = empConfigService.selectTwinEmpConfigList(new TwinEmpConfig());
+        Map<BigDecimal, BigDecimal> configMap = configs.stream().collect(Collectors.toMap(o -> o.getDensity().setScale(2, RoundingMode.HALF_UP), TwinEmpConfig::getPrice));
+
+        List<TwinEmpCalc> calcList = new ArrayList<>();
+        process(true, emp, calcMap, configMap, calcList, specHourMap);
+        process(false, emp, calcMap, configMap, calcList, specHourMap);
+        if (calcList.size() > 0) {
+            try (SqlSession sqlSession = factory.openSession(ExecutorType.BATCH, false)) {
+                TwinEmpCalcMapper mapper = sqlSession.getMapper(TwinEmpCalcMapper.class);
+                calcList.forEach(mapper::insertTwinEmpCalc);
+                sqlSession.commit();
+            }
+        }
+        return 1;
+    }
+
+
+    /**
+     * @param flag true为A班false为B班
+     */
+    private void process(boolean flag, TwinEmp emp, Map<Long, TwinCalcDay> calcMap, Map<BigDecimal, BigDecimal> configMap, List<TwinEmpCalc> calcList, Map<String, List<TwinCalcHourSpec>> specHourMap) {
+        List<TwinEmpDetail> list = emp.getTwinEmpDetailListA();
+        String team = "A";
+        if (!flag) {
+            team = "B";
+            list = emp.getTwinEmpDetailListB();
+        }
+        for (TwinEmpDetail d : list) {
+            Long[] devices = getDevices(d.getDevices());
+            for (int i = 0; i < devices.length; i++) {
+                Long deviceId = devices[i];
+                List<TwinCalcHourSpec> specs = specHourMap.get(deviceId + "-" + team);
+                //按密度和米克重、毛高分组统计
+                Map<String, BigDecimal> resultMap = specs.stream().collect(Collectors.groupingBy(t -> t.getDensity() + "-" + t.getMick() + "-" + t.getHeight(), Collectors.reducing(BigDecimal.ZERO, TwinCalcHourSpec::getLength, BigDecimal::add)));
+                for (String ss : resultMap.keySet()) {
+                    String[] temp = ss.split("-");
+                    BigDecimal density = new BigDecimal(temp[0]).setScale(2, RoundingMode.HALF_UP);
+                    Integer mick = Integer.parseInt(temp[1]);
+                    TwinCalcDay td = calcMap.get(deviceId);
+                    TwinEmpCalc calc = new TwinEmpCalc();
+                    calc.setDeviceId(deviceId);
+                    if (StringUtils.isNotEmpty(temp[2]) && !"null".equals(temp[2])) {
+                        BigDecimal height = new BigDecimal(temp[2]).setScale(2, RoundingMode.HALF_UP);
+                        calc.setHeight(height);
+                    }
+                    calc.setEfficiency(td.getEfficiencyA());
+                    calc.setEmpDate(td.getTime());
+                    BigDecimal length = resultMap.get(ss);
+                    if (!flag) {
+                        calc.setEfficiency(td.getEfficiencyB());
+                    }
+                    if (length.compareTo(BigDecimal.ZERO) == 0) {
+                        continue;
+                    }
+                    calc.setLength(length);
+                    calc.setEmpTeam(d.getEmpTeam());
+                    calc.setEmpName(d.getEmpName());
+                    calc.setMick(mick);
+                    calc.setDensity(density);
+                    BigDecimal price = configMap.get(Tools.density(density));
+                    calc.setPrice(price);
+                    if (price != null) {
+                        BigDecimal total = length.multiply(price);
+                        calc.setTotalPrice(total);
+                    }
+                    calcList.add(calc);
+                }
+            }
+        }
+    }
+
+    private Long[] getDevices(String d) {
+        String[] temp = d.split(",");
+        Set<Long> set = new HashSet<>();
+        for (String s : temp) {
+            String[] ss = s.split("-");
+            if (ss.length > 1) {
+                Long st = Long.parseLong(ss[0]);
+                Long ed = Long.parseLong(ss[1]);
+                for (long i = st; i <= ed; i++) {
+                    set.add(i);
+                }
+            } else {
+                set.add(Long.parseLong(s));
+            }
+        }
+        Long[] devices = new Long[set.size()];
+        set.toArray(devices);
+        return devices;
+    }
+
+
+    /**
+     * 按日查询
+     *
+     * @param date 日期
+     * @return 结果
+     */
+    @Override
+    public List<TwinEmpCalc> selectTwinEmpCalcListByDate(Date date) {
+        TwinEmpCalc search = new TwinEmpCalc();
+        search.setEmpDate(date);
+        return selectTwinEmpCalcList(search);
+    }
+
+    /**
+     * 按月查询
+     *
+     * @param month 月份
+     * @return 结果
+     */
+    @Override
+    public List<TwinEmpCalc> selectTwinEmpCalcListByMonth(String month) {
+        return twinEmpCalcMapper.selectTwinEmpCalcListByMonth(month);
+    }
 }

+ 24 - 0
jjt-biz/src/main/java/com/jjt/emp/service/impl/TwinEmpServiceImpl.java

@@ -10,6 +10,7 @@ import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 import java.util.stream.Collectors;
 
@@ -131,4 +132,27 @@ public class TwinEmpServiceImpl implements ITwinEmpService {
             }
         }
     }
+
+    /**
+     * 按日期查询排班
+     *
+     * @param date 日期
+     * @return 排班结果
+     */
+    @Override
+    public TwinEmp selectTwinEmpByDate(Date date) {
+        TwinEmp twinEmp = new TwinEmp();
+        twinEmp.setEmpDate(date);
+        List<TwinEmp> list = selectTwinEmpList(twinEmp);
+        if (list.size() == 0) {
+            //如果未找到,则取最后一条记录
+            list = selectTwinEmpList(new TwinEmp());
+        }
+        Long empId = list.get(0).getEmpId();
+        twinEmp = selectTwinEmpByEmpId(empId);
+        twinEmp.setEmpId(null);
+        twinEmp.setEmpDate(date);
+        insertTwinEmp(twinEmp);
+        return twinEmp;
+    }
 }

+ 33 - 0
jjt-biz/src/main/java/com/jjt/task/EmpTask.java

@@ -0,0 +1,33 @@
+package com.jjt.task;
+
+import com.jjt.calc.service.ITwinCalcDayService;
+import com.jjt.calc.service.ITwinCalcHourService;
+import com.jjt.common.utils.DateUtils;
+import com.jjt.emp.service.ITwinEmpCalcService;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+import java.time.LocalDate;
+
+/**
+ * 员工绩效定时任务
+ *
+ * @author wukai
+ * @date 2025-1-17 23:27:26
+ */
+@Component("emp")
+public class EmpTask {
+    @Resource
+    private ITwinEmpCalcService empCalcService;
+
+
+    /**
+     * 绩效日报数据
+     */
+
+    public void day() {
+        LocalDate localDate = LocalDate.now().minusDays(1);
+        empCalcService.calc(DateUtils.toDate(localDate));
+    }
+
+}

+ 3 - 0
jjt-biz/src/main/resources/mapper/calc/TwinCalcHourSpecMapper.xml

@@ -35,6 +35,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="density != null "> and DENSITY = #{density}</if>
             <if test="price != null "> and PRICE = #{price}</if>
             <if test="remark != null  and remark != ''"> and REMARK = #{remark}</if>
+            <if test="params.sTime != null and params.eTime != null">
+                and DATEADD(hour, HOUR, DATA_DATE) between #{params.sTime} and #{params.eTime}
+            </if>
         </where>
     </select>
 

+ 63 - 37
jjt-biz/src/main/resources/mapper/emp/TwinEmpCalcMapper.xml

@@ -1,53 +1,66 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper
-PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.jjt.emp.mapper.TwinEmpCalcMapper">
-    
+
     <resultMap type="TwinEmpCalc" id="TwinEmpCalcResult">
-        <result property="calcId"    column="CALC_ID"    />
-        <result property="empName"    column="EMP_NAME"    />
-        <result property="empDate"    column="EMP_DATE"    />
-        <result property="empTeam"    column="EMP_TEAM"    />
-        <result property="deviceId"    column="DEVICE_ID"    />
-        <result property="efficiency"    column="EFFICIENCY"    />
-        <result property="spec"    column="SPEC"    />
-        <result property="mick"    column="MICK"    />
-        <result property="density"    column="DENSITY"    />
-        <result property="length"    column="LENGTH"    />
-        <result property="height"    column="HEIGHT"    />
-        <result property="price"    column="PRICE"    />
-        <result property="totalPrice"    column="TOTAL_PRICE"    />
+        <result property="calcId" column="CALC_ID"/>
+        <result property="empName" column="EMP_NAME"/>
+        <result property="empDate" column="EMP_DATE"/>
+        <result property="empTeam" column="EMP_TEAM"/>
+        <result property="deviceId" column="DEVICE_ID"/>
+        <result property="efficiency" column="EFFICIENCY"/>
+        <result property="spec" column="SPEC"/>
+        <result property="mick" column="MICK"/>
+        <result property="density" column="DENSITY"/>
+        <result property="length" column="LENGTH"/>
+        <result property="height" column="HEIGHT"/>
+        <result property="price" column="PRICE"/>
+        <result property="totalPrice" column="TOTAL_PRICE"/>
     </resultMap>
 
     <sql id="selectTwinEmpCalcVo">
-        select CALC_ID, EMP_NAME, EMP_DATE, EMP_TEAM, DEVICE_ID, EFFICIENCY, SPEC, MICK, DENSITY, LENGTH, HEIGHT, PRICE, TOTAL_PRICE from TWIN_EMP_CALC
+        select CALC_ID,
+               EMP_NAME,
+               EMP_DATE,
+               EMP_TEAM,
+               DEVICE_ID,
+               EFFICIENCY,
+               SPEC,
+               MICK,
+               DENSITY,
+               LENGTH,
+               HEIGHT,
+               PRICE,
+               TOTAL_PRICE
+        from TWIN_EMP_CALC
     </sql>
 
     <select id="selectTwinEmpCalcList" parameterType="TwinEmpCalc" resultMap="TwinEmpCalcResult">
         <include refid="selectTwinEmpCalcVo"/>
-        <where>  
-            <if test="empName != null  and empName != ''"> and EMP_NAME like concat('%', #{empName}, '%')</if>
-            <if test="empDate != null "> and EMP_DATE = #{empDate}</if>
-            <if test="empTeam != null  and empTeam != ''"> and EMP_TEAM = #{empTeam}</if>
-            <if test="deviceId != null "> and DEVICE_ID = #{deviceId}</if>
-            <if test="efficiency != null "> and EFFICIENCY = #{efficiency}</if>
-            <if test="spec != null  and spec != ''"> and SPEC = #{spec}</if>
-            <if test="mick != null "> and MICK = #{mick}</if>
-            <if test="density != null "> and DENSITY = #{density}</if>
-            <if test="length != null "> and LENGTH = #{length}</if>
-            <if test="height != null "> and HEIGHT = #{height}</if>
-            <if test="price != null "> and PRICE = #{price}</if>
-            <if test="totalPrice != null "> and TOTAL_PRICE = #{totalPrice}</if>
+        <where>
+            <if test="empName != null  and empName != ''">and EMP_NAME like concat('%', #{empName}, '%')</if>
+            <if test="empDate != null ">and EMP_DATE = #{empDate}</if>
+            <if test="empTeam != null  and empTeam != ''">and EMP_TEAM = #{empTeam}</if>
+            <if test="deviceId != null ">and DEVICE_ID = #{deviceId}</if>
+            <if test="efficiency != null ">and EFFICIENCY = #{efficiency}</if>
+            <if test="spec != null  and spec != ''">and SPEC = #{spec}</if>
+            <if test="mick != null ">and MICK = #{mick}</if>
+            <if test="density != null ">and DENSITY = #{density}</if>
+            <if test="length != null ">and LENGTH = #{length}</if>
+            <if test="height != null ">and HEIGHT = #{height}</if>
+            <if test="price != null ">and PRICE = #{price}</if>
+            <if test="totalPrice != null ">and TOTAL_PRICE = #{totalPrice}</if>
         </where>
     </select>
-    
+
     <select id="selectTwinEmpCalcByCalcId" parameterType="Long" resultMap="TwinEmpCalcResult">
         <include refid="selectTwinEmpCalcVo"/>
         where CALC_ID = #{calcId}
     </select>
 
-    <insert id="insertTwinEmpCalc" parameterType="TwinEmpCalc" useGeneratedKeys="true" keyProperty="calcId">
+    <insert id="insertTwinEmpCalc" parameterType="TwinEmpCalc">
         insert into TWIN_EMP_CALC
         <trim prefix="(" suffix=")" suffixOverrides=",">
             <if test="empName != null">EMP_NAME,</if>
@@ -62,7 +75,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="height != null">HEIGHT,</if>
             <if test="price != null">PRICE,</if>
             <if test="totalPrice != null">TOTAL_PRICE,</if>
-         </trim>
+        </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="empName != null">#{empName},</if>
             <if test="empDate != null">#{empDate},</if>
@@ -76,7 +89,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="height != null">#{height},</if>
             <if test="price != null">#{price},</if>
             <if test="totalPrice != null">#{totalPrice},</if>
-         </trim>
+        </trim>
     </insert>
 
     <update id="updateTwinEmpCalc" parameterType="TwinEmpCalc">
@@ -99,13 +112,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </update>
 
     <delete id="deleteTwinEmpCalcByCalcId" parameterType="Long">
-        delete from TWIN_EMP_CALC where CALC_ID = #{calcId}
+        delete
+        from TWIN_EMP_CALC
+        where CALC_ID = #{calcId}
     </delete>
 
     <delete id="deleteTwinEmpCalcByCalcIds" parameterType="String">
-        delete from TWIN_EMP_CALC where CALC_ID in 
+        delete from TWIN_EMP_CALC where CALC_ID in
         <foreach item="calcId" collection="array" open="(" separator="," close=")">
             #{calcId}
         </foreach>
     </delete>
-</mapper>
+    <delete id="deleteTwinEmpCalcByDate">
+        delete
+        from twin_emp_calc
+        where emp_Date = #{date}
+    </delete>
+
+    <select id="selectTwinEmpCalcListByMonth" resultMap="TwinEmpCalcResult">
+        <include refid="selectTwinEmpCalcVo"/>
+        where FORMAT(EMP_DATE, 'yyyy-MM') = #{month}
+        order by DENSITY,EMP_DATE
+    </select>
+</mapper>

+ 1 - 0
jjt-biz/src/main/resources/mapper/emp/TwinEmpMapper.xml

@@ -31,6 +31,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <where>
             <if test="empDate != null "> and EMP_DATE = #{empDate}</if>
         </where>
+        order by emp_date desc
     </select>
 
     <select id="selectTwinEmpByEmpId" parameterType="Long" resultMap="TwinEmpTwinEmpDetailResult">