lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcEquipmentPunchController.java
@@ -16,55 +16,56 @@ /** * @Description: mdc_equipment_punch * @Author: jeecg-boot * @Date: 2025-06-09 * @Date: 2025-06-09 * @Version: V1.0 */ @Api(tags="ä¸ä¸çæå¡è®°å½è¡¨") @Api(tags = "ä¸ä¸çæå¡è®°å½è¡¨") @RestController @RequestMapping("/mdcEquipmentPunch") @Slf4j public class MdcEquipmentPunchController extends JeecgController<MdcEquipmentPunch, IMdcEquipmentPunchService> { @Autowired private IMdcEquipmentPunchService mdcEquipmentPunchService; @Autowired private IMdcEquipmentPunchService mdcEquipmentPunchService; private static final String msg = "æå¡æåï¼"; /** * æ¥è¯¢å½åç»å½äººæè´è´£è®¾å¤æå¡æ åµ * * @return */ @ApiOperation(value="æ¥è¯¢å½åç»å½äººæè´è´£è®¾å¤æå¡æ åµ", notes="æ¥è¯¢å½åç»å½äººæè´è´£è®¾å¤æå¡æ åµ") @GetMapping(value = "/list") public Result<List<MdcEquipmentPunch>> queryList() { return Result.OK(mdcEquipmentPunchService.queryList()); } private static final String msg = "æå¡æåï¼"; /** * ä¸çæå¡ * * @param mdcEquipmentPunch * @return */ @AutoLog(value = "ä¸çæå¡") @ApiOperation(value="ä¸çæå¡", notes="ä¸çæå¡") @PostMapping(value = "/workUp") public Result<String> workUp(@RequestBody MdcEquipmentPunch mdcEquipmentPunch) { mdcEquipmentPunchService.workUp(mdcEquipmentPunch); return Result.OK(msg); } /** * æ¥è¯¢å½åç»å½äººæè´è´£è®¾å¤æå¡æ åµ * * @return */ @ApiOperation(value = "æ¥è¯¢å½åç»å½äººæè´è´£è®¾å¤æå¡æ åµ", notes = "æ¥è¯¢å½åç»å½äººæè´è´£è®¾å¤æå¡æ åµ") @GetMapping(value = "/list") public Result<List<MdcEquipmentPunch>> queryList() { return Result.OK(mdcEquipmentPunchService.queryList()); } /** * ä¸çæå¡ * * @param mdcEquipmentPunch * @return */ @AutoLog(value = "ä¸çæå¡") @ApiOperation(value="ä¸çæå¡", notes="ä¸çæå¡") @PostMapping(value = "/workDown") public Result<String> workDown(@RequestBody MdcEquipmentPunch mdcEquipmentPunch) { mdcEquipmentPunchService.workDown(mdcEquipmentPunch); return Result.OK(msg); } /** * ä¸çæå¡ * * @param mdcEquipmentPunch * @return */ @AutoLog(value = "ä¸çæå¡") @ApiOperation(value = "ä¸çæå¡", notes = "ä¸çæå¡") @PostMapping(value = "/workUp") public Result<String> workUp(@RequestBody MdcEquipmentPunch mdcEquipmentPunch) { mdcEquipmentPunchService.workUp(mdcEquipmentPunch); return Result.OK(msg); } /** * ä¸çæå¡ * * @param mdcEquipmentPunch * @return */ @AutoLog(value = "ä¸çæå¡") @ApiOperation(value = "ä¸çæå¡", notes = "ä¸çæå¡") @PostMapping(value = "/workDown") public Result<String> workDown(@RequestBody MdcEquipmentPunch mdcEquipmentPunch) { mdcEquipmentPunchService.workDown(mdcEquipmentPunch); return Result.OK(msg); } } lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcEquipmentPunchRateController.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,81 @@ package org.jeecg.modules.mdc.controller; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.jeecg.common.api.vo.Result; import org.jeecg.common.aspect.annotation.AutoLog; import org.jeecg.common.system.base.controller.JeecgController; import org.jeecg.common.system.query.QueryGenerator; import org.jeecg.modules.mdc.entity.MdcEquipmentPunchRate; import org.jeecg.modules.mdc.service.IMdcEquipmentPunchRateService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.servlet.ModelAndView; import javax.servlet.http.HttpServletRequest; /** * @Description: mdc_equipment_punch_rate * @Author: jeecg-boot * @Date: 2025-06-09 * @Version: V1.0 */ @Api(tags = "è®¾å¤æå¡çæ¥è¡¨") @RestController @RequestMapping("/mdcEquipmentPunchRate") @Slf4j public class MdcEquipmentPunchRateController extends JeecgController<MdcEquipmentPunchRate, IMdcEquipmentPunchRateService> { @Autowired private IMdcEquipmentPunchRateService mdcEquipmentPunchService; /** * å页å表æ¥è¯¢ * * @param mdEquipmentPunch æ¥è¯¢åæ° * @param pageNo å½å页ç * @param pageSize æ¯é¡µæ¡æ° * @param req 请æ±å¯¹è±¡ * @return */ @ApiOperation(value = "è®¾å¤æå¡ç-å页å表æ¥è¯¢", notes = "è®¾å¤æå¡ç-å页å表æ¥è¯¢") @AutoLog(value = "è®¾å¤æå¡ç-å页å表æ¥è¯¢") @GetMapping(value = "/queryPageList") public Result<IPage<MdcEquipmentPunchRate>> queryPageList(MdcEquipmentPunchRate mdEquipmentPunch, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) { QueryWrapper<MdcEquipmentPunchRate> queryWrapper = QueryGenerator.initQueryWrapper(mdEquipmentPunch, req.getParameterMap()); Page<MdcEquipmentPunchRate> page = new Page<MdcEquipmentPunchRate>(pageNo, pageSize); IPage<MdcEquipmentPunchRate> pageList = mdcEquipmentPunchService.page(page, queryWrapper); return Result.OK(pageList); } /** * 导åºexcel * * @param request * @param mdcEquipmentPunchRate */ @RequestMapping(value = "/exportXls") public ModelAndView exportXls(HttpServletRequest request, MdcEquipmentPunchRate mdcEquipmentPunchRate) { return super.exportXls(request, mdcEquipmentPunchRate, MdcEquipmentPunchRate.class, "è®¾å¤æå¡çæ¥è¡¨"); } } lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/dto/MdcEquipmentPunchExportDTO.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,98 @@ package org.jeecg.modules.mdc.dto; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import org.jeecg.common.aspect.annotation.Dict; import java.math.BigDecimal; import java.util.Date; @Data public class MdcEquipmentPunchExportDTO { @ApiModelProperty(value = "设å¤ç¼å·") private String equipmentId; @ApiModelProperty(value = "æå¡ç¨æ·") @Dict(dicCode = "id", dictTable = "sys_user", dicText = "realname") private String punchUser; @ApiModelProperty(value = "ä¸çæ¶é´") private Date checkInTime; /** * ä¸çæ¶é´ */ @ApiModelProperty(value = "ä¸çæ¶é´") private Date checkOutTime; /** * è®°å½æ¥æ */ @ApiModelProperty(value = "è®°å½æ¥æ") private String recordDate; @ApiModelProperty(value = "çæ¬¡") @Dict(dicCode = "shift_schedule") private Integer shiftSchedule; @ApiModelProperty(value = "æ¯å¦ç¼ºå¡") private Integer isAbsent; @ApiModelProperty(value = "æ¯å¦è¿å°") private Integer isLate; @ApiModelProperty(value = "æ¯å¦æ©é") private Integer isEarly; /** * æ©çä¸çæå¡ç */ @ApiModelProperty(value = "æ©çä¸çæå¡ç") private BigDecimal morningShiftInRate; /** * æçä¸çæå¡ç */ @ApiModelProperty(value = "æçä¸çæå¡ç") private BigDecimal eveningShiftInRate; @ApiModelProperty(value = "æ©çä¸çæå¡ç") private BigDecimal morningShiftOutRate; @ApiModelProperty(value = "æçä¸çæå¡ç") private BigDecimal eveningShiftOutRate; @ApiModelProperty(value = "ç½çä¸çæå¡è®¾å¤æ°é") private Integer morningShiftInDeviceNum; @ApiModelProperty(value = "ç½çä¸çæå¡è®¾å¤æ°é") private Integer morningShiftOutDeviceNum; @ApiModelProperty(value = "å¤çä¸çæå¡è®¾å¤æ°é") private Integer eveningShiftInDeviceNum; @ApiModelProperty(value = "å¤çä¸çæå¡è®¾å¤æ°é") private Integer eveningShiftOutDeviceNum; @ApiModelProperty(value = "è®¾å¤æ»æ°") private Integer deviceCountNum; private String punchUserRealName; } lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcEquipmentPunch.java
@@ -1,22 +1,24 @@ package org.jeecg.modules.mdc.entity; import java.io.Serializable; import java.util.Date; import cn.hutool.core.date.DatePattern; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; import com.fasterxml.jackson.annotation.JsonFormat; import org.jeecg.common.aspect.annotation.Dict; import org.springframework.format.annotation.DateTimeFormat; import org.jeecgframework.poi.excel.annotation.Excel; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; import org.jeecg.common.aspect.annotation.Dict; import org.jeecg.common.system.base.entity.JeecgEntity; import org.jeecgframework.poi.excel.annotation.Excel; import org.springframework.format.annotation.DateTimeFormat; import java.io.Serializable; import java.math.BigDecimal; import java.util.Date; /** * @Description: mdc_equipment_punch @@ -29,7 +31,7 @@ @Accessors(chain = true) @EqualsAndHashCode(callSuper = false) @ApiModel(value = "mdc_equipment_punch对象", description = "mdc_equipment_punch") public class MdcEquipmentPunch implements Serializable { public class MdcEquipmentPunch extends JeecgEntity implements Serializable { private static final long serialVersionUID = 1L; /** @@ -49,18 +51,18 @@ */ @Excel(name = "æå¡ç¨æ·", width = 15) @ApiModelProperty(value = "æå¡ç¨æ·") @Dict(dicCode = "id", dictTable = "sys_user", dicText = "realname") private String punchUser; /** * æå¡ç¨æ·è´¦å· */ @Excel(name = "æå¡ç¨æ·è´¦å·", width = 15) @ApiModelProperty(value = "æå¡ç¨æ·è´¦å·") @TableField(exist = false) private String punchUserRealName; /** * æå¡ç¨æ·åç§° */ @Excel(name = "æå¡ç¨æ·åç§°", width = 15) @ApiModelProperty(value = "æå¡ç¨æ·åç§°") @TableField(exist = false) private String punchUserUserName; @@ -87,7 +89,7 @@ @ApiModelProperty(value = "è®°å½æ¥æ") private String recordDate; /** * çæ¬¡ * çæ¬¡ */ @Excel(name = "çæ¬¡", width = 15) @ApiModelProperty(value = "çæ¬¡") @@ -107,7 +109,7 @@ @ApiModelProperty(value = "æ¯å¦ç¼ºå¡") private Integer isAbsent; /** * æ¯å¦è¿å° * æ¯å¦è¿å°ï¼0æªæ©éï¼1æ©éï¼ */ @Excel(name = "æ¯å¦è¿å°", width = 15) @ApiModelProperty(value = "æ¯å¦è¿å°") @@ -118,28 +120,74 @@ @Excel(name = "æ¯å¦æ©é", width = 15) @ApiModelProperty(value = "æ¯å¦æ©é") private Integer isEarly; /** * å建人 * æ©çä¸çæå¡ç */ @ApiModelProperty(value = "å建人") private String createBy; @TableField(exist = false) @Excel(name = "æ©çä¸çæå¡ç", width = 15) @ApiModelProperty(value = "æ©çä¸çæå¡ç") private BigDecimal morningShiftInRate; /** * å建æ¶é´ * æçä¸çæå¡ç */ @JsonFormat(timezone = "GMT+8", pattern = DatePattern.NORM_DATETIME_PATTERN) @DateTimeFormat(pattern = DatePattern.NORM_DATETIME_PATTERN) @ApiModelProperty(value = "å建æ¶é´") private Date createTime; @TableField(exist = false) @Excel(name = "æçä¸çæå¡ç", width = 15) @ApiModelProperty(value = "æçä¸çæå¡ç") private BigDecimal eveningShiftInRate; /** * æ´æ°äºº * æ©çä¸çæå¡ç */ @ApiModelProperty(value = "æ´æ°äºº") private String updateBy; @TableField(exist = false) @Excel(name = "æ©çä¸çæå¡ç", width = 15) @ApiModelProperty(value = "æ©çä¸çæå¡ç") private BigDecimal morningShiftOutRate; /** * æ´æ°æ¶é´ * æçä¸çæå¡ç */ @JsonFormat(timezone = "GMT+8", pattern = DatePattern.NORM_DATETIME_PATTERN) @DateTimeFormat(pattern = DatePattern.NORM_DATETIME_PATTERN) @ApiModelProperty(value = "æ´æ°æ¶é´") private Date updateTime; @TableField(exist = false) @Excel(name = "æçä¸çæå¡ç", width = 15) @ApiModelProperty(value = "æçä¸çæå¡ç") private BigDecimal eveningShiftOutRate; /** * ç½çä¸çæå¡è®¾å¤æ°é */ @TableField(exist = false) @Excel(name = "ç½çä¸çæå¡è®¾å¤æ°é", width = 15) @ApiModelProperty(value = "ç½çä¸çæå¡è®¾å¤æ°é") private Integer morningShiftInDeviceNum; /** * ç½çä¸çæå¡è®¾å¤æ°é */ @TableField(exist = false) @Excel(name = "ç½çä¸çæå¡è®¾å¤æ°é", width = 15) @ApiModelProperty(value = "ç½çä¸çæå¡è®¾å¤æ°é") private Integer morningShiftOutDeviceNum; /** * å¤çä¸çæå¡è®¾å¤æ°é */ @TableField(exist = false) @Excel(name = "å¤çä¸çæå¡è®¾å¤æ°é", width = 15) @ApiModelProperty(value = "å¤çä¸çæå¡è®¾å¤æ°é") private Integer eveningShiftInDeviceNum; /** * å¤çä¸çæå¡è®¾å¤æ°é */ @TableField(exist = false) @Excel(name = "å¤çä¸çæå¡è®¾å¤æ°é", width = 15) @ApiModelProperty(value = "å¤çä¸çæå¡è®¾å¤æ°é") private Integer eveningShiftOutDeviceNum; /** * è®¾å¤æ»æ° */ @TableField(exist = false) @Excel(name = "è®¾å¤æ»æ°", width = 15) @ApiModelProperty(value = "è®¾å¤æ»æ°") private Integer deviceCountNum; } lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcEquipmentPunchRate.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,129 @@ package org.jeecg.modules.mdc.entity; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; import org.jeecg.common.aspect.annotation.Dict; import org.jeecg.common.system.base.entity.JeecgEntity; import org.jeecgframework.poi.excel.annotation.Excel; import java.io.Serializable; import java.math.BigDecimal; /** * @Description: mdc_equipment_punch_rate * @Author: jeecg-boot * @Date: 2025-06-09 * @Version: V1.0 */ @Data @TableName("mdc_equipment_punch_rate") @Accessors(chain = true) @EqualsAndHashCode(callSuper = false) @ApiModel(value = "mdc_equipment_punch_rate对象", description = "mdc_equipment_punch_rate") public class MdcEquipmentPunchRate extends JeecgEntity implements Serializable { private static final long serialVersionUID = 1L; /** * id */ @TableId(type = IdType.ASSIGN_ID) @ApiModelProperty(value = "id") private String id; /** * 设å¤ç¼å· */ @Excel(name = "设å¤ç¼å·", width = 15) @ApiModelProperty(value = "设å¤ç¼å·") private String equipmentId; /** * è®°å½æ¥æ */ @Excel(name = "è®°å½æ¥æ", width = 15) @ApiModelProperty(value = "è®°å½æ¥æ") private String theDate; /** * çæ¬¡ */ @Excel(name = "çæ¬¡", width = 15) @ApiModelProperty(value = "çæ¬¡") @Dict(dicCode = "shift_schedule") private Integer shiftSchedule; /** * æ©çä¸çæå¡ç */ @Excel(name = "æ©çä¸çæå¡ç(%)", width = 15) @ApiModelProperty(value = "æ©çä¸çæå¡ç") private BigDecimal mornShiftInRate; /** * æçä¸çæå¡ç */ @Excel(name = "æçä¸çæå¡ç(%)", width = 15) @ApiModelProperty(value = "æçä¸çæå¡ç") private BigDecimal evenShiftInRate; /** * æ©çä¸çæå¡ç */ @Excel(name = "æ©çä¸çæå¡ç(%)", width = 15) @ApiModelProperty(value = "æ©çä¸çæå¡ç") private BigDecimal mornShiftOutRate; /** * æçä¸çæå¡ç */ @Excel(name = "æçä¸çæå¡ç(%)", width = 15) @ApiModelProperty(value = "æçä¸çæå¡ç") private BigDecimal evenShiftOutRate; /** * ç½çä¸çæå¡è®¾å¤æ°é */ @Excel(name = "ç½çä¸çæå¡è®¾å¤æ°é", width = 15) @ApiModelProperty(value = "ç½çä¸çæå¡è®¾å¤æ°é") private Integer mornShiftInNum; /** * ç½çä¸çæå¡è®¾å¤æ°é */ @Excel(name = "ç½çä¸çæå¡è®¾å¤æ°é", width = 15) @ApiModelProperty(value = "ç½çä¸çæå¡è®¾å¤æ°é") private Integer mornShiftOutNum; /** * å¤çä¸çæå¡è®¾å¤æ°é */ @Excel(name = "å¤çä¸çæå¡è®¾å¤æ°é", width = 15) @ApiModelProperty(value = "å¤çä¸çæå¡è®¾å¤æ°é") private Integer evenShiftInNum; /** * å¤çä¸çæå¡è®¾å¤æ°é */ @Excel(name = "å¤çä¸çæå¡è®¾å¤æ°é", width = 15) @ApiModelProperty(value = "å¤çä¸çæå¡è®¾å¤æ°é") private Integer evenShiftOutNum; /** * è®¾å¤æ»æ° */ @Excel(name = "è®¾å¤æ»æ°", width = 15) @ApiModelProperty(value = "è®¾å¤æ»æ°") private Integer deviceCountNum; } lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/DailyPunchRateJob.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,108 @@ package org.jeecg.modules.mdc.job; import cn.hutool.core.date.DatePattern; import lombok.extern.slf4j.Slf4j; import org.jeecg.modules.mdc.entity.MdcEquipmentPunch; import org.jeecg.modules.mdc.service.IMdcEquipmentPunchRateService; import org.jeecg.modules.mdc.service.IMdcEquipmentPunchService; import org.jeecg.modules.quartz.entity.QuartzJob; import org.jeecg.modules.quartz.entity.SysQuartzLog; import org.jeecg.modules.quartz.service.IQuartzJobService; import org.jeecg.modules.quartz.service.ISysQuartzLogService; import org.jeecg.modules.system.service.ISysAnnouncementService; import org.quartz.Job; import org.quartz.JobExecutionContext; import org.quartz.JobExecutionException; import javax.annotation.Resource; import java.time.LocalDate; import java.time.format.DateTimeFormatter; import java.util.Date; import java.util.List; /** * @Description: æ¯æ¥åæ¨å®æ¶è®¡ç®åä¸å¤©çè®¾å¤æå¡çï¼å¹¶å ¥åº * @Author: Lius * @CreateTime: 2025-06-12 */ @Slf4j public class DailyPunchRateJob implements Job { private String parameter; // å¯éåæ°ï¼æå®æ¥æï¼å¦ "2025-06-11"ï¼ public void setParameter(String parameter) { this.parameter = parameter; } @Resource private IQuartzJobService quartzJobService; @Resource private ISysQuartzLogService sysQuartzLogService; @Resource private ISysAnnouncementService sysAnnouncementService; @Resource private IMdcEquipmentPunchService mdcEquipmentPunchService; @Resource private IMdcEquipmentPunchRateService mdcEquipmentPunchRateService; @Override public void execute(JobExecutionContext context) throws JobExecutionException { SysQuartzLog quartzLog = new SysQuartzLog(); quartzLog.setCreateTime(new Date()); List<QuartzJob> jobList = this.quartzJobService.findByJobClassName(this.getClass().getName()); if (jobList != null && !jobList.isEmpty()) { quartzLog.setJobId(jobList.get(0).getId()); } log.info("ãå¼å§æ§è¡æ¯æ¥è®¾å¤æå¡çç»è®¡ä»»å¡ã"); long startTime = System.currentTimeMillis(); try { String yesterdayStr; if (parameter != null && !parameter.isEmpty()) { yesterdayStr = parameter; // æ¯ææå¨ä¼ å } else { LocalDate yesterday = LocalDate.now().minusDays(1); yesterdayStr = yesterday.format(DateTimeFormatter.ofPattern(DatePattern.PURE_DATE_PATTERN)); // æ ¼å¼å为 "yyyy-MM-dd" } log.info("â æåå®ææ¯æ¥è®¾å¤æå¡çç»è®¡æ°æ®", yesterdayStr); // Step 1ï¼è·åæ¨æ¥æå¡æ°æ® List<MdcEquipmentPunch> punchRecords = mdcEquipmentPunchService.getYesterdayRecords(yesterdayStr); log.info("â æåå®ææ¯æ¥è®¾å¤æå¡çç»è®¡æ°æ®", punchRecords); if (punchRecords == null || punchRecords.isEmpty()) { log.warn("â ï¸ æ²¡ææ¾å°æ¨æ¥è®¾å¤æå¡æ°æ®"); quartzLog.setIsSuccess(0); return; } // Step 2ï¼ä¿åå°æå¡ç表 mdcEquipmentPunchRateService.savePunchRates(yesterdayStr, punchRecords); quartzLog.setIsSuccess(0); log.info("â æåå®ææ¯æ¥è®¾å¤æå¡çç»è®¡ï¼å ±å¤ç {} æ¡è®°å½ï¼æ¥æï¼{}", punchRecords.size(), yesterdayStr); } catch (Exception e) { quartzLog.setIsSuccess(-1); quartzLog.setExceptionDetail(e.getMessage()); log.error("â è®¾å¤æå¡çç»è®¡ä»»å¡æ§è¡å¤±è´¥", e); sysAnnouncementService.jobSendMessage("è®¾å¤æå¡çç»è®¡ä»»å¡", e.getMessage()); } // è®°å½æ§è¡æ¶é´ long endTime = System.currentTimeMillis(); quartzLog.setExecutionTime((int)(endTime - startTime)); sysQuartzLogService.save(quartzLog); } } lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentPunchMapper.java
@@ -15,4 +15,22 @@ public interface MdcEquipmentPunchMapper extends BaseMapper<MdcEquipmentPunch> { List<MdcEquipmentPunch> list(@Param("equipmentIds") List<String> equipmentIds, @Param("date") String date); // æ¥è¯¢æ©çä¸çæå¡è®¾å¤æ° int countMorningShiftIn(@Param("date") String date); // æ¥è¯¢æçä¸çæå¡è®¾å¤æ° int countEveningShiftIn(@Param("date") String date); // æ¥è¯¢æ©çä¸çæå¡è®¾å¤æ° int countMorningShiftOut(@Param("date") String date); // æ¥è¯¢æçä¸çæå¡è®¾å¤æ° int countEveningShiftOut(@Param("date") String date); /** * è·åææè®¾å¤æ° */ int getTotalDeviceCount(); } lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentPunchRateMapper.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,14 @@ package org.jeecg.modules.mdc.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.jeecg.modules.mdc.entity.MdcEquipmentPunchRate; /** * @Description: mdc_equipment_punch_rate * @Author: jeecg-boot * @Date: 2025-06-09 * @Version: V1.0 */ public interface MdcEquipmentPunchRateMapper extends BaseMapper<MdcEquipmentPunchRate> { } lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentPunchMapper.xml
@@ -4,31 +4,31 @@ <select id="list" resultType="org.jeecg.modules.mdc.entity.MdcEquipmentPunch"> SELECT p.id, p.equipment_id, p.punch_user, p.check_in_time, p.check_out_time, p.record_date, p.is_absent, p.is_late, p.is_early, p.create_by, p.create_time, p.update_by, p.update_time, p.shift_schedule, u.realname punchUserRealName, u.username punchUserUserName, d1.item_text shiftScheduleName p.id, p.equipment_id, p.punch_user, p.check_in_time, p.check_out_time, p.record_date, p.is_absent, p.is_late, p.is_early, p.create_by, p.create_time, p.update_by, p.update_time, p.shift_schedule, u.realname punchUserRealName, u.username punchUserUserName, d1.item_text shiftScheduleName FROM mdc_equipment_punch p INNER JOIN sys_user u ON u.id = p.punch_user INNER JOIN (SELECT i1.item_text, i1.item_value FROM sys_dict_item i1 LEFT JOIN sys_dict i2 ON i2.id = i1.dict_id WHERE i2.dict_code = 'shift_schedule') d1 ON d1.item_value = CAST (p.shift_schedule AS nvarchar) mdc_equipment_punch p INNER JOIN sys_user u ON u.id = p.punch_user INNER JOIN (SELECT i1.item_text, i1.item_value FROM sys_dict_item i1 LEFT JOIN sys_dict i2 ON i2.id = i1.dict_id WHERE i2.dict_code = 'shift_schedule') d1 ON d1.item_value = CAST (p.shift_schedule AS nvarchar) where 1=1 AND p.equipment_id IN <foreach collection="equipmentIds" item="equipmentId" open="(" close=")" separator=","> @@ -39,4 +39,47 @@ </if> order by p.equipment_id desc, p.shift_schedule asc </select> <!--æ¥è¯¢ææè®¾å¤æ°é--> <select id="getTotalDeviceCount" resultType="int"> SELECT COUNT(*) FROM mdc_equipment </select> <!-- æ©ç ä¸çæå¡ --> <select id="countMorningShiftIn" resultType="int"> SELECT COUNT(DISTINCT equipment_id) FROM mdc_equipment_punch WHERE record_date = #{date, jdbcType=VARCHAR} AND shift_schedule = '1' AND check_in_time IS NOT NULL </select> <!-- æç ä¸çæå¡ --> <select id="countEveningShiftIn" resultType="int"> SELECT COUNT(DISTINCT equipment_id) FROM mdc_equipment_punch WHERE record_date = #{date, jdbcType=VARCHAR} AND shift_schedule = '2' AND check_in_time IS NOT NULL </select> <!-- æ©ç ä¸çæå¡ --> <select id="countMorningShiftOut" resultType="int"> SELECT COUNT(DISTINCT equipment_id) FROM mdc_equipment_punch WHERE record_date = #{date, jdbcType=VARCHAR} AND shift_schedule = '1' AND check_out_time IS NOT NULL </select> <!-- æç ä¸çæå¡ --> <select id="countEveningShiftOut" resultType="int"> SELECT COUNT(DISTINCT equipment_id) FROM mdc_equipment_punch WHERE record_date = #{date, jdbcType=VARCHAR} AND shift_schedule = '2' AND check_out_time IS NOT NULL </select> </mapper> lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentPunchRateMapper.xml
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,6 @@ <?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"> <mapper namespace="org.jeecg.modules.mdc.mapper.MdcEquipmentPunchRateMapper"> </mapper> lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentPunchRateService.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,19 @@ package org.jeecg.modules.mdc.service; import com.baomidou.mybatisplus.extension.service.IService; import org.jeecg.modules.mdc.entity.MdcEquipmentPunch; import org.jeecg.modules.mdc.entity.MdcEquipmentPunchRate; import java.util.List; /** * @Description: mdc_equipment_punch * @Author: jeecg-boot * @Date: 2025-06-09 * @Version: V1.0 */ public interface IMdcEquipmentPunchRateService extends IService<MdcEquipmentPunchRate> { void savePunchRates(String targetDate, List<MdcEquipmentPunch> punchRecords); } lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentPunchService.java
@@ -18,4 +18,10 @@ void workUp(MdcEquipmentPunch mdcEquipmentPunch); void workDown(MdcEquipmentPunch mdcEquipmentPunch); void fillPunchRates(List<MdcEquipmentPunch> punchList); /** * æ¥è¯¢æå®æ¥æçè®¾å¤æå¡æ°æ®ï¼éå¸¸æ¯æ¨å¤©ï¼ */ List<MdcEquipmentPunch> getYesterdayRecords(String targetDate); } lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentPunchRateServiceImpl.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,81 @@ package org.jeecg.modules.mdc.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.jeecg.modules.mdc.entity.MdcEquipmentPunch; import org.jeecg.modules.mdc.entity.MdcEquipmentPunchRate; import org.jeecg.modules.mdc.mapper.MdcEquipmentPunchMapper; import org.jeecg.modules.mdc.mapper.MdcEquipmentPunchRateMapper; import org.jeecg.modules.mdc.service.IMdcEquipmentPunchRateService; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.math.BigDecimal; import java.math.RoundingMode; import java.util.List; import java.util.UUID; /** * @Description: mdc_equipment_punch * @Author: jeecg-boot * @Date: 2025-06-09 * @Version: V1.0 */ @Service public class MdcEquipmentPunchRateServiceImpl extends ServiceImpl<MdcEquipmentPunchRateMapper, MdcEquipmentPunchRate> implements IMdcEquipmentPunchRateService { @Resource private MdcEquipmentPunchRateMapper mdcEquipmentPunchRateMapper; @Resource private MdcEquipmentPunchMapper mdcEquipmentPunchMapper; @Override public void savePunchRates(String targetDate, List<MdcEquipmentPunch> punchRecords) { int morningIn = mdcEquipmentPunchMapper.countMorningShiftIn(targetDate); int eveningIn = mdcEquipmentPunchMapper.countEveningShiftIn(targetDate); int morningOut = mdcEquipmentPunchMapper.countMorningShiftOut(targetDate); int eveningOut = mdcEquipmentPunchMapper.countEveningShiftOut(targetDate); for (MdcEquipmentPunch punch : punchRecords) { MdcEquipmentPunchRate rate = new MdcEquipmentPunchRate(); rate.setId(UUID.randomUUID().toString()); // çæå¯ä¸ID rate.setEquipmentId(punch.getEquipmentId()); rate.setTheDate(targetDate); rate.setShiftSchedule(punch.getShiftSchedule()); // è®¾ç½®è®¾å¤æ°é rate.setMornShiftInNum(morningIn); rate.setMornShiftOutNum(eveningIn); rate.setEvenShiftInNum(morningOut); rate.setEvenShiftOutNum(eveningOut); // è·åæ»è®¾å¤æ° int totalDevices = mdcEquipmentPunchMapper.getTotalDeviceCount(); if (totalDevices == 0) return; rate.setDeviceCountNum(totalDevices); // è®¡ç®æå¡çï¼ä¿ç两ä½å°æ°ï¼ rate.setMornShiftInRate(calculateRate(morningIn, totalDevices)); rate.setMornShiftOutRate(calculateRate(eveningIn, totalDevices)); rate.setEvenShiftInRate(calculateRate(morningOut, totalDevices)); rate.setEvenShiftOutRate(calculateRate(eveningOut, totalDevices)); this.save(rate); } } private BigDecimal calculateRate(int actual, int total) { if (total == 0) return BigDecimal.ZERO; return new BigDecimal(actual) .divide(new BigDecimal(total), 4, RoundingMode.DOWN) .multiply(BigDecimal.valueOf(100)) .setScale(2, RoundingMode.DOWN); // ä¿ç两ä½å°æ°ï¼ä¸è¿è¡åèäºå ¥ } } lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentPunchServiceImpl.java
@@ -3,6 +3,7 @@ import cn.hutool.core.date.DatePattern; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.StringPool; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @@ -19,6 +20,10 @@ import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.math.BigDecimal; import java.math.RoundingMode; import java.time.LocalDate; import java.time.format.DateTimeFormatter; import java.util.*; import java.util.stream.Collectors; @@ -30,7 +35,8 @@ */ @Service public class MdcEquipmentPunchServiceImpl extends ServiceImpl<MdcEquipmentPunchMapper, MdcEquipmentPunch> implements IMdcEquipmentPunchService { @Resource private MdcEquipmentPunchMapper mdcEquipmentPunchMapper; @Resource private IMdcEquipmentService mdcEquipmentService; @@ -235,4 +241,59 @@ this.saveOrUpdateBatch(list); } @Override public void fillPunchRates(List<MdcEquipmentPunch> punchList) { // è·åæ¨å¤©æ¥æ LocalDate yesterday = LocalDate.now().minusDays(1); String yesterdayStr = yesterday.format(DateTimeFormatter.ofPattern(DatePattern.PURE_DATE_PATTERN)); // æ ¼å¼å为 "yyyy-MM-dd" // è·åæ»è®¾å¤æ° int totalDevices = mdcEquipmentPunchMapper.getTotalDeviceCount(); if (totalDevices == 0) return; // ç»è®¡åç±»åæå¡äººæ° int morningIn = mdcEquipmentPunchMapper.countMorningShiftIn(yesterdayStr); int eveningIn = mdcEquipmentPunchMapper.countEveningShiftIn(yesterdayStr); int morningOut = mdcEquipmentPunchMapper.countMorningShiftOut(yesterdayStr); int eveningOut = mdcEquipmentPunchMapper.countEveningShiftOut(yesterdayStr); // 设置æå¡çå°æ¯ä¸ª DTO for (MdcEquipmentPunch dto : punchList) { dto.setMorningShiftInRate(calculateRate(morningIn, totalDevices)); dto.setEveningShiftInRate(calculateRate(eveningIn, totalDevices)); dto.setMorningShiftOutRate(calculateRate(morningOut, totalDevices)); dto.setEveningShiftOutRate(calculateRate(eveningOut, totalDevices)); // 设置æå¡è®¾å¤æ°éåæ®µ dto.setMorningShiftInDeviceNum(morningIn); dto.setMorningShiftOutDeviceNum(morningOut); dto.setEveningShiftInDeviceNum(eveningIn); dto.setEveningShiftOutDeviceNum(eveningOut); dto.setDeviceCountNum(totalDevices); } } // 计ç®ç¾åæ¯å¹¶ä¿ç两ä½å°æ° private BigDecimal calculateRate(int actual, int total) { if (total == 0) return BigDecimal.ZERO; return new BigDecimal(actual) .divide(new BigDecimal(total), 4, RoundingMode.HALF_UP) .multiply(BigDecimal.valueOf(100)) .setScale(2, RoundingMode.HALF_UP); // ä¿ç两ä½å°æ° } @Override public List<MdcEquipmentPunch> getYesterdayRecords(String targetDate) { // æé æ¥è¯¢æ¡ä»¶ï¼record_date = targetDate.toString() QueryWrapper<MdcEquipmentPunch> queryWrapper = new QueryWrapper<>(); queryWrapper.eq("record_date", targetDate); // æ§è¡æ¥è¯¢å¹¶è¿åç»æ return baseMapper.selectList(queryWrapper); } }