Commit 8cd90575a8d0bdd872d301a683e8bbda56f26813

Authored by liujun001
1 parent fdb152ac

优化签到和日志

Showing 27 changed files with 925 additions and 178 deletions
Bsth-admin/src/main/java/com/ruoyi/domain/DriverScheduling.java
1 1 package com.ruoyi.domain;
2 2  
3 3 import com.alibaba.fastjson2.JSON;
  4 +import com.baomidou.mybatisplus.annotation.TableField;
4 5 import lombok.Data;
5   -import org.apache.poi.hpsf.Decimal;
6 6  
7 7 import java.math.BigDecimal;
8 8 import java.util.Date;
... ... @@ -27,12 +27,17 @@ public class DriverScheduling {
27 27 private Integer alcoholFlag;
28 28 private BigDecimal alcoholIntake;
29 29 private String remark;
  30 + @TableField(exist = false)
30 31 private String siteName;
31 32 /**
32 33 * 不是当前表的属性
33 34 */
  35 + @TableField(exist = false)
34 36 private String fleetName;
35 37  
  38 + @TableField(exist = false)
  39 + private long minTime;
  40 +
36 41 @Override
37 42 public String toString() {
38 43 return JSON.toJSONString(this);
... ...
Bsth-admin/src/main/java/com/ruoyi/driver/domain/Driver.java
1 1 package com.ruoyi.driver.domain;
2 2  
  3 +import com.alibaba.fastjson2.JSON;
3 4 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4 5 import io.swagger.annotations.ApiModel;
5 6 import io.swagger.annotations.ApiModelProperty;
... ... @@ -159,6 +160,11 @@ public class Driver extends BaseEntity implements Serializable {
159 160 }
160 161  
161 162 @Override
  163 + public String toString() {
  164 + return JSON.toJSONString(this);
  165 + }
  166 +
  167 + @Override
162 168 public int hashCode() {
163 169 return new HashCodeBuilder(17, 37).append(getId()).append(getJobCode()).append(getCompanyCode()).append(getBrancheCompanyCode()).append(getPersonnelName()).append(getPapersCode()).append(getIcCardCode()).append(getPersonnelType()).append(getPosts()).append(getCard()).append(getTelphone()).append(getIcRfid()).append(getIdRfid()).append(getTagRfid()).append(getLineName()).append(getLineCode()).append(getFaceSignIn()).append(getImage()).append(getUpdateTime()).append(getSignInEquipment()).append(getFleetName()).toHashCode();
164 170 }
... ...
Bsth-admin/src/main/java/com/ruoyi/in/controller/SignInController.java
1 1 package com.ruoyi.in.controller;
2 2  
3   -import java.io.IOException;
4   -import java.util.List;
5   -import javax.servlet.http.HttpServletRequest;
6   -import javax.servlet.http.HttpServletResponse;
7   -
  3 +import com.ruoyi.common.annotation.Log;
  4 +import com.ruoyi.common.core.controller.BaseController;
  5 +import com.ruoyi.common.core.domain.AjaxResult;
  6 +import com.ruoyi.common.core.page.TableDataInfo;
  7 +import com.ruoyi.common.enums.BusinessType;
8 8 import com.ruoyi.common.exception.file.FileUploadException;
  9 +import com.ruoyi.common.utils.poi.ExcelUtil;
  10 +import com.ruoyi.in.domain.SignIn;
  11 +import com.ruoyi.in.service.ISignInService;
  12 +import com.ruoyi.in.service.SignInServiceV1;
9 13 import com.ruoyi.pojo.response.SignInResponseVo;
10 14 import io.swagger.annotations.Api;
11 15 import io.swagger.annotations.ApiOperation;
12 16 import io.swagger.annotations.ApiParam;
  17 +import lombok.extern.slf4j.Slf4j;
  18 +import org.apache.commons.lang3.RandomUtils;
13 19 import org.springframework.beans.factory.annotation.Autowired;
14 20 import org.springframework.validation.annotation.Validated;
15   -import org.springframework.web.bind.annotation.GetMapping;
16   -import org.springframework.web.bind.annotation.PostMapping;
17   -import org.springframework.web.bind.annotation.PutMapping;
18   -import org.springframework.web.bind.annotation.DeleteMapping;
19   -import org.springframework.web.bind.annotation.PathVariable;
20   -import org.springframework.web.bind.annotation.RequestBody;
21   -import org.springframework.web.bind.annotation.RequestMapping;
22   -import org.springframework.web.bind.annotation.RestController;
23   -import com.ruoyi.common.annotation.Log;
24   -import com.ruoyi.common.core.controller.BaseController;
25   -import com.ruoyi.common.core.domain.AjaxResult;
26   -import com.ruoyi.common.enums.BusinessType;
27   -import com.ruoyi.in.domain.SignIn;
28   -import com.ruoyi.in.service.ISignInService;
29   -import com.ruoyi.common.utils.poi.ExcelUtil;
30   -import com.ruoyi.common.core.page.TableDataInfo;
  21 +import org.springframework.web.bind.annotation.*;
  22 +
  23 +import javax.servlet.http.HttpServletRequest;
  24 +import javax.servlet.http.HttpServletResponse;
  25 +import java.io.IOException;
  26 +import java.util.List;
31 27  
32 28 /**
33 29 * 签到Controller
... ... @@ -35,12 +31,16 @@ import com.ruoyi.common.core.page.TableDataInfo;
35 31 * @author guzijian
36 32 * @date 2023-07-05
37 33 */
  34 +@Slf4j
38 35 @RestController
39 36 @RequestMapping("/in/in")
40 37 @Api(tags = "签到管理")
41 38 public class SignInController extends BaseController {
42 39 @Autowired
43 40 private ISignInService signInService;
  41 + @Autowired
  42 + private SignInServiceV1 signInServiceV1;
  43 +
44 44  
45 45 /**
46 46 * 查询签到列表
... ... @@ -99,7 +99,14 @@ public class SignInController extends BaseController {
99 99 @PostMapping("/newAdd")
100 100 @ApiOperation("新增签到(设备传入)")
101 101 public AjaxResult addSignIn(@ApiParam @RequestBody @Validated SignIn signIn) throws FileUploadException, IOException {
102   - return signInService.addSignIn(signIn);
  102 + Integer num = RandomUtils.nextInt(0, 9);
  103 + if (num < 3) {
  104 + log.info("[{}] sing method 走新的签到方式 :[{}] ", num, signIn);
  105 + return signInServiceV1.addsignInV1(signIn);
  106 + } else {
  107 + log.info("[{}] sing method old sign :[{}]", num, signIn);
  108 + return signInService.addSignIn(signIn);
  109 + }
103 110 }
104 111  
105 112 // /**
... ... @@ -123,14 +130,13 @@ public class SignInController extends BaseController {
123 130 // public AjaxResult remove(@PathVariable Long[] ids) {
124 131 // return toAjax(signInService.deleteSignInByIds(ids));
125 132 // }
126   -
127 133 @GetMapping("/repair")
128   - public AjaxResult repairSignRecord(HttpServletRequest request){
  134 + public AjaxResult repairSignRecord(HttpServletRequest request) {
129 135 return AjaxResult.success(signInService.repairSignRecord(request));
130 136 }
131 137  
132 138 @GetMapping("/repairAll/{date}")
133   - public AjaxResult repairAllSignRecord(HttpServletRequest request,@PathVariable("date") String date){
134   - return AjaxResult.success(signInService.repairAllSignRecord(request,date));
  139 + public AjaxResult repairAllSignRecord(HttpServletRequest request, @PathVariable("date") String date) {
  140 + return AjaxResult.success(signInService.repairAllSignRecord(request, date));
135 141 }
136 142 }
... ...
Bsth-admin/src/main/java/com/ruoyi/in/domain/SignIn.java
1 1 package com.ruoyi.in.domain;
2 2  
3   -import java.io.UnsupportedEncodingException;
4   -import java.math.BigDecimal;
5   -
6 3 import com.alibaba.fastjson2.JSON;
  4 +import com.ruoyi.common.annotation.Excel;
  5 +import com.ruoyi.common.core.domain.BaseEntity;
7 6 import io.swagger.annotations.ApiModel;
8 7 import io.swagger.annotations.ApiModelProperty;
9 8 import lombok.Data;
10   -import org.apache.commons.lang3.builder.ToStringBuilder;
11   -import org.apache.commons.lang3.builder.ToStringStyle;
12   -import com.ruoyi.common.annotation.Excel;
13   -import com.ruoyi.common.core.domain.BaseEntity;
14 9  
15 10 import javax.validation.constraints.NotBlank;
16 11 import javax.validation.constraints.NotNull;
  12 +import java.math.BigDecimal;
17 13  
18 14 /**
19 15 * 签到对象 sign_in
... ... @@ -96,13 +92,17 @@ public class SignIn extends BaseEntity {
96 92 @Excel(name = "酒精摄入量")
97 93 @ApiModelProperty("酒精摄入量 52.12")
98 94 private BigDecimal alcoholIntake;
99   - @Excel(name = "异常类型",readConverterExp = "0=无异常,1=超时异常,2=无排班异常,3=酒精超标异常")
  95 + @Excel(name = "异常类型",readConverterExp = "0=无异常,1=超时异常,2=无排班异常,3=酒精超标异常,200=早签,300=迟到")
100 96 @ApiModelProperty("异常类型")
101 97 private Integer exType;
102 98  
103 99 @Override
104 100 public String toString() {
105   - return JSON.toJSONString(this);
  101 + String image = this.getImage();
  102 + this.setImage(null);
  103 + String str = JSON.toJSONString(this);
  104 + this.setImage(image);
  105 + return str;
106 106 }
107 107 }
108 108  
... ...
Bsth-admin/src/main/java/com/ruoyi/in/mapper/SignInMapperV1.java 0 → 100644
  1 +package com.ruoyi.in.mapper;
  2 +
  3 +import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  4 +import com.ruoyi.in.domain.SignInV1;
  5 +
  6 +import javax.annotation.Resource;
  7 +
  8 +@Resource
  9 +public interface SignInMapperV1 extends BaseMapper<SignInV1> {
  10 +}
... ...
Bsth-admin/src/main/java/com/ruoyi/in/service/SignInServiceV1.java 0 → 100644
  1 +package com.ruoyi.in.service;
  2 +
  3 +import com.baomidou.mybatisplus.extension.service.IService;
  4 +import com.ruoyi.common.core.domain.AjaxResult;
  5 +import com.ruoyi.in.domain.SignIn;
  6 +import com.ruoyi.in.domain.SignInV1;
  7 +
  8 +import java.io.IOException;
  9 +
  10 +public interface SignInServiceV1 extends IService<SignInV1> {
  11 + AjaxResult addsignInV1(SignIn signIn) throws IOException;
  12 +}
... ...
Bsth-admin/src/main/java/com/ruoyi/in/service/impl/SignInServiceImpl.java
... ... @@ -38,6 +38,7 @@ import com.ruoyi.pojo.response.SignInResponseVo;
38 38 import com.ruoyi.service.SchedulingService;
39 39 import com.ruoyi.service.ThreadJobService;
40 40 import com.ruoyi.utils.ConstDateUtil;
  41 +import org.apache.commons.collections4.CollectionUtils;
41 42 import org.apache.commons.io.FilenameUtils;
42 43 import org.slf4j.Logger;
43 44 import org.slf4j.LoggerFactory;
... ... @@ -170,9 +171,16 @@ public class SignInServiceImpl implements ISignInService {
170 171 List<DriverScheduling> dto = schedulingService.queryScheduling(signIn.getJobCode(), now);
171 172 handleSignBody(signIn, driver, globalIndex, now, dto);
172 173  
173   - log.info("签到签退数据为:[{}]",dto.get(globalIndex.getIndex()));
174 174  
175   - if (PERSONNEL_POSTS_DRIVER.equals(driver.getPosts()) && Objects.equals(dto.get(globalIndex.getIndex()).getBcType(), BC_TYPE_OUT)) {
  175 + if (CollectionUtils.isNotEmpty(dto)) {
  176 + int size = CollectionUtils.size(dto);
  177 + if (size > 0 && globalIndex.getIndex() < size) {
  178 + log.info("签到签退数据为:[{}]", dto.get(globalIndex.getIndex()));
  179 + }
  180 + } else {
  181 + log.info("没有签到或签退的数据");
  182 + }
  183 + if (PERSONNEL_POSTS_DRIVER.equals(driver.getPosts()) && CollectionUtils.isNotEmpty(dto) && Objects.equals(dto.get(globalIndex.getIndex()).getBcType(), BC_TYPE_OUT)) {
176 184 AjaxResult result = getAjaxResultByDriverSignInfo(signIn, vo);
177 185 if (!Objects.isNull(result)) {
178 186 String msg = "签到异常: 请使用手持式酒精测试棒进行酒测";
... ...
Bsth-admin/src/main/java/com/ruoyi/in/service/impl/SignInServiceV1Impl.java 0 → 100644
  1 +package com.ruoyi.in.service.impl;
  2 +
  3 +import com.alibaba.fastjson2.JSON;
  4 +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  5 +import com.ruoyi.common.ConstDriverProperties;
  6 +import com.ruoyi.common.ConstSignInConstSignInProperties;
  7 +import com.ruoyi.common.ErrorTypeProperties;
  8 +import com.ruoyi.common.cache.TempCache;
  9 +import com.ruoyi.common.config.RuoYiConfig;
  10 +import com.ruoyi.common.constant.Constants;
  11 +import com.ruoyi.common.core.domain.AjaxResult;
  12 +import com.ruoyi.common.core.redis.RedisCache;
  13 +import com.ruoyi.common.redispre.GlobalRedisPreName;
  14 +import com.ruoyi.common.utils.DateUtils;
  15 +import com.ruoyi.common.utils.StringUtils;
  16 +import com.ruoyi.common.utils.ip.IpUtils;
  17 +import com.ruoyi.common.utils.uuid.Seq;
  18 +import com.ruoyi.common.utils.uuid.UUID;
  19 +import com.ruoyi.domain.DriverScheduling;
  20 +import com.ruoyi.domain.DriverSchedulingV1;
  21 +import com.ruoyi.driver.domain.Driver;
  22 +import com.ruoyi.driver.mapper.DriverMapper;
  23 +import com.ruoyi.equipment.domain.Equipment;
  24 +import com.ruoyi.equipment.mapper.EquipmentMapper;
  25 +import com.ruoyi.in.domain.CalDriverScheduling;
  26 +import com.ruoyi.in.domain.SignIn;
  27 +import com.ruoyi.in.domain.SignInV1;
  28 +import com.ruoyi.in.mapper.SignInMapper;
  29 +import com.ruoyi.in.mapper.SignInMapperV1;
  30 +import com.ruoyi.in.service.SignInServiceV1;
  31 +import com.ruoyi.scheduling.service.SchedulingServiceV1;
  32 +import com.ruoyi.service.BigViewServiceV1;
  33 +import com.ruoyi.service.SchedulingService;
  34 +import com.ruoyi.service.ThreadJobService;
  35 +import com.ruoyi.utils.ConstDateUtil;
  36 +import lombok.extern.slf4j.Slf4j;
  37 +import org.apache.commons.collections4.CollectionUtils;
  38 +import org.apache.commons.io.FilenameUtils;
  39 +import org.apache.commons.lang3.time.FastDateFormat;
  40 +import org.springframework.beans.BeanUtils;
  41 +import org.springframework.beans.factory.annotation.Autowired;
  42 +import org.springframework.stereotype.Service;
  43 +
  44 +import javax.annotation.Resource;
  45 +import java.io.File;
  46 +import java.io.IOException;
  47 +import java.math.BigDecimal;
  48 +import java.util.*;
  49 +import java.util.concurrent.atomic.AtomicInteger;
  50 +
  51 +import static com.ruoyi.common.ConstSignInConstSignInProperties.*;
  52 +import static com.ruoyi.common.ErrorTypeProperties.SIGN_IN_ERROR;
  53 +import static com.ruoyi.common.ErrorTypeProperties.SIGN_OUT_ERROR;
  54 +
  55 +@Slf4j
  56 +@Service
  57 +public class SignInServiceV1Impl extends ServiceImpl<SignInMapperV1, SignInV1> implements SignInServiceV1 {
  58 +
  59 + @Autowired
  60 + private DriverMapper driverMapper;
  61 + @Autowired
  62 + private EquipmentMapper equipmentMapper;
  63 + @Autowired
  64 + private SchedulingServiceV1 schedulingServiceV1;
  65 +
  66 + @Resource
  67 + private ThreadJobService threadJobService;
  68 + @Resource
  69 + private SchedulingService schedulingService;
  70 + @Resource
  71 + private BigViewServiceV1 bigViewServiceV1;
  72 +
  73 + @Autowired
  74 + private SignInMapper signInMapper;
  75 +
  76 + @Autowired
  77 + private RedisCache redisCache;
  78 +
  79 + private static final FastDateFormat HHMM = FastDateFormat.getInstance("HH:mm");
  80 +
  81 + @Override
  82 + public AjaxResult addsignInV1(SignIn signIn) throws IOException {
  83 +
  84 + SignInV1 signInV1 = new SignInV1();
  85 +
  86 + // 查询员工信息
  87 + Driver driver = driverMapper.getDriverInfoByJobCode(signIn.getJobCode());
  88 + if (Objects.isNull(driver)) {
  89 + log.info("这个工号的员工不存在:[{}]", signIn);
  90 + return AjaxResult.warn("这个工号的员工不存在!");
  91 + }
  92 +
  93 + Equipment equipment = equipmentMapper.selectEquipmentByDeviceId(signIn.getDeviceId());
  94 + if (Objects.isNull(equipment)) {
  95 + log.info("这个设备号不存在:[{}]", signIn);
  96 + return AjaxResult.warn("这个设备号不存在");
  97 + }
  98 +
  99 + signInV1.setAddress(equipment.getAddress());
  100 + signInV1.setDeviceId(signIn.getDeviceId());
  101 + signInV1.setSiteName(equipment.getSiteName());
  102 + signInV1.setName(driver.getPersonnelName());
  103 + signInV1.setPosts(driver.getPosts());
  104 +
  105 + if (Objects.isNull(signIn.getCreateTime())) {
  106 + signIn.setCreateTime(DateUtils.getNowDate());
  107 + }
  108 + long dateTime = signIn.getCreateTime().getTime();
  109 + Date date = DateUtils.shortDate(new Date(dateTime));
  110 + DriverScheduling scheduling = null;
  111 + CalDriverScheduling calDriverScheduling = null;
  112 +
  113 + uploadImage(signIn);
  114 + List<DriverSchedulingV1> schedulings = schedulingServiceV1.queryByJobCodeAndSchedulingDate(signIn.getJobCode(), date);
  115 + if (CollectionUtils.isEmpty(schedulings)) {
  116 + saveSignOfNoScheduling(signIn, ErrorTypeProperties.WORK_DAY_ERROR);
  117 + switchAndChooseAlcohol(signIn, driver, null);
  118 + return saveData(signIn, null, null, driver, signInV1);
  119 + } else if (Objects.equals(2, signIn.getType())) {
  120 + calDriverScheduling = findSchedulingByDateTime(schedulings, dateTime, ConstDriverProperties.BC_TYPE_IN);
  121 + } else {
  122 + if (checkAlcoholIntake(signIn.getAlcoholIntake())) {
  123 + AjaxResult ajaxResult = bigViewServiceV1.getAjaxResultByDriverSignInfo(signIn);
  124 + if (Objects.nonNull(ajaxResult)) {
  125 + return ajaxResult;
  126 + }
  127 + }
  128 + calDriverScheduling = findSchedulingByDateTime(schedulings, dateTime, ConstDriverProperties.BC_TYPE_OUT);
  129 + }
  130 +
  131 + if (Objects.isNull(calDriverScheduling.getDriverScheduling())) {
  132 + log.info("当天没有满足要求的数据:dateTime:[{}],signIn:[{}],scheduling:[{}]", dateTime, signIn, JSON.toJSONString(scheduling));
  133 + saveSignOfNoScheduling(signIn, ErrorTypeProperties.WORK_DAY_ERROR);
  134 + return AjaxResult.success(ErrorTypeProperties.WORK_DAY_ERROR);
  135 + }
  136 +
  137 + scheduling = calDriverScheduling.getDriverScheduling();
  138 +
  139 + if (Objects.isNull(scheduling.getSignInId())) {
  140 + switchAndChooseTime(signIn, scheduling, dateTime);
  141 + switchAndChooseAlcohol(signIn, driver, scheduling);
  142 +
  143 + } else {
  144 + SignInV1 sourceSign = getById(scheduling.getSignInId());
  145 + if (Objects.nonNull(sourceSign)) {
  146 + switchAndChooseTime(signIn, scheduling, dateTime);
  147 + switchAndChooseAlcohol(signIn, driver, scheduling);
  148 + }
  149 + }
  150 + return saveData(signIn, scheduling, calDriverScheduling, driver, signInV1);
  151 + }
  152 +
  153 + private AjaxResult saveData(SignIn signIn, DriverScheduling scheduling, CalDriverScheduling calDriverScheduling, Driver driver, SignInV1 signInV1) {
  154 + signInMapper.insertSignIn(signIn);
  155 + // 更新考勤
  156 + if (Objects.nonNull(calDriverScheduling)) {
  157 + schedulingService.computedSignInBySignIn(scheduling, calDriverScheduling.getIndex(), signIn);
  158 + }
  159 +
  160 + if (TempCache.checkJobCodeExist(signIn.getJobCode())) {
  161 + TempCache.updateSignStatus(signIn.getJobCode());
  162 + }
  163 +
  164 + // 异常保存到异常异常中
  165 + threadJobService.asyncInsertExceptionRecord(signIn, driver, scheduling);
  166 +
  167 + return handleAjaxResult(signIn, signInV1);
  168 + }
  169 +
  170 +
  171 + private AjaxResult handleAjaxResult(SignIn signIn, SignInV1 signInV1) {
  172 +
  173 + // 酒精测试后续恢复的需要删除异常的酒测缓存
  174 + BeanUtils.copyProperties(signIn, signInV1);
  175 + if (SIGN_IN_SUCCESS.equals(signIn.getStatus())) {
  176 + String prompt = signIn.getRemark().replace("正常", "");
  177 + if (signIn.getType().equals(SIGN_OUT)) {
  178 + return AjaxResult.success(SIGN_OUT_SUCCESS_STRING + "," + prompt, signInV1);
  179 + } else {
  180 + return AjaxResult.success(SIGN_IN_SUCCESS_STRING + "," + prompt, signInV1);
  181 + }
  182 + } else {
  183 + if (signIn.getType().equals(SIGN_OUT)) {
  184 + return AjaxResult.success(SIGN_OUT_ERROR + ":" + signIn.getRemark(), signInV1);
  185 + }
  186 + return AjaxResult.success(SIGN_IN_ERROR + ":" + signIn.getRemark(), signInV1);
  187 + }
  188 + }
  189 +
  190 +
  191 + /***
  192 + * 判断是否酒驾;范围 0 =未做酒测;1=酒测;2=酒测正常
  193 + * @author liujun
  194 + * @date 2024/9/23 10:56
  195 + *
  196 + * @param signIn
  197 + * @param driver
  198 + * @param scheduling
  199 + * @return java.lang.Integer
  200 + */
  201 + private Integer switchAndChooseAlcohol(SignIn signIn, Driver driver, DriverScheduling scheduling) {
  202 + // 酒精测试校验 确定 且员工工种是驾驶员
  203 + if (ConstSignInConstSignInProperties.ALCOHOL_FLAG_YES.equals(signIn.getAlcoholFlag()) && ConstDriverProperties.PERSONNEL_POSTS_DRIVER.equals(driver.getPosts())) {
  204 + if (org.apache.commons.lang3.StringUtils.isEmpty(signIn.getIp())) {
  205 + signIn.setIp(IpUtils.getIpAddr());
  206 + }
  207 + Integer extype = Objects.isNull(signIn.getExType()) ? 0 : signIn.getExType();
  208 + if (checkAlcoholIntake(signIn.getAlcoholIntake())) {
  209 + threadJobService.asyncSendEmail(scheduling, signIn, driver);
  210 + signIn.setRemark(join(signIn.getRemark(), ErrorTypeProperties.ALCOHOL_SIGN_IN_ERROR, signIn.getAlcoholIntake().toString(), "mg/100ml。"));
  211 + signIn.setExType(extype + ConstSignInConstSignInProperties.SIGN_ALCOHOL_EX_NUM);
  212 +
  213 + signIn.setStatus(ConstSignInConstSignInProperties.SIGN_IN_FAIL);
  214 + signIn.setRemark(signIn.getRemark().replaceFirst(",$", "。"));
  215 +
  216 + return 1;
  217 + } else {
  218 + // 如果驾驶员酒精测试在之前不合格 必须重测
  219 + String key = GlobalRedisPreName.REDIS_SIGN_IN_DRIVER_ALCOHOL_OVERFLOW + ConstDateUtil.formatDate("yyyyMMdd") + ":" + driver.getJobCode();
  220 + Integer count = redisCache.getCacheObject(key);
  221 + if (!Objects.isNull(count)) {
  222 + redisCache.deleteObject(key);
  223 + }
  224 + if (Objects.isNull(signIn.getStatus()) || Objects.equals(signIn.getStatus(), ConstSignInConstSignInProperties.SIGN_IN_SUCCESS)) {
  225 + signIn.setStatus(ConstSignInConstSignInProperties.SIGN_IN_SUCCESS);
  226 + }
  227 + extype = extype > 9 ? extype : extype + ConstSignInConstSignInProperties.SIGN_NO_EX_NUM;
  228 + signIn.setExType(extype);
  229 + if (Objects.equals(0, signIn.getExType())) {
  230 + signIn.setRemark("正常");
  231 + }
  232 +
  233 +
  234 + return 2;
  235 + }
  236 + }
  237 + log.info("未做酒测:alcoholFlag[{}];posts:[{}]", signIn.getAlcoholFlag(), driver.getPosts());
  238 + return 0;
  239 + }
  240 +
  241 + private boolean checkAlcoholIntake(BigDecimal alcoholIntake) {
  242 + return Objects.nonNull(alcoholIntake) ? new BigDecimal("20").compareTo(alcoholIntake) <= 0 : Boolean.FALSE;
  243 + }
  244 +
  245 + private int switchAndChooseTime(SignIn signIn, DriverScheduling scheduling, long dateTime) {
  246 + if (Objects.equals(2, signIn.getType())) {
  247 + Date zdsj = new Date(scheduling.getZdsjT());
  248 +
  249 + Date date1 = org.apache.commons.lang3.time.DateUtils.addMinutes(zdsj, 80);
  250 + String fcsjHHMM = HHMM.format(zdsj);
  251 + String dzsjHHMM = HHMM.format(date1);
  252 +
  253 + String remark = org.apache.commons.lang3.StringUtils.join(ErrorTypeProperties.SIGN_OUT_TIMEOUT, "请在", fcsjHHMM, "到", dzsjHHMM, "之间打卡");
  254 + return switchAndChooseTime(signIn, dateTime, zdsj, 80, remark);
  255 + } else {
  256 + Date fcsj = new Date(scheduling.getFcsjT());
  257 +
  258 + String fcsjHHMM = HHMM.format(org.apache.commons.lang3.time.DateUtils.addMinutes(fcsj, -60));
  259 + String dzsjHHMM = HHMM.format(fcsj);
  260 +
  261 + String remark = org.apache.commons.lang3.StringUtils.join(ErrorTypeProperties.SIGN_IN_TIMEOUT, "请在", fcsjHHMM, "到", dzsjHHMM, "之间打卡");
  262 + return switchAndChooseTime(signIn, dateTime, fcsj, -60, remark);
  263 + }
  264 + }
  265 +
  266 + private String join(String... strs) {
  267 + int length = strs.length;
  268 + StringBuilder builder = new StringBuilder();
  269 + for (int i = 0; i < length; i++) {
  270 + if (org.apache.commons.lang3.StringUtils.isNotEmpty(strs[i])) {
  271 + if (org.apache.commons.lang3.StringUtils.isNotEmpty(builder.toString())) {
  272 + builder.append(";");
  273 + }
  274 + builder.append(strs[i]);
  275 + }
  276 + }
  277 + return builder.toString();
  278 + }
  279 +
  280 + /**
  281 + * 判断时间是否是早签、正常、迟到
  282 + *
  283 + * @param signIn 签到数据
  284 + * @param dateTime 打卡时间
  285 + * @param date 发车或到站时间
  286 + * @param value 允许的最大范围值
  287 + * @param remark 提示信息模板
  288 + * @author liujun
  289 + * @date 2024/9/20 17:14
  290 + */
  291 + private int switchAndChooseTime(SignIn signIn, long dateTime, Date date, Integer value, String remark) {
  292 + long time1 = date.getTime();
  293 + date = org.apache.commons.lang3.time.DateUtils.addMinutes(date, value);
  294 + long time = date.getTime();
  295 +
  296 + if (value < 0) {
  297 + if (dateTime < time) {
  298 + signIn.setExType(20);
  299 + signIn.setRemark(remark);
  300 + signIn.setStatus(2);
  301 +
  302 + return 1;
  303 + } else if (dateTime > time1) {
  304 + signIn.setExType(30);
  305 + signIn.setRemark(remark);
  306 + signIn.setStatus(2);
  307 +
  308 + return 2;
  309 + }
  310 + } else if (value > 0) {
  311 + if (dateTime < time1) {
  312 + signIn.setExType(20);
  313 + signIn.setRemark(remark);
  314 + signIn.setStatus(2);
  315 +
  316 + return 1;
  317 + } else if (dateTime > time) {
  318 + signIn.setExType(30);
  319 + signIn.setRemark(remark);
  320 + signIn.setStatus(2);
  321 +
  322 + return 2;
  323 + }
  324 + }
  325 +
  326 + signIn.setExType(0);
  327 + signIn.setStatus(1);
  328 +
  329 + return 0;
  330 + }
  331 +
  332 + /***
  333 + * 在数据中找出最近一条的排班数据
  334 + * @author liujun
  335 + * @date 2024/9/20 17:08
  336 + * @param schedulings 排班数据集合
  337 + * @param dateTime 打开时间
  338 + * @param type 签到类型
  339 + * @return com.ruoyi.domain.DriverScheduling
  340 + */
  341 + private CalDriverScheduling findSchedulingByDateTime(List<DriverSchedulingV1> schedulings, long dateTime, String type) {
  342 +
  343 + AtomicInteger atomicInteger = new AtomicInteger(-1);
  344 + Optional<DriverSchedulingV1> optional = schedulings.stream().map(s -> {
  345 + atomicInteger.addAndGet(1);
  346 + if (Objects.nonNull(s.getFcsjT()) && org.apache.commons.lang3.StringUtils.equalsAnyIgnoreCase(org.apache.commons.lang3.StringUtils.trim(s.getBcType()), type)) {
  347 + s.setMinTime(Math.abs(s.getFcsjT() - dateTime));
  348 + } else {
  349 + s.setMinTime(Long.MAX_VALUE);
  350 + }
  351 + return s;
  352 + }).min(Comparator.comparing(DriverScheduling::getMinTime));
  353 + return new CalDriverScheduling(atomicInteger.get(), optional.orElse(null));
  354 + }
  355 +
  356 + /**
  357 + * 没有排班数据
  358 + *
  359 + * @param signIn
  360 + * @param remark
  361 + * @author liujun
  362 + * @date 2024/9/20 16:41
  363 + */
  364 + private void saveSignOfNoScheduling(SignIn signIn, String remark) {
  365 + signIn.setRemark(remark);
  366 + signIn.setExType(2);
  367 + signIn.setStatus(2);
  368 + signIn.setType(1);
  369 +
  370 + }
  371 +
  372 + private void uploadImage(SignIn signIn) throws IOException {
  373 + String base64 = signIn.getImage();
  374 + // 图片路径
  375 + String filePath = RuoYiConfig.getUploadPath();
  376 + // 固定jpg文件
  377 + String fileName = "";
  378 + // 看是否带有base64前缀 有就判断文件类型 没有默认jpg
  379 + fileName = checkImageBase64Format(signIn.getImage());
  380 + fileName = extractFilename(fileName);
  381 + // 获取相对路径
  382 + String absPath = getAbsoluteFile(filePath, fileName).getAbsolutePath();
  383 +
  384 + // 获取文件上传路径
  385 + String pathFileName = getPathFileName(filePath, fileName);
  386 + signIn.setImage(pathFileName);
  387 + signIn.setImage(signIn.getImage());
  388 + log.info("开始异步上传签到图片");
  389 + // 异步上传文件
  390 + threadJobService.asyncStartUploadBase64Image(absPath, base64);
  391 + }
  392 +
  393 + /**
  394 + * 检查文件类型
  395 + *
  396 + * @param base64ImgData
  397 + * @return
  398 + */
  399 + public static String checkImageBase64Format(String base64ImgData) {
  400 + byte[] b = Base64.getDecoder().decode(base64ImgData);
  401 + String type = "";
  402 + if (0x424D == ((b[0] & 0xff) << 8 | (b[1] & 0xff))) {
  403 + type = "bmp";
  404 + } else if (0x8950 == ((b[0] & 0xff) << 8 | (b[1] & 0xff))) {
  405 + type = "png";
  406 + } else {
  407 + type = "jpg";
  408 + }
  409 +// else if (0xFFD8 == ((b[0] & 0xff) << 8 | (b[1] & 0xff))) {
  410 +// type = "jpg";
  411 +// }
  412 + return type;
  413 + }
  414 +
  415 + /**
  416 + * 获取扩展文件名
  417 + *
  418 + * @param extendFileName
  419 + * @return
  420 + */
  421 + private String extractFilename(String extendFileName) {
  422 + return StringUtils.format("{}/{}_{}.{}", DateUtils.datePath(),
  423 + FilenameUtils.getBaseName(UUID.randomUUID().toString().replace("-", "")), Seq.getId(Seq.uploadSeqType), extendFileName);
  424 + }
  425 +
  426 + /**
  427 + * 获取相对路径名
  428 + *
  429 + * @param uploadDir
  430 + * @param fileName
  431 + * @return
  432 + * @throws IOException
  433 + */
  434 + private File getAbsoluteFile(String uploadDir, String fileName) throws IOException {
  435 + File desc = new File(uploadDir + File.separator + fileName);
  436 +
  437 + if (!desc.exists()) {
  438 + if (!desc.getParentFile().exists()) {
  439 + desc.getParentFile().mkdirs();
  440 + }
  441 + }
  442 + return desc;
  443 + }
  444 +
  445 + /**
  446 + * @param uploadDir
  447 + * @param fileName
  448 + * @return
  449 + * @throws IOException
  450 + */
  451 + private String getPathFileName(String uploadDir, String fileName) throws IOException {
  452 + int dirLastIndex = RuoYiConfig.getProfile().length() + 1;
  453 + String currentDir = StringUtils.substring(uploadDir, dirLastIndex);
  454 + return Constants.RESOURCE_PREFIX + "/" + currentDir + "/" + fileName;
  455 + }
  456 +
  457 +
  458 +}
... ...
Bsth-admin/src/main/java/com/ruoyi/pojo/vo/bigViewVo/FleetState.java
1 1 package com.ruoyi.pojo.vo.bigViewVo;
2 2  
  3 +import com.alibaba.fastjson2.JSON;
3 4 import lombok.Data;
4 5  
5 6 /**
6   - *
7 7 * @author 20412
8 8 */
9 9 @Data
10 10 public class FleetState {
11 11 private String lineName;
12 12 private Integer state;
  13 +
  14 + @Override
  15 + public String toString() {
  16 + return JSON.toJSONString(this);
  17 + }
13 18 }
... ...
Bsth-admin/src/main/java/com/ruoyi/pojo/vo/bigViewVo/LineInfo.java
... ... @@ -15,15 +15,18 @@ public class LineInfo {
15 15 private PersonInfoVo saleInfoVo;
16 16 private String lineName;
17 17 private String fleetName;
  18 +
18 19 @Data
19 20 public static class PersonInfoVo {
20 21 private String jobCode;
21 22 private String name;
22 23 private Integer signStatus;
  24 + private String posts;
23 25  
24 26 public void setSignStatus(SignStatusEnum statusEnum) {
25 27 this.signStatus = statusEnum.getStatus();
26 28 }
  29 +
27 30 public void setSignStatus(Integer status) {
28 31 this.signStatus = status;
29 32 }
... ...
Bsth-admin/src/main/java/com/ruoyi/scheduling/mapper/SchedulingMapperV1.java 0 → 100644
  1 +package com.ruoyi.scheduling.mapper;
  2 +
  3 +import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  4 +import com.ruoyi.domain.DriverSchedulingV1;
  5 +
  6 +import javax.annotation.Resource;
  7 +
  8 +@Resource
  9 +public interface SchedulingMapperV1 extends BaseMapper<DriverSchedulingV1> {
  10 +}
... ...
Bsth-admin/src/main/java/com/ruoyi/scheduling/service/SchedulingServiceV1.java 0 → 100644
  1 +package com.ruoyi.scheduling.service;
  2 +
  3 +import com.baomidou.mybatisplus.extension.service.IService;
  4 +import com.ruoyi.domain.DriverSchedulingV1;
  5 +
  6 +import java.util.Date;
  7 +import java.util.List;
  8 +
  9 +public interface SchedulingServiceV1 extends IService<DriverSchedulingV1> {
  10 +
  11 + List<DriverSchedulingV1> queryByJobCodeAndSchedulingDate(String jobCode, Date date);
  12 +}
... ...
Bsth-admin/src/main/java/com/ruoyi/scheduling/service/impl/SchedulingServiceV1Impl.java 0 → 100644
  1 +package com.ruoyi.scheduling.service.impl;
  2 +
  3 +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  4 +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  5 +import com.ruoyi.domain.DriverSchedulingV1;
  6 +import com.ruoyi.scheduling.mapper.SchedulingMapperV1;
  7 +import com.ruoyi.scheduling.service.SchedulingServiceV1;
  8 +import org.springframework.stereotype.Service;
  9 +
  10 +import java.util.Date;
  11 +import java.util.List;
  12 +
  13 +@Service
  14 +public class SchedulingServiceV1Impl extends ServiceImpl<SchedulingMapperV1, DriverSchedulingV1> implements SchedulingServiceV1 {
  15 +
  16 + @Override
  17 + public List<DriverSchedulingV1> queryByJobCodeAndSchedulingDate(String jobCode, Date date) {
  18 + LambdaQueryWrapper<DriverSchedulingV1> wrapper = new LambdaQueryWrapper<>();
  19 + wrapper.eq(DriverSchedulingV1::getJobCode, jobCode).eq(DriverSchedulingV1::getScheduleDate, date);
  20 + wrapper.orderByAsc(DriverSchedulingV1::getFcsjT);
  21 + return list(wrapper);
  22 + }
  23 +}
... ...
Bsth-admin/src/main/java/com/ruoyi/service/SchedulingService.java
... ... @@ -3,26 +3,25 @@ package com.ruoyi.service;
3 3 import cn.hutool.core.collection.CollectionUtil;
4 4 import com.ruoyi.common.cache.NowSchedulingCache;
5 5 import com.ruoyi.common.utils.DateUtils;
  6 +import com.ruoyi.domain.DriverScheduling;
6 7 import com.ruoyi.driver.mapper.DriverSchedulingMapper;
7 8 import com.ruoyi.in.domain.SignIn;
8 9 import com.ruoyi.in.mapper.SignInMapper;
9 10 import com.ruoyi.in.service.impl.SignInServiceImpl;
10 11 import com.ruoyi.pojo.DriverSignInRecommendation;
11 12 import com.ruoyi.pojo.GlobalIndex;
12   -import com.ruoyi.domain.DriverScheduling;
13 13 import com.ruoyi.pojo.request.ReportViewRequestVo;
14 14 import com.ruoyi.pojo.response.ReportViewResponseVo;
15 15 import com.ruoyi.utils.ConstDateUtil;
16 16 import com.ruoyi.utils.ToolUtils;
  17 +import org.apache.commons.lang3.StringUtils;
17 18 import org.springframework.beans.BeanUtils;
18 19 import org.springframework.beans.factory.annotation.Autowired;
19 20 import org.springframework.stereotype.Service;
20 21  
21 22 import javax.annotation.Resource;
22 23 import javax.servlet.http.HttpServletResponse;
23   -import java.time.LocalDate;
24 24 import java.time.LocalDateTime;
25   -import java.time.YearMonth;
26 25 import java.time.temporal.ChronoUnit;
27 26 import java.util.*;
28 27  
... ... @@ -40,6 +39,8 @@ public class SchedulingService {
40 39  
41 40 @Resource
42 41 private NowSchedulingCache nowSchedulingCache;
  42 + @Resource
  43 + private BigViewServiceV1 bigViewServiceV1;
43 44  
44 45 @Autowired
45 46 private DriverSchedulingMapper schedulingMapper;
... ... @@ -106,6 +107,7 @@ public class SchedulingService {
106 107 return timeMap.get(index);
107 108 }
108 109  
  110 +
109 111 /**
110 112 * 更具最新的签到记录判断是否需要更新考勤。
111 113 *
... ... @@ -138,6 +140,64 @@ public class SchedulingService {
138 140  
139 141 }
140 142  
  143 + /**
  144 + * 更具最新的签到记录判断是否需要更新考勤。
  145 + *
  146 + * @param signIn
  147 + */
  148 + public void computedSignInBySignIn(DriverScheduling driverScheduling, int index, SignIn signIn) {
  149 + // 无排班不记录不在考勤表不更新
  150 + if (Objects.isNull(driverScheduling)) {
  151 + return;
  152 + }
  153 + String remark = getRemark(driverScheduling, signIn);
  154 + // 更新最新的签到记录判断是否需要更新考勤
  155 + // 记录为空直接插入记录
  156 + if (Objects.isNull(driverScheduling.getSignInId())) {
  157 + schedulingMapper.updateRoster(driverScheduling, signIn.getId(), signIn.getExType(), signIn.getCreateTime(), remark, signIn.getType(), signIn.getAlcoholFlag(), signIn.getAlcoholIntake());
  158 + // 更新缓存
  159 + nowSchedulingCache.updateCacheByJobCode(remark, ConstDateUtil.formatDate(driverScheduling.getScheduleDate()), index, signIn);
  160 + }
  161 + // 之前的无效
  162 + else if (!SIGN_NO_EX_NUM.equals(driverScheduling.getExType())) {
  163 + schedulingMapper.updateRoster(driverScheduling, signIn.getId(), signIn.getExType(), signIn.getCreateTime(), remark, signIn.getType(), signIn.getAlcoholFlag(), signIn.getAlcoholIntake());
  164 + nowSchedulingCache.updateCacheByJobCode(remark, ConstDateUtil.formatDate(driverScheduling.getScheduleDate()), index, signIn);
  165 + }
  166 + // 之前的有效
  167 + else {
  168 + handlerRecord(driverScheduling, signIn, index);
  169 + }
  170 +
  171 + }
  172 +
  173 + private void handlerRecord(DriverScheduling scheduling, SignIn signIn, Integer index) {
  174 + if (Objects.isNull(scheduling)) {
  175 + return;
  176 + }
  177 + long timer = 1000 * 60 * 3;
  178 + // 有效的在三分钟内重复签到不做修改
  179 + if (signIn.getExType().equals(SIGN_NO_EX_NUM) && (DateUtils.getNowDate().getTime() - scheduling.getSignTime().getTime()) <= timer) {
  180 + signIn.setRemark("您已经打卡过了,请勿在3分钟内重复打卡");
  181 + return;
  182 + }
  183 + // 目前也有效 -》 无需更新 || 目前无效 -》往后更新
  184 + // TODO 判断时间 之前的有效 但是人员提前打卡且还在上次操作有效范围内需要往后偏移
  185 + // 但是操作一样时间还在有效范围内打卡的话会导致排班表数据不匹配
  186 +
  187 + if (signIn.getExType().equals(SIGN_NO_EX_NUM)) {
  188 + if (signIn.getType().equals(bcTypeTransform(scheduling.getBcType()))) {
  189 + return;
  190 + }
  191 + }
  192 +
  193 +
  194 + String remark = getRemark(scheduling, signIn);
  195 + signInMapper.updateSignIn(signIn);
  196 + schedulingMapper.updateRoster(scheduling, signIn.getId(), signIn.getExType(), signIn.getCreateTime(), remark, signIn.getType(), signIn.getAlcoholFlag(), signIn.getAlcoholIntake());
  197 + nowSchedulingCache.updateCacheByJobCode(remark, ConstDateUtil.formatDate(scheduling.getScheduleDate()), index, signIn);
  198 + }
  199 +
  200 +
141 201 private String getRemark(List<DriverScheduling> dto, SignIn signIn, Integer globalIndex) {
142 202 StringBuilder sb = new StringBuilder();
143 203 DriverScheduling scheduling = dto.get(globalIndex);
... ... @@ -162,6 +222,25 @@ public class SchedulingService {
162 222 return sb.toString();
163 223 }
164 224  
  225 + private String getRemark(DriverScheduling scheduling, SignIn signIn) {
  226 + StringBuilder sb = new StringBuilder();
  227 + if (bigViewServiceV1.isEarly(signIn)) {
  228 + sb.append(EARLY);
  229 + } else if (bigViewServiceV1.isSignStatusDelayEnum(signIn)) {
  230 + sb.append(SIGN_STATUS_DELAY_ENUM.getDescription(scheduling.getBcType()));
  231 + } else {
  232 + sb.append(signIn.getRemark());
  233 + }
  234 +
  235 + if (bigViewServiceV1.isSignStatusWineEnum(signIn) && StringUtils.isNotEmpty(signIn.getRemark())) {
  236 + int index = signIn.getRemark().indexOf(ALCOHOL_SIGN_IN_ERROR);
  237 + if (index != -1) {
  238 + sb.append("," + signIn.getRemark().substring(index));
  239 + }
  240 + }
  241 + return sb.toString();
  242 + }
  243 +
165 244  
166 245 private void handlerRecord(List<DriverScheduling> dto, SignIn signIn, GlobalIndex globalIndex) {
167 246 if (globalIndex.getIndex() == dto.size() - 1) {
... ...
Bsth-admin/src/main/java/com/ruoyi/service/ThreadJobService.java
... ... @@ -189,6 +189,31 @@ public class ThreadJobService {
189 189 }
190 190 }
191 191  
  192 + @Async
  193 + public void asyncInsertExceptionRecord(SignIn signIn, Driver driver, DriverScheduling scheduling) {
  194 + if (!SIGN_NO_EX_NUM.equals(signIn.getExType())) {
  195 + EquipmentException exception = new EquipmentException();
  196 + exception.setExType(signIn.getExType());
  197 + exception.setDeviceId(signIn.getDeviceId());
  198 + exception.setJobCode(signIn.getJobCode());
  199 + exception.setStatus(EQUIPMENT_PROCESS_FLOW_COMMIT);
  200 + exception.setImage(signIn.getImage());
  201 + exception.setTitle("打卡异常");
  202 + exception.setRemark(signIn.getRemark());
  203 + exception.setCreateTime(signIn.getCreateTime());
  204 + exception.setFleetName(driver.getFleetName());
  205 + if (Objects.nonNull(scheduling)) {
  206 + exception.setNbbm(scheduling.getNbbm());
  207 + exception.setLineName(scheduling.getLineName());
  208 + exception.setPlanTime(scheduling.getBcType().equals(BC_TYPE_IN) ? new Date(scheduling.getZdsjT()) : new Date(scheduling.getFcsjT()));
  209 + }
  210 + exception.setSignType(signIn.getType());
  211 + exceptionMapper.insertEquipmentException(exception);
  212 + // 发送通知
  213 + sendNotice(signIn, driver, scheduling);
  214 + }
  215 + }
  216 +
192 217 private void sendNotice(SignIn signIn, Driver driver, List<DriverScheduling> dto, GlobalIndex globalIndex) {
193 218 if (SIGN_ALCOHOL_EX_NUM.equals(signIn.getExType())) {
194 219 SysNotice notice = new SysNotice();
... ... @@ -219,6 +244,34 @@ public class ThreadJobService {
219 244 }
220 245 }
221 246  
  247 + private void sendNotice(SignIn signIn, Driver driver, DriverScheduling item) {
  248 + if (SIGN_ALCOHOL_EX_NUM.equals(signIn.getExType())) {
  249 + SysNotice notice = new SysNotice();
  250 + notice.setCreateBy("system");
  251 + notice.setUpdateBy("system");
  252 + notice.setNoticeTitle("酒精测试异常通知");
  253 +
  254 + if (Objects.isNull(item)) {
  255 + item = new DriverScheduling();
  256 + handlerNoScheduling(item, signIn, driver);
  257 + }
  258 + String jobCode = "工号:" + item.getJobCode() + "\n";
  259 + String name = "姓名:" + item.getName() + "\n";
  260 + String posts = "工种:" + item.getPosts() + "\n";
  261 + String fleetName = "车队:" + item.getFleetName() + "\n";
  262 + String scheduling = "排班:" + (Objects.isNull(item.getScheduleDate()) ? "无排班" : "有排班") + "\n";
  263 + String signDate = "打卡时间:" + ConstDateUtil.formatDate("yyyy-MM-dd HH:mm:ss", signIn.getCreateTime()) + "\n";
  264 + String cause = "原因:酒精测试超标,当前测试值达到" + signIn.getAlcoholIntake() + "mg/100ml。属于" + getResultString(signIn.getAlcoholIntake());
  265 + String content = jobCode + name + posts + fleetName + scheduling + signDate + cause;
  266 + notice.setNoticeContent(content);
  267 + notice.setNoticeType("1");
  268 + notice.setStatus("0");
  269 + notice.setCreateTime(DateUtils.getNowDate());
  270 + notice.setUpdateTime(DateUtils.getNowDate());
  271 + noticeService.insertNotice(notice);
  272 + }
  273 + }
  274 +
222 275 private String getResultString(BigDecimal alcoholIntake) {
223 276 if (alcoholIntake.compareTo(new BigDecimal(20)) >= 0 && alcoholIntake.compareTo(new BigDecimal(80)) < 0) {
224 277 return "饮酒后驾驶机动车";
... ... @@ -269,6 +322,28 @@ public class ThreadJobService {
269 322  
270 323 }
271 324  
  325 + /**
  326 + * 异步发送邮件
  327 + *
  328 + * @param scheduling
  329 + * @param signIn
  330 + * @param driver
  331 + */
  332 + @Async
  333 + public void asyncSendEmail(DriverScheduling scheduling, SignIn signIn, Driver driver) {
  334 + DriverScheduling item = null;
  335 + if (Objects.isNull(scheduling)) {
  336 + item = new DriverScheduling();
  337 + handlerNoScheduling(item, signIn, driver);
  338 + // 无排班
  339 + emailService.sendWarningEmail(item, signIn.getCreateTime(), signIn.getAlcoholIntake());
  340 + } else {
  341 + // 有排班
  342 + emailService.sendWarningEmail(scheduling, signIn.getCreateTime(), signIn.getAlcoholIntake());
  343 + }
  344 +
  345 + }
  346 +
272 347 private void handlerNoScheduling(DriverScheduling item, SignIn signIn, Driver driver) {
273 348 BeanUtils.copyProperties(signIn, item);
274 349 item.setName(driver.getPersonnelName());
... ...
Bsth-admin/src/main/java/com/ruoyi/service/impl/BigViewServiceImpl.java
... ... @@ -104,10 +104,14 @@ public class BigViewServiceImpl implements BigViewService {
104 104 for (LineInfo lineInfo : fleetInfo.getLineInfos()) {
105 105 LineInfo.PersonInfoVo driverInfoVo = lineInfo.getDriverInfoVo();
106 106 LineInfo.PersonInfoVo saleInfoVo = lineInfo.getSaleInfoVo();
107   - Integer driverStatus = handleStateByPerson(driverInfoVo);
108   - Integer saleStatus = handleStateByPerson(saleInfoVo);
109   - int maxState = Math.max(driverStatus, saleStatus);
110   - state = Math.max(maxState, state);
  107 + if(Objects.nonNull(driverInfoVo) && Objects.nonNull(saleInfoVo)) {
  108 + Integer driverStatus = handleStateByPerson(driverInfoVo);
  109 + Integer saleStatus = handleStateByPerson(saleInfoVo);
  110 + if(Objects.nonNull(driverStatus) && Objects.nonNull(saleStatus)) {
  111 + int maxState = Math.max(driverStatus, saleStatus);
  112 + state = Math.max(maxState, state);
  113 + }
  114 + }
111 115 }
112 116 FleetState fleetState = new FleetState();
113 117 fleetState.setState(state);
... ...
Bsth-admin/src/main/java/com/ruoyi/template/domain/FleetLineTemplate.java
1 1 package com.ruoyi.template.domain;
2 2  
3   -import org.apache.commons.lang3.builder.ToStringBuilder;
4   -import org.apache.commons.lang3.builder.ToStringStyle;
  3 +import com.alibaba.fastjson2.JSON;
5 4 import com.ruoyi.common.annotation.Excel;
6 5 import com.ruoyi.common.core.domain.BaseEntity;
7 6  
... ... @@ -56,15 +55,6 @@ public class FleetLineTemplate extends BaseEntity
56 55  
57 56 @Override
58 57 public String toString() {
59   - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
60   - .append("id", getId())
61   - .append("fleetName", getFleetName())
62   - .append("lineName", getLineName())
63   - .append("createTime", getCreateTime())
64   - .append("updateTime", getUpdateTime())
65   - .append("createBy", getCreateBy())
66   - .append("updateBy", getUpdateBy())
67   - .append("remark", getRemark())
68   - .toString();
  58 + return JSON.toJSONString(this);
69 59 }
70 60 }
... ...
Bsth-admin/src/main/java/com/ruoyi/template/service/IFleetLineTemplateService.java
1 1 package com.ruoyi.template.service;
2 2  
3   -import java.util.List;
4 3 import com.ruoyi.template.domain.FleetLineTemplate;
5 4  
  5 +import java.util.List;
  6 +
6 7 /**
7 8 * 车队与线路对应模板Service接口
8 9 *
... ... @@ -28,6 +29,13 @@ public interface IFleetLineTemplateService
28 29 public List<FleetLineTemplate> selectFleetLineTemplateList(FleetLineTemplate fleetLineTemplate);
29 30  
30 31 /**
  32 + * 查询车队与线路对应模板列表
  33 + *
  34 + * @return 车队与线路对应模板集合
  35 + */
  36 + List<FleetLineTemplate> selectFleetLineTemplateList();
  37 +
  38 + /**
31 39 * 新增车队与线路对应模板
32 40 *
33 41 * @param fleetLineTemplate 车队与线路对应模板
... ...
Bsth-admin/src/main/java/com/ruoyi/template/service/impl/FleetLineTemplateServiceImpl.java
1 1 package com.ruoyi.template.service.impl;
2 2  
3   -import java.util.List;
  3 +import com.alibaba.fastjson2.JSON;
  4 +import com.ruoyi.common.core.redis.RedisCache;
4 5 import com.ruoyi.common.utils.DateUtils;
5 6 import com.ruoyi.common.utils.SecurityUtils;
6   -import org.springframework.beans.factory.annotation.Autowired;
7   -import org.springframework.stereotype.Service;
8   -import com.ruoyi.template.mapper.FleetLineTemplateMapper;
9 7 import com.ruoyi.template.domain.FleetLineTemplate;
  8 +import com.ruoyi.template.mapper.FleetLineTemplateMapper;
10 9 import com.ruoyi.template.service.IFleetLineTemplateService;
  10 +import lombok.extern.slf4j.Slf4j;
  11 +import org.apache.commons.collections4.CollectionUtils;
  12 +import org.apache.commons.lang3.StringUtils;
  13 +import org.springframework.beans.factory.annotation.Autowired;
  14 +import org.springframework.stereotype.Service;
  15 +
  16 +import java.util.List;
11 17  
12 18 /**
13 19 * 车队与线路对应模板Service业务层处理
14   - *
  20 + *
15 21 * @author guzijian
16 22 * @date 2023-12-04
17 23 */
  24 +@Slf4j
18 25 @Service
19   -public class FleetLineTemplateServiceImpl implements IFleetLineTemplateService
20   -{
  26 +public class FleetLineTemplateServiceImpl implements IFleetLineTemplateService {
21 27 @Autowired
22 28 private FleetLineTemplateMapper fleetLineTemplateMapper;
23 29  
  30 + @Autowired
  31 + private RedisCache redisCache;
  32 +
  33 + private static final String CONFIG_LINE = "config:fleet:line:template";
  34 +
24 35 /**
25 36 * 查询车队与线路对应模板
26   - *
  37 + *
27 38 * @param id 车队与线路对应模板主键
28 39 * @return 车队与线路对应模板
29 40 */
30 41 @Override
31   - public FleetLineTemplate selectFleetLineTemplateById(String id)
32   - {
  42 + public FleetLineTemplate selectFleetLineTemplateById(String id) {
33 43 return fleetLineTemplateMapper.selectFleetLineTemplateById(id);
34 44 }
35 45  
36 46 /**
37 47 * 查询车队与线路对应模板列表
38   - *
  48 + *
39 49 * @param fleetLineTemplate 车队与线路对应模板
40 50 * @return 车队与线路对应模板
41 51 */
42 52 @Override
43   - public List<FleetLineTemplate> selectFleetLineTemplateList(FleetLineTemplate fleetLineTemplate)
44   - {
  53 + public List<FleetLineTemplate> selectFleetLineTemplateList(FleetLineTemplate fleetLineTemplate) {
45 54 return fleetLineTemplateMapper.selectFleetLineTemplateList(fleetLineTemplate);
46 55 }
47 56  
  57 + @Override
  58 + public List<FleetLineTemplate> selectFleetLineTemplateList() {
  59 + List<FleetLineTemplate> fleetLineTemplates = getFleetLineTemplateOfRedis();
  60 + if (CollectionUtils.isEmpty(fleetLineTemplates)) {
  61 + fleetLineTemplates = selectFleetLineTemplateList(new FleetLineTemplate());
  62 + if (CollectionUtils.isNotEmpty(fleetLineTemplates)) {
  63 + redisCache.setCacheObject(CONFIG_LINE, JSON.toJSONString(fleetLineTemplates));
  64 + }
  65 + }
  66 +
  67 + return fleetLineTemplates;
  68 + }
  69 +
48 70 /**
49 71 * 新增车队与线路对应模板
50   - *
  72 + *
51 73 * @param fleetLineTemplate 车队与线路对应模板
52 74 * @return 结果
53 75 */
54 76 @Override
55   - public int insertFleetLineTemplate(FleetLineTemplate fleetLineTemplate)
56   - {
  77 + public int insertFleetLineTemplate(FleetLineTemplate fleetLineTemplate) {
57 78 fleetLineTemplate.setCreateTime(DateUtils.getNowDate());
58   - fleetLineTemplate.setCreateBy(SecurityUtils.getUsername());
  79 + fleetLineTemplate.setCreateBy(SecurityUtils.getUsername());
59 80 return fleetLineTemplateMapper.insertFleetLineTemplate(fleetLineTemplate);
60 81 }
61 82  
62 83 /**
63 84 * 修改车队与线路对应模板
64   - *
  85 + *
65 86 * @param fleetLineTemplate 车队与线路对应模板
66 87 * @return 结果
67 88 */
68 89 @Override
69   - public int updateFleetLineTemplate(FleetLineTemplate fleetLineTemplate)
70   - {
  90 + public int updateFleetLineTemplate(FleetLineTemplate fleetLineTemplate) {
71 91 fleetLineTemplate.setUpdateTime(DateUtils.getNowDate());
72   - fleetLineTemplate.setUpdateBy(SecurityUtils.getUsername());
  92 + fleetLineTemplate.setUpdateBy(SecurityUtils.getUsername());
73 93 return fleetLineTemplateMapper.updateFleetLineTemplate(fleetLineTemplate);
74 94 }
75 95  
76 96 /**
77 97 * 批量删除车队与线路对应模板
78   - *
  98 + *
79 99 * @param ids 需要删除的车队与线路对应模板主键
80 100 * @return 结果
81 101 */
82 102 @Override
83   - public int deleteFleetLineTemplateByIds(String[] ids)
84   - {
  103 + public int deleteFleetLineTemplateByIds(String[] ids) {
85 104 return fleetLineTemplateMapper.deleteFleetLineTemplateByIds(ids);
86 105 }
87 106  
88 107 /**
89 108 * 删除车队与线路对应模板信息
90   - *
  109 + *
91 110 * @param id 车队与线路对应模板主键
92 111 * @return 结果
93 112 */
94 113 @Override
95   - public int deleteFleetLineTemplateById(String id)
96   - {
  114 + public int deleteFleetLineTemplateById(String id) {
97 115 return fleetLineTemplateMapper.deleteFleetLineTemplateById(id);
98 116 }
99 117  
... ... @@ -106,4 +124,16 @@ public class FleetLineTemplateServiceImpl implements IFleetLineTemplateService
106 124 public void insertBatch(List<FleetLineTemplate> templateList) {
107 125 fleetLineTemplateMapper.insertBatch(templateList);
108 126 }
  127 +
  128 + private List<FleetLineTemplate> getFleetLineTemplateOfRedis() {
  129 + try {
  130 + String json = redisCache.getCacheObject(CONFIG_LINE);
  131 + if (StringUtils.isNotEmpty(json)) {
  132 + return JSON.parseArray(json, FleetLineTemplate.class);
  133 + }
  134 + } catch (Exception e) {
  135 + log.error("从redis中获取数据异常[{}]", CONFIG_LINE, e);
  136 + }
  137 + return null;
  138 + }
109 139 }
... ...
Bsth-admin/src/main/resources/application-druid-dev.yml
... ... @@ -28,7 +28,7 @@ spring:
28 28 # 主库数据源
29 29 master:
30 30 # 测试地址
31   - url: jdbc:mysql://localhost:3306/all-in-one?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&useAffectedRows=true&allowMultiQueries=true
  31 + url: jdbc:mysql://192.168.168.124:3306/all-in-one?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&useAffectedRows=true&allowMultiQueries=true
32 32 username: root
33 33 password: guzijian
34 34 # 从库数据源
... ... @@ -181,7 +181,7 @@ api:
181 181 log:
182 182 path: D:/ruoyi/logs
183 183 server:
184   - port: 8100
  184 + port: 8101
185 185 netty:
186 186 # 是否开启netty服务
187 187 enabled: true
... ...
Bsth-admin/src/main/resources/application-druid-uat.yml
... ... @@ -198,7 +198,7 @@ api:
198 198 people:
199 199 url: https://api.dingtalk.com/v1.0/yida/forms/instances/search
200 200 log:
201   - path: /home/health/logs
  201 + path: /home/health/log.path_IS_UNDEFINED
202 202 netty:
203 203 # 是否开启netty服务
204 204 enabled: true
... ...
Bsth-admin/src/main/resources/application.yml
... ... @@ -9,7 +9,7 @@ ruoyi:
9 9 # 实例演示开关
10 10 demoEnabled: true
11 11 # 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath)
12   - profile: D:/ruoyi/uploadPath
  12 + profile: ruoyi/uploadPath
13 13 # 获取ip地址开关
14 14 addressEnabled: false
15 15 # 验证码类型 math 数字计算 char 字符验证
... ... @@ -66,7 +66,7 @@ spring:
66 66 # 国际化资源文件路径
67 67 basename: i18n/messages
68 68 profiles:
69   - active: druid-dev
  69 + active: druid-prd
70 70 # 文件上传
71 71 servlet:
72 72 multipart:
... ... @@ -164,4 +164,4 @@ api:
164 164 appKey: dingsclwvxui5zilg1xk
165 165 appSecret: ckV20k3jMKJpUkfXXSGhLk077rQQjsSaAusiSVY-nm4glwweCmb_SMJ62Cpf4YQ5
166 166 log:
167   - path: E:/ruoyi/logs
168 167 \ No newline at end of file
  168 + path: logs
169 169 \ No newline at end of file
... ...
Bsth-admin/src/main/resources/logback.xml
... ... @@ -3,7 +3,7 @@
3 3 <!-- 日志存放路径 -->
4 4 <!-- <property name="log.path" value="E:/ruoyi/logs" />-->
5 5 <!-- <property name="log.path" value="D:/ruoyi/logs" />-->
6   - <springProperty name="log.path" source="log.path" defaultValue="E:/ruoyi/logs" />
  6 + <springProperty name="log.path" source="log.path" defaultValue="log.path_IS_UNDEFINED" />
7 7 />
8 8 <!-- <property name="log.path" value="/home/ruoyi/logs" />-->
9 9 <!-- 日志输出格式 -->
... ...
Bsth-common/src/main/java/com/ruoyi/common/core/domain/BaseEntity.java
1 1 package com.ruoyi.common.core.domain;
2 2  
  3 +import com.fasterxml.jackson.annotation.JsonFormat;
  4 +import com.fasterxml.jackson.annotation.JsonIgnore;
  5 +import com.fasterxml.jackson.annotation.JsonInclude;
  6 +
3 7 import java.io.Serializable;
4 8 import java.util.Date;
5 9 import java.util.HashMap;
6 10 import java.util.Map;
7   -import com.fasterxml.jackson.annotation.JsonFormat;
8   -import com.fasterxml.jackson.annotation.JsonIgnore;
9   -import com.fasterxml.jackson.annotation.JsonInclude;
10 11  
11 12 /**
12 13 * Entity基类
... ...
Bsth-common/src/main/java/com/ruoyi/common/core/redis/RedisCache.java
1 1 package com.ruoyi.common.core.redis;
2 2  
3   -import java.util.Collection;
4   -import java.util.Iterator;
5   -import java.util.List;
6   -import java.util.Map;
7   -import java.util.Set;
8   -import java.util.concurrent.TimeUnit;
9   -
10 3 import org.springframework.beans.factory.annotation.Autowired;
11 4 import org.springframework.data.redis.core.BoundSetOperations;
12 5 import org.springframework.data.redis.core.HashOperations;
... ... @@ -14,6 +7,9 @@ import org.springframework.data.redis.core.RedisTemplate;
14 7 import org.springframework.data.redis.core.ValueOperations;
15 8 import org.springframework.stereotype.Component;
16 9  
  10 +import java.util.*;
  11 +import java.util.concurrent.TimeUnit;
  12 +
17 13 /**
18 14 * spring redis 工具类
19 15 *
... ... @@ -31,10 +27,12 @@ public class RedisCache {
31 27 * @param key 缓存的键值
32 28 * @param value 缓存的值
33 29 */
  30 + @Deprecated
34 31 public <T> void setCacheObject(final String key, final T value) {
35 32 redisTemplate.opsForValue().set(key, value);
36 33 }
37 34  
  35 +
38 36 /**
39 37 * 缓存基本的对象,Integer、String、实体类等
40 38 *
... ... @@ -46,6 +44,7 @@ public class RedisCache {
46 44 public <T> void setCacheObject(final String key, final T value, final Integer timeout, final TimeUnit timeUnit) {
47 45 redisTemplate.opsForValue().set(key, value, timeout, timeUnit);
48 46 }
  47 +
49 48 public <T> void setCacheObject(final String key, final T value, final Long timeout, final TimeUnit timeUnit) {
50 49 redisTemplate.opsForValue().set(key, value, timeout, timeUnit);
51 50 }
... ... @@ -69,8 +68,8 @@ public class RedisCache {
69 68 * @param unit 时间单位
70 69 * @return true=设置成功;false=设置失败
71 70 */
72   - public void expire(final String key,Object val ,final long timeout, final TimeUnit unit) {
73   - redisTemplate.opsForValue().set(key, val,timeout, unit);
  71 + public void expire(final String key, Object val, final long timeout, final TimeUnit unit) {
  72 + redisTemplate.opsForValue().set(key, val, timeout, unit);
74 73 }
75 74  
76 75 /**
... ... @@ -241,7 +240,7 @@ public class RedisCache {
241 240 */
242 241 public <T> void setCacheMapValue(final String key, final String hKey, final T value, long timeOut, TimeUnit timeUnit) {
243 242 redisTemplate.opsForHash().put(key, hKey, value);
244   - redisTemplate.expire(key,timeOut,timeUnit);
  243 + redisTemplate.expire(key, timeOut, timeUnit);
245 244 }
246 245  
247 246 /**
... ... @@ -278,8 +277,8 @@ public class RedisCache {
278 277 return redisTemplate.opsForHash().delete(key, hKey) > 0;
279 278 }
280 279  
281   - public Integer setIncrementMapValue(String key, String hkey, Integer value){
282   - return redisTemplate.opsForHash().increment(key,hkey,value.longValue()).intValue();
  280 + public Integer setIncrementMapValue(String key, String hkey, Integer value) {
  281 + return redisTemplate.opsForHash().increment(key, hkey, value.longValue()).intValue();
283 282 }
284 283  
285 284 /**
... ... @@ -292,7 +291,7 @@ public class RedisCache {
292 291 return redisTemplate.keys(pattern);
293 292 }
294 293  
295   - public <T> Set<T> getHashKeys(String key){
  294 + public <T> Set<T> getHashKeys(String key) {
296 295 return redisTemplate.opsForHash().keys(key);
297 296 }
298 297  
... ... @@ -301,8 +300,14 @@ public class RedisCache {
301 300 return result != null && result;
302 301 }
303 302  
  303 + public boolean setNx(String key, Object val, Long timeout, TimeUnit unit) {
  304 + Boolean result = redisTemplate.opsForValue().setIfAbsent(key, val, timeout, unit);
  305 + return result != null && result;
  306 + }
  307 +
304 308 public Long increment(String key) {
305 309 Long increment = redisTemplate.opsForValue().increment(key);
306 310 return increment;
307 311 }
  312 +
308 313 }
... ...
Bsth-common/src/main/java/com/ruoyi/common/utils/DateUtils.java
... ... @@ -9,15 +9,17 @@ import java.time.LocalTime;
9 9 import java.time.ZoneId;
10 10 import java.time.ZonedDateTime;
11 11 import java.util.Date;
  12 +import java.util.Objects;
  13 +
12 14 import org.apache.commons.lang3.time.DateFormatUtils;
  15 +import org.apache.commons.lang3.time.FastDateFormat;
13 16  
14 17 /**
15 18 * 时间工具类
16   - *
  19 + *
17 20 * @author ruoyi
18 21 */
19   -public class DateUtils extends org.apache.commons.lang3.time.DateUtils
20   -{
  22 +public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
21 23 public static String YYYY = "yyyy";
22 24  
23 25 public static String YYYY_MM = "yyyy-MM";
... ... @@ -28,65 +30,72 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
28 30  
29 31 public static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
30 32  
  33 +
31 34 private static String[] parsePatterns = {
32   - "yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM",
  35 + "yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM",
33 36 "yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM",
34 37 "yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss", "yyyy.MM.dd HH:mm", "yyyy.MM"};
35 38  
  39 + public static FastDateFormat FAST_YYYY_MM_DD = FastDateFormat.getInstance("yyyy-MM-DD");
  40 +
36 41 /**
37 42 * 获取当前Date型日期
38   - *
  43 + *
39 44 * @return Date() 当前日期
40 45 */
41   - public static Date getNowDate()
42   - {
  46 + public static Date getNowDate() {
43 47 return new Date();
44 48 }
45 49  
  50 + public static Date shortDate() {
  51 + return shortDate(getNowDate());
  52 + }
  53 +
  54 + public static Date shortDate(Date date) {
  55 + if (Objects.isNull(date)) {
  56 + return null;
  57 + }
  58 + try {
  59 + return FAST_YYYY_MM_DD.parse(FAST_YYYY_MM_DD.format(date));
  60 + } catch (ParseException e) {
  61 + throw new RuntimeException(e);
  62 + }
  63 + }
  64 +
46 65 /**
47 66 * 获取当前日期, 默认格式为yyyy-MM-dd
48   - *
  67 + *
49 68 * @return String
50 69 */
51   - public static String getDate()
52   - {
  70 + public static String getDate() {
53 71 return dateTimeNow(YYYY_MM_DD);
54 72 }
55 73  
56 74  
57   - public static final String getTime()
58   - {
  75 + public static final String getTime() {
59 76 return dateTimeNow(YYYY_MM_DD_HH_MM_SS);
60 77 }
61 78  
62   - public static final String dateTimeNow()
63   - {
  79 + public static final String dateTimeNow() {
64 80 return dateTimeNow(YYYYMMDDHHMMSS);
65 81 }
66 82  
67   - public static final String dateTimeNow(final String format)
68   - {
  83 + public static final String dateTimeNow(final String format) {
69 84 return parseDateToStr(format, new Date());
70 85 }
71 86  
72   - public static final String dateTime(final Date date)
73   - {
  87 + public static final String dateTime(final Date date) {
74 88 return parseDateToStr(YYYY_MM_DD, date);
75 89 }
76 90  
77   - public static final String parseDateToStr(final String format, final Date date)
78   - {
  91 + public static final String parseDateToStr(final String format, final Date date) {
79 92 return new SimpleDateFormat(format).format(date);
80 93 }
81 94  
82   - public static final Date dateTime(final String format, final String ts)
83   - {
84   - try
85   - {
  95 + public static final Date dateTime(final String format, final String ts) {
  96 + try {
86 97 return new SimpleDateFormat(format).parse(ts);
87   - }
88   - catch (ParseException e)
89   - {
  98 + } catch (ParseException e) {
90 99 throw new RuntimeException(e);
91 100 }
92 101 }
... ... @@ -94,8 +103,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
94 103 /**
95 104 * 日期路径 即年/月/日 如2018/08/08
96 105 */
97   - public static final String datePath()
98   - {
  106 + public static final String datePath() {
99 107 Date now = new Date();
100 108 return DateFormatUtils.format(now, "yyyy/MM/dd");
101 109 }
... ... @@ -103,8 +111,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
103 111 /**
104 112 * 日期路径 即年/月/日 如20180808
105 113 */
106   - public static final String dateTime()
107   - {
  114 + public static final String dateTime() {
108 115 Date now = new Date();
109 116 return DateFormatUtils.format(now, "yyyyMMdd");
110 117 }
... ... @@ -112,18 +119,13 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
112 119 /**
113 120 * 日期型字符串转化为日期 格式
114 121 */
115   - public static Date parseDate(Object str)
116   - {
117   - if (str == null)
118   - {
  122 + public static Date parseDate(Object str) {
  123 + if (str == null) {
119 124 return null;
120 125 }
121   - try
122   - {
  126 + try {
123 127 return parseDate(str.toString(), parsePatterns);
124   - }
125   - catch (ParseException e)
126   - {
  128 + } catch (ParseException e) {
127 129 return null;
128 130 }
129 131 }
... ... @@ -131,8 +133,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
131 133 /**
132 134 * 获取服务器启动时间
133 135 */
134   - public static Date getServerStartDate()
135   - {
  136 + public static Date getServerStartDate() {
136 137 long time = ManagementFactory.getRuntimeMXBean().getStartTime();
137 138 return new Date(time);
138 139 }
... ... @@ -140,20 +141,18 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
140 141 /**
141 142 * 计算相差天数
142 143 */
143   - public static int differentDaysByMillisecond(Date date1, Date date2)
144   - {
  144 + public static int differentDaysByMillisecond(Date date1, Date date2) {
145 145 return Math.abs((int) ((date2.getTime() - date1.getTime()) / (1000 * 3600 * 24)));
146 146 }
147 147  
148 148 /**
149 149 * 计算时间差
150 150 *
151   - * @param endTime 最后时间
  151 + * @param endTime 最后时间
152 152 * @param startTime 开始时间
153 153 * @return 时间差(天/小时/分钟)
154 154 */
155   - public static String timeDistance(Date endDate, Date startTime)
156   - {
  155 + public static String timeDistance(Date endDate, Date startTime) {
157 156 long nd = 1000 * 24 * 60 * 60;
158 157 long nh = 1000 * 60 * 60;
159 158 long nm = 1000 * 60;
... ... @@ -174,8 +173,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
174 173 /**
175 174 * 增加 LocalDateTime ==> Date
176 175 */
177   - public static Date toDate(LocalDateTime temporalAccessor)
178   - {
  176 + public static Date toDate(LocalDateTime temporalAccessor) {
179 177 ZonedDateTime zdt = temporalAccessor.atZone(ZoneId.systemDefault());
180 178 return Date.from(zdt.toInstant());
181 179 }
... ... @@ -183,8 +181,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
183 181 /**
184 182 * 增加 LocalDate ==> Date
185 183 */
186   - public static Date toDate(LocalDate temporalAccessor)
187   - {
  184 + public static Date toDate(LocalDate temporalAccessor) {
188 185 LocalDateTime localDateTime = LocalDateTime.of(temporalAccessor, LocalTime.of(0, 0, 0));
189 186 ZonedDateTime zdt = localDateTime.atZone(ZoneId.systemDefault());
190 187 return Date.from(zdt.toInstant());
... ...
Bsth-system/src/main/java/com/ruoyi/system/domain/SysNotice.java
1 1 package com.ruoyi.system.domain;
2 2  
3   -import javax.validation.constraints.NotBlank;
4   -import javax.validation.constraints.Size;
5   -import org.apache.commons.lang3.builder.ToStringBuilder;
6   -import org.apache.commons.lang3.builder.ToStringStyle;
  3 +import com.alibaba.fastjson2.JSON;
7 4 import com.ruoyi.common.core.domain.BaseEntity;
8 5 import com.ruoyi.common.xss.Xss;
9 6  
  7 +import javax.validation.constraints.NotBlank;
  8 +import javax.validation.constraints.Size;
10 9 import java.util.Date;
11 10  
12 11 /**
... ... @@ -109,19 +108,20 @@ public class SysNotice extends BaseEntity
109 108  
110 109 @Override
111 110 public String toString() {
112   - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
113   - .append("noticeId", getNoticeId())
114   - .append("noticeTitle", getNoticeTitle())
115   - .append("noticeType", getNoticeType())
116   - .append("noticeContent", getNoticeContent())
117   - .append("status", getStatus())
118   - .append("createBy", getCreateBy())
119   - .append("createTime", getCreateTime())
120   - .append("updateBy", getUpdateBy())
121   - .append("updateTime", getUpdateTime())
122   - .append("remark", getRemark())
123   - .append("jobCode", getJobCode())
124   - .append("planTime", getPlanTime())
125   - .toString();
  111 +// return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
  112 +// .append("noticeId", getNoticeId())
  113 +// .append("noticeTitle", getNoticeTitle())
  114 +// .append("noticeType", getNoticeType())
  115 +// .append("noticeContent", getNoticeContent())
  116 +// .append("status", getStatus())
  117 +// .append("createBy", getCreateBy())
  118 +// .append("createTime", getCreateTime())
  119 +// .append("updateBy", getUpdateBy())
  120 +// .append("updateTime", getUpdateTime())
  121 +// .append("remark", getRemark())
  122 +// .append("jobCode", getJobCode())
  123 +// .append("planTime", getPlanTime())
  124 +// .toString();
  125 + return JSON.toJSONString(this);
126 126 }
127 127 }
... ...