Commit 7022fa148905ce44453a4b5ac50971549685d2dc
1 parent
9d418400
feat: 通过人事系统获取人员信息
Showing
34 changed files
with
1148 additions
and
186 deletions
ruoyi-admin/pom.xml
| ... | ... | @@ -70,6 +70,11 @@ |
| 70 | 70 | <groupId>com.ruoyi</groupId> |
| 71 | 71 | <artifactId>ruoyi-generator</artifactId> |
| 72 | 72 | </dependency> |
| 73 | + <dependency> | |
| 74 | + <groupId>org.apache.httpcomponents</groupId> | |
| 75 | + <artifactId>httpclient</artifactId> | |
| 76 | + <version>4.5.13</version> | |
| 77 | + </dependency> | |
| 73 | 78 | |
| 74 | 79 | </dependencies> |
| 75 | 80 | ... | ... |
ruoyi-admin/src/main/java/com/ruoyi/common/ConstDriverProperties.java
0 → 100644
ruoyi-admin/src/main/java/com/ruoyi/common/SignInEnum.java renamed to ruoyi-admin/src/main/java/com/ruoyi/common/ConstSignInConstSignInProperties.java
| 1 | 1 | package com.ruoyi.common; |
| 2 | 2 | |
| 3 | -public interface SignInEnum { | |
| 3 | +/** | |
| 4 | + * 签到枚举 | |
| 5 | + * @author 20412 | |
| 6 | + */ | |
| 7 | +public interface ConstSignInConstSignInProperties { | |
| 4 | 8 | /** |
| 5 | 9 | * 导出图片 |
| 6 | 10 | */ |
| ... | ... | @@ -33,5 +37,10 @@ public interface SignInEnum { |
| 33 | 37 | Integer ALCOHOL_FLAG_NO = 2; |
| 34 | 38 | String ALCOHOL_FLAG_NO_STRING = "未测试"; |
| 35 | 39 | |
| 40 | + /** | |
| 41 | + * 酒精测试异常指定次数 弹出更换驾驶员提示 | |
| 42 | + */ | |
| 43 | + Integer SIGN_IN_ERROR_COUNT = 2; | |
| 44 | + | |
| 36 | 45 | |
| 37 | 46 | } | ... | ... |
ruoyi-admin/src/main/java/com/ruoyi/common/ErrorTypeProperties.java
| ... | ... | @@ -6,7 +6,7 @@ package com.ruoyi.common; |
| 6 | 6 | public interface ErrorTypeProperties { |
| 7 | 7 | String SIGN_IN_ERROR = "签到异常"; |
| 8 | 8 | String EQUIPMENT_ERROR = "设备异常"; |
| 9 | - String ALCOHOL_SIGN_IN_ERROR = "酒精测试超标"; | |
| 10 | - String WORK_DAY_ERROR = "当天没有排班"; | |
| 11 | - String SIGN_IN_TIMEOUT = "签到超时"; | |
| 9 | + String ALCOHOL_SIGN_IN_ERROR = "酒精测试超标,"; | |
| 10 | + String WORK_DAY_ERROR = "当天没有排班,"; | |
| 11 | + String SIGN_IN_TIMEOUT = "签到超时,"; | |
| 12 | 12 | } | ... | ... |
ruoyi-admin/src/main/java/com/ruoyi/common/global/GlobalDriverInfoCache.java
0 → 100644
| 1 | +package com.ruoyi.common.global; | |
| 2 | + | |
| 3 | +import com.ruoyi.in.domain.SignIn; | |
| 4 | +import org.springframework.stereotype.Component; | |
| 5 | + | |
| 6 | +import java.security.Principal; | |
| 7 | +import java.util.*; | |
| 8 | +import java.util.concurrent.ConcurrentHashMap; | |
| 9 | + | |
| 10 | +/** | |
| 11 | + * @author 20412 | |
| 12 | + */ | |
| 13 | +@Component | |
| 14 | +public class GlobalDriverInfoCache { | |
| 15 | + private final ConcurrentHashMap<String, List<SignIn>> userCurrentMap = new ConcurrentHashMap(); | |
| 16 | + | |
| 17 | + /** | |
| 18 | + * 驾驶员签到 | |
| 19 | + * @param signIn | |
| 20 | + */ | |
| 21 | + public void putDriver(SignIn signIn) { | |
| 22 | + if (Objects.isNull(userCurrentMap.get(signIn.getJobCode()))) { | |
| 23 | + userCurrentMap.put(signIn.getJobCode(), new ArrayList<>(Arrays.asList(signIn))); | |
| 24 | + } else { | |
| 25 | + userCurrentMap.get(signIn.getJobCode()).add(signIn); | |
| 26 | + } | |
| 27 | + } | |
| 28 | + | |
| 29 | + | |
| 30 | +} | ... | ... |
ruoyi-admin/src/main/java/com/ruoyi/common/redispre/GlobalRedisPreName.java
| ... | ... | @@ -6,4 +6,18 @@ package com.ruoyi.common.redispre; |
| 6 | 6 | public interface GlobalRedisPreName { |
| 7 | 7 | String DRIVER_SCHEDULING_PRE = "driver:scheduling:"; |
| 8 | 8 | String REDIS_SIGN_IN = "sign:in:"; |
| 9 | + /** | |
| 10 | + * 请求人事系统token | |
| 11 | + */ | |
| 12 | + String REDIS_PERSONNEL_TOKEN = "personnel:token"; | |
| 13 | + | |
| 14 | + /** | |
| 15 | + * 驾驶员签到 hash key | |
| 16 | + */ | |
| 17 | + String REDIS_PERSONNEL_DRIVER = "personnel:driver"; | |
| 18 | + | |
| 19 | + /** | |
| 20 | + * 其他人员 | |
| 21 | + */ | |
| 22 | + | |
| 9 | 23 | } | ... | ... |
ruoyi-admin/src/main/java/com/ruoyi/controller/ApplicationUpdateController.java
ruoyi-admin/src/main/java/com/ruoyi/controller/ReportController.java
| ... | ... | @@ -17,7 +17,7 @@ import javax.servlet.http.HttpServletResponse; |
| 17 | 17 | import java.util.List; |
| 18 | 18 | import java.util.stream.Collectors; |
| 19 | 19 | |
| 20 | -import static com.ruoyi.common.SignInEnum.EXPORT; | |
| 20 | +import static com.ruoyi.common.ConstSignInConstSignInProperties.EXPORT; | |
| 21 | 21 | |
| 22 | 22 | /** |
| 23 | 23 | * @author 20412 | ... | ... |
ruoyi-admin/src/main/java/com/ruoyi/driver/domain/Driver.java
| ... | ... | @@ -3,10 +3,7 @@ package com.ruoyi.driver.domain; |
| 3 | 3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
| 4 | 4 | import io.swagger.annotations.ApiModel; |
| 5 | 5 | import io.swagger.annotations.ApiModelProperty; |
| 6 | -import io.swagger.annotations.ApiOperation; | |
| 7 | 6 | import lombok.Data; |
| 8 | -import org.apache.commons.lang3.builder.ToStringBuilder; | |
| 9 | -import org.apache.commons.lang3.builder.ToStringStyle; | |
| 10 | 7 | import com.ruoyi.common.annotation.Excel; |
| 11 | 8 | import com.ruoyi.common.core.domain.BaseEntity; |
| 12 | 9 | import org.springframework.format.annotation.DateTimeFormat; |
| ... | ... | @@ -143,7 +140,7 @@ public class Driver extends BaseEntity { |
| 143 | 140 | private String image; |
| 144 | 141 | @DateTimeFormat(pattern = "yyyy-MM-dd hh:mm:ss") |
| 145 | 142 | @ApiModelProperty("更新时间") |
| 146 | - private Date update_time; | |
| 143 | + private Date updateTime; | |
| 147 | 144 | |
| 148 | 145 | @ApiModelProperty("注册设备列表") |
| 149 | 146 | private String signInEquipment; | ... | ... |
ruoyi-admin/src/main/java/com/ruoyi/driver/service/impl/DriverServiceImpl.java
| ... | ... | @@ -61,6 +61,8 @@ public class DriverServiceImpl implements IDriverService { |
| 61 | 61 | @Autowired |
| 62 | 62 | private RedisCache redisCache; |
| 63 | 63 | |
| 64 | + @Value("${api.headImage}") | |
| 65 | + private String headImagePre; | |
| 64 | 66 | /** |
| 65 | 67 | * 查询驾驶员信息 |
| 66 | 68 | * |
| ... | ... | @@ -149,7 +151,7 @@ public class DriverServiceImpl implements IDriverService { |
| 149 | 151 | } catch (Exception e) { |
| 150 | 152 | throw new RuntimeException(e); |
| 151 | 153 | } |
| 152 | - Map<String, List<ResponseScheduling>> scheduling = driverJob.saveSchedulingToRedis(getSchedulingInfoUrl, Collections.emptyList(), schedulingDate); | |
| 154 | + Map<String, List<ResponseScheduling>> scheduling = driverJob.saveSchedulingToRedis(getSchedulingInfoUrl, schedulingDate); | |
| 153 | 155 | // 数据库中读取所有接收到的排班信息 |
| 154 | 156 | // List<ResponseScheduling> responseSchedulings = driverMapper.getDriverSchedulingList(schedulingDate, jobCode); |
| 155 | 157 | return AjaxResult.success(scheduling.get(jobCode)); |
| ... | ... | @@ -182,10 +184,11 @@ public class DriverServiceImpl implements IDriverService { |
| 182 | 184 | |
| 183 | 185 | @Override |
| 184 | 186 | public AjaxResult uploadImage(MultipartFile file) throws InvalidExtensionException, IOException { |
| 187 | + // 上传并返回新文件名称 | |
| 185 | 188 | |
| 186 | 189 | // 上传文件路径 |
| 187 | - String baseUrl = RuoYiConfig.getUploadPath() + "/head/image"; | |
| 188 | - // 上传并返回新文件名称 | |
| 190 | + String baseUrl = RuoYiConfig.getUploadPath() + headImagePre; | |
| 191 | + // 校验文件格式 | |
| 189 | 192 | FileUploadUtils.assertAllowed(file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION); |
| 190 | 193 | // 后期可以通过请求头拿到对应的工号 |
| 191 | 194 | String fileName = FilenameUtils.getBaseName(file.getOriginalFilename()) + "." + FileUploadUtils.getExtension(file); |
| ... | ... | @@ -233,10 +236,9 @@ public class DriverServiceImpl implements IDriverService { |
| 233 | 236 | } |
| 234 | 237 | |
| 235 | 238 | |
| 236 | - | |
| 237 | 239 | @Override |
| 238 | 240 | public AjaxResult faceRegistrationFeedback(String deviceId, List<String> jobCodes) { |
| 239 | - threadJobService.asyncUpdateDriver(deviceId,jobCodes); | |
| 241 | + threadJobService.asyncInsertSignInContactEquipment(deviceId, jobCodes); | |
| 240 | 242 | return AjaxResult.success("注册成功"); |
| 241 | 243 | } |
| 242 | 244 | ... | ... |
ruoyi-admin/src/main/java/com/ruoyi/in/service/impl/SignInServiceImpl.java
| ... | ... | @@ -15,12 +15,13 @@ import com.ruoyi.common.constant.Constants; |
| 15 | 15 | import com.ruoyi.common.core.domain.AjaxResult; |
| 16 | 16 | import com.ruoyi.common.core.redis.RedisCache; |
| 17 | 17 | import com.ruoyi.common.utils.DateUtils; |
| 18 | -import com.ruoyi.common.SignInEnum; | |
| 18 | +import com.ruoyi.common.ConstSignInConstSignInProperties; | |
| 19 | 19 | import com.ruoyi.common.utils.StringUtils; |
| 20 | 20 | import com.ruoyi.common.utils.ip.IpUtils; |
| 21 | 21 | import com.ruoyi.common.utils.uuid.Seq; |
| 22 | 22 | import com.ruoyi.common.utils.uuid.UUID; |
| 23 | 23 | import com.ruoyi.driver.domain.Driver; |
| 24 | +import com.ruoyi.driver.mapper.DriverMapper; | |
| 24 | 25 | import com.ruoyi.equipment.domain.Equipment; |
| 25 | 26 | import com.ruoyi.equipment.mapper.EquipmentMapper; |
| 26 | 27 | import com.ruoyi.pojo.response.ResponseScheduling; |
| ... | ... | @@ -36,8 +37,10 @@ import com.ruoyi.in.service.ISignInService; |
| 36 | 37 | |
| 37 | 38 | import javax.annotation.Resource; |
| 38 | 39 | |
| 40 | +import static com.ruoyi.common.ConstDriverProperties.PERSONNEL_TYPE_DRIVER; | |
| 39 | 41 | import static com.ruoyi.common.ErrorTypeProperties.*; |
| 40 | -import static com.ruoyi.common.SignInEnum.*; | |
| 42 | +import static com.ruoyi.common.ConstSignInConstSignInProperties.*; | |
| 43 | +import static com.ruoyi.common.redispre.GlobalRedisPreName.DRIVER_SCHEDULING_PRE; | |
| 41 | 44 | import static com.ruoyi.common.redispre.GlobalRedisPreName.REDIS_SIGN_IN; |
| 42 | 45 | |
| 43 | 46 | /** |
| ... | ... | @@ -52,6 +55,9 @@ public class SignInServiceImpl implements ISignInService { |
| 52 | 55 | private SignInMapper signInMapper; |
| 53 | 56 | |
| 54 | 57 | @Autowired |
| 58 | + private DriverMapper driverMapper; | |
| 59 | + | |
| 60 | + @Autowired | |
| 55 | 61 | private EquipmentMapper equipmentMapper; |
| 56 | 62 | |
| 57 | 63 | @Autowired |
| ... | ... | @@ -93,7 +99,7 @@ public class SignInServiceImpl implements ISignInService { |
| 93 | 99 | signIn.setIp(IpUtils.getIpAddr()); |
| 94 | 100 | signIn.setCreateTime(DateUtils.getNowDate()); |
| 95 | 101 | if (signIn.getType() == null) { |
| 96 | - signIn.setType(SignInEnum.SIGN_IN); | |
| 102 | + signIn.setType(ConstSignInConstSignInProperties.SIGN_IN); | |
| 97 | 103 | } |
| 98 | 104 | if (ALCOHOL_FLAG_YES.equals(signIn.getAlcoholFlag())) { |
| 99 | 105 | signIn.setStatus(signIn.getAlcoholIntake().compareTo(new BigDecimal(20)) < 0 ? SIGN_IN_SUCCESS : SIGN_IN_FAIL); |
| ... | ... | @@ -138,99 +144,129 @@ public class SignInServiceImpl implements ISignInService { |
| 138 | 144 | |
| 139 | 145 | @Override |
| 140 | 146 | public AjaxResult addSignIn(SignIn signIn) throws IOException { |
| 147 | + Driver driver = driverMapper.getDriverInfoByJobCode(signIn.getJobCode()); | |
| 148 | + // 查询地址 | |
| 149 | + Equipment equipment = equipmentMapper.selectEquipmentByDeviceId(signIn.getDeviceId()); | |
| 150 | + SignInResponseVo vo = getSignInResponseVo(signIn, equipment); | |
| 141 | 151 | // 签到检查 |
| 142 | - checkSignIn(signIn); | |
| 152 | + if (checkSignIn(signIn, driver)) { | |
| 153 | + signIn.setStatus(SIGN_IN_SUCCESS); | |
| 154 | + } else { | |
| 155 | + signIn.setStatus(SIGN_IN_FAIL); | |
| 156 | + } | |
| 143 | 157 | // base64转图片 |
| 144 | 158 | signIn.setCreateTime(new Date()); |
| 145 | 159 | signIn.setIp(IpUtils.getIpAddr()); |
| 146 | 160 | uploadImage(signIn); |
| 147 | 161 | signInMapper.insertSignIn(signIn); |
| 162 | + // TODO redis 存储每个人的签到 用于后续考勤 | |
| 163 | + | |
| 148 | 164 | // TODO 驾驶人员二次签到酒精测试异常 |
| 149 | - if (true) { | |
| 150 | - Equipment equipment = equipmentMapper.selectEquipmentByDeviceId(signIn.getDeviceId()); | |
| 151 | - SignInResponseVo vo = new SignInResponseVo(); | |
| 152 | - vo.setAddress(equipment.getAddress()); | |
| 153 | - vo.setDeviceId(signIn.getDeviceId()); | |
| 154 | - Integer count = redisCache.getCacheMapValue(ConstDateUtil.formatDate("yyyyMMdd") + REDIS_SIGN_IN, signIn.getJobCode()); | |
| 155 | - if (Objects.isNull(count)) { | |
| 156 | - redisCache.setCacheMapValue(ConstDateUtil.formatDate("yyyyMMdd") + REDIS_SIGN_IN, signIn.getJobCode(), 0); | |
| 157 | - } else { | |
| 158 | - count = redisCache.increment(ConstDateUtil.formatDate("yyyyMMdd") + REDIS_SIGN_IN, signIn.getJobCode(), 1); | |
| 159 | - } | |
| 160 | - if (count.compareTo(2) >= 0) { | |
| 161 | - // TODO | |
| 162 | - return SIGN_IN_SUCCESS.equals(signIn.getStatus()) ? AjaxResult.success(SIGN_IN_SUCCESS_STRING,vo) : AjaxResult.error(SIGN_IN_ERROR + signIn.getRemark() + ",酒精测试不通过两次请更换车辆驾驶员",vo); | |
| 165 | + if (PERSONNEL_TYPE_DRIVER.equals(driver.getPosts())) { | |
| 166 | + AjaxResult result = getAjaxResultByDriverSignInfo(signIn, vo); | |
| 167 | + if (!Objects.isNull(result)) { | |
| 168 | + return result; | |
| 163 | 169 | } |
| 164 | 170 | } |
| 165 | 171 | |
| 166 | - // 查询地址 | |
| 167 | - Equipment equipment = equipmentMapper.selectEquipmentByDeviceId(signIn.getDeviceId()); | |
| 168 | - System.out.println("设备信息:" + equipment); | |
| 172 | + return SIGN_IN_SUCCESS.equals(signIn.getStatus()) ? AjaxResult.success(SIGN_IN_SUCCESS_STRING, vo) : AjaxResult.error(SIGN_IN_ERROR + signIn.getRemark(), vo); | |
| 173 | + } | |
| 174 | + | |
| 175 | + private SignInResponseVo getSignInResponseVo(SignIn signIn, Equipment equipment) { | |
| 169 | 176 | SignInResponseVo vo = new SignInResponseVo(); |
| 177 | + if (Objects.isNull(equipment)) { | |
| 178 | + equipment = new Equipment(); | |
| 179 | + } | |
| 170 | 180 | vo.setAddress(equipment.getAddress()); |
| 171 | 181 | vo.setDeviceId(signIn.getDeviceId()); |
| 172 | - System.out.println("返回数据:" + vo.toString()); | |
| 173 | - return SIGN_IN_SUCCESS.equals(signIn.getStatus()) ? AjaxResult.success(SIGN_IN_SUCCESS_STRING,vo) : AjaxResult.error(SIGN_IN_ERROR + signIn.getRemark(),vo); | |
| 182 | + return vo; | |
| 183 | + } | |
| 184 | + | |
| 185 | + private AjaxResult getAjaxResultByDriverSignInfo(SignIn signIn, SignInResponseVo vo) { | |
| 186 | + // 驾驶员酒精测试连续超标两次则提示换人 | |
| 187 | + Integer count = redisCache.getCacheMapValue(ConstDateUtil.formatDate("yyyyMMdd") + REDIS_SIGN_IN, signIn.getJobCode()); | |
| 188 | + if (Objects.isNull(count) || count.equals(0)) { | |
| 189 | + count = 1; | |
| 190 | + redisCache.setCacheMapValue(ConstDateUtil.formatDate("yyyyMMdd") + REDIS_SIGN_IN, signIn.getJobCode(), count); | |
| 191 | + } else { | |
| 192 | + count = redisCache.setIncrementMapValue(ConstDateUtil.formatDate("yyyyMMdd") + REDIS_SIGN_IN, signIn.getJobCode(), 1); | |
| 193 | + } | |
| 194 | + if (SIGN_IN_ERROR_COUNT.compareTo(count) <= 0) { | |
| 195 | + // TODO | |
| 196 | + return AjaxResult.error(SIGN_IN_ERROR + signIn.getRemark() + ",酒精测试不通过" + count + "次请更换车辆驾驶员", vo); | |
| 197 | + } | |
| 198 | + return null; | |
| 174 | 199 | } |
| 175 | 200 | |
| 176 | - private void checkSignIn(SignIn signIn) { | |
| 177 | - // TODO 更具工号获取人员信息 | |
| 178 | - Driver driver = getDriverInfoByJobCode(signIn.getJobCode()); | |
| 201 | + private boolean checkSignIn(SignIn signIn, Driver driver) { | |
| 202 | + boolean result = true; | |
| 179 | 203 | if (Objects.isNull(driver)) { |
| 180 | - signIn.setStatus(SIGN_IN_SUCCESS); | |
| 181 | - return; | |
| 204 | + return true; | |
| 182 | 205 | } |
| 183 | - // TODO 排班校验 非司售未作 | |
| 184 | - checkWorkDay(signIn, driver.getPersonnelType()); | |
| 206 | + // TODO 排班校验 和签到超时校验 非司售未作 | |
| 207 | + result = checkWorkDay(signIn, driver.getPosts()); | |
| 185 | 208 | |
| 186 | - // 酒精测试校验 TODO 判断人员类型 | |
| 187 | - if (ALCOHOL_FLAG_YES.equals(signIn.getAlcoholFlag())) { | |
| 188 | - signIn.setStatus(signIn.getAlcoholIntake().compareTo(new BigDecimal(20)) < 0 ? SIGN_IN_SUCCESS : SIGN_IN_FAIL); | |
| 189 | - signIn.setRemark(signIn.getStatus().equals(SIGN_IN_FAIL) ? ALCOHOL_SIGN_IN_ERROR : ""); | |
| 209 | + // 酒精测试校验 确定 且员工工种是驾驶员 | |
| 210 | + if (ALCOHOL_FLAG_YES.equals(signIn.getAlcoholFlag()) && PERSONNEL_TYPE_DRIVER.equals(driver.getPosts())) { | |
| 211 | + if (new BigDecimal(20).compareTo(signIn.getAlcoholIntake()) > 0) { | |
| 212 | + result = true; | |
| 213 | + } else { | |
| 214 | + signIn.setRemark(ALCOHOL_SIGN_IN_ERROR); | |
| 215 | + result = false; | |
| 216 | + } | |
| 190 | 217 | } |
| 218 | + return result; | |
| 191 | 219 | } |
| 192 | 220 | |
| 193 | - private Driver getDriverInfoByJobCode(String jobCode) { | |
| 194 | - return null; | |
| 195 | - } | |
| 196 | 221 | |
| 197 | - private void checkWorkDay(SignIn signIn, String personnelType) { | |
| 222 | + /** | |
| 223 | + * 排班和超时检查 | |
| 224 | + * | |
| 225 | + * @param signIn | |
| 226 | + * @param personnelType | |
| 227 | + * @return | |
| 228 | + */ | |
| 229 | + private boolean checkWorkDay(SignIn signIn, String personnelType) { | |
| 230 | + boolean result = true; | |
| 198 | 231 | List<ResponseScheduling> jobs = null; |
| 199 | 232 | switch (personnelType) { |
| 200 | 233 | case "0": |
| 201 | 234 | // 查询工号对应的排班 司售人员 |
| 202 | - jobs = redisCache.getCacheMapValue(ConstDateUtil.formatDate("yyyyMMdd"), signIn.getJobCode()); | |
| 235 | + jobs = redisCache.getCacheMapValue(DRIVER_SCHEDULING_PRE + ConstDateUtil.formatDate("yyyyMMdd"), signIn.getJobCode()); | |
| 203 | 236 | if (Objects.isNull(jobs) || jobs.size() == 0) { |
| 204 | - signIn.setStatus(SIGN_IN_FAIL); | |
| 205 | - signIn.setRemark(WORK_DAY_ERROR); | |
| 237 | + signIn.setRemark(signIn.getRemark() + WORK_DAY_ERROR); | |
| 238 | + result = false; | |
| 206 | 239 | } |
| 207 | 240 | break; |
| 208 | 241 | case "1": |
| 209 | 242 | // 查询工号对应的排班 非司售人员 |
| 210 | 243 | // 查询数据库 |
| 244 | + result = true; | |
| 211 | 245 | break; |
| 212 | 246 | } |
| 213 | 247 | |
| 214 | 248 | // 超时校验司售人员 |
| 215 | - checkTimeOut(signIn, jobs); | |
| 216 | - // TODO 非司售人员 | |
| 217 | - | |
| 249 | + if (result) { | |
| 250 | + // TODO 非司售人员 | |
| 251 | + result = checkTimeOut(signIn, jobs); | |
| 252 | + } | |
| 253 | + return result; | |
| 218 | 254 | } |
| 219 | 255 | |
| 220 | - private void checkTimeOut(SignIn signIn, List<ResponseScheduling> driver) { | |
| 256 | + private boolean checkTimeOut(SignIn signIn, List<ResponseScheduling> driver) { | |
| 221 | 257 | // 那发车时间和到站时间作为开始上班的时间 |
| 222 | 258 | LocalDateTime startTime = ConstDateUtil.getLocalDateTimeByLongTime(driver.get(0).getFcsjT()); |
| 223 | 259 | LocalDateTime endTime = ConstDateUtil.getLocalDateTimeByLongTime(driver.get(0).getZdsjT()); |
| 224 | 260 | LocalDateTime signTime = ConstDateUtil.getLocalDateTimeByLongTime(signIn.getCreateTime().getTime()); |
| 225 | 261 | long morningBetween = ChronoUnit.MINUTES.between(startTime, signTime); |
| 226 | 262 | long afternoonBetween = ChronoUnit.MINUTES.between(endTime, signTime); |
| 263 | + // 签到范围一小时内 | |
| 227 | 264 | if (Math.abs(morningBetween) <= 60 || Math.abs(afternoonBetween) <= 60) { |
| 228 | - signIn.setStatus(SIGN_IN_SUCCESS); | |
| 265 | + return true; | |
| 229 | 266 | } else { |
| 230 | - signIn.setStatus(SIGN_IN_FAIL); | |
| 231 | - signIn.setRemark(SIGN_IN_TIMEOUT); | |
| 267 | + signIn.setRemark(signIn.getRemark() + SIGN_IN_TIMEOUT); | |
| 268 | + return false; | |
| 232 | 269 | } |
| 233 | - | |
| 234 | 270 | } |
| 235 | 271 | |
| 236 | 272 | private void uploadImage(SignIn signIn) throws IOException { |
| ... | ... | @@ -249,7 +285,7 @@ public class SignInServiceImpl implements ISignInService { |
| 249 | 285 | String pathFileName = getPathFileName(filePath, fileName); |
| 250 | 286 | signIn.setImage(pathFileName); |
| 251 | 287 | // 异步上传文件 |
| 252 | - threadJobConfig.asyncStartUpload(absPath, base64); | |
| 288 | + threadJobConfig.asyncStartUploadBase64Image(absPath, base64); | |
| 253 | 289 | } |
| 254 | 290 | |
| 255 | 291 | /** | ... | ... |
ruoyi-admin/src/main/java/com/ruoyi/job/DriverJob.java
| 1 | 1 | package com.ruoyi.job; |
| 2 | 2 | |
| 3 | +import com.alibaba.fastjson2.JSON; | |
| 4 | +import com.alibaba.fastjson2.JSONArray; | |
| 3 | 5 | import com.ruoyi.common.core.redis.RedisCache; |
| 4 | 6 | import com.ruoyi.driver.domain.Driver; |
| 5 | 7 | import com.ruoyi.driver.service.IDriverService; |
| 8 | +import com.ruoyi.pojo.request.PersonnelRequestVo; | |
| 9 | +import com.ruoyi.pojo.request.TokenRequestVo; | |
| 6 | 10 | import com.ruoyi.pojo.response.ResponseScheduling; |
| 7 | -import com.ruoyi.pojo.response.TokenResponseVo; | |
| 11 | +import com.ruoyi.pojo.response.personnel.*; | |
| 12 | +import com.ruoyi.service.ThreadJobService; | |
| 8 | 13 | import com.ruoyi.utils.ConstDateUtil; |
| 14 | +import com.ruoyi.utils.HttpUtils; | |
| 9 | 15 | import com.ruoyi.utils.ListUtils; |
| 16 | +import lombok.extern.slf4j.Slf4j; | |
| 10 | 17 | import org.springframework.beans.factory.InitializingBean; |
| 11 | 18 | import org.springframework.beans.factory.annotation.Autowired; |
| 12 | 19 | import org.springframework.beans.factory.annotation.Value; |
| 13 | 20 | import org.springframework.core.ParameterizedTypeReference; |
| 14 | 21 | import org.springframework.http.*; |
| 15 | 22 | import org.springframework.stereotype.Component; |
| 16 | -import org.springframework.util.LinkedMultiValueMap; | |
| 17 | -import org.springframework.util.MultiValueMap; | |
| 18 | 23 | import org.springframework.web.client.RestTemplate; |
| 19 | 24 | |
| 20 | 25 | import javax.annotation.Resource; |
| 26 | +import java.io.UnsupportedEncodingException; | |
| 27 | +import java.net.URLEncoder; | |
| 28 | +import java.nio.charset.StandardCharsets; | |
| 21 | 29 | import java.security.MessageDigest; |
| 22 | 30 | import java.util.*; |
| 23 | 31 | import java.util.concurrent.TimeUnit; |
| 24 | 32 | import java.util.stream.Collectors; |
| 25 | 33 | |
| 26 | 34 | import static com.ruoyi.common.redispre.GlobalRedisPreName.DRIVER_SCHEDULING_PRE; |
| 35 | +import static com.ruoyi.common.redispre.GlobalRedisPreName.REDIS_PERSONNEL_TOKEN; | |
| 27 | 36 | |
| 28 | 37 | /** |
| 29 | 38 | * 该定时任务用户获取驾驶员信息 |
| ... | ... | @@ -31,6 +40,7 @@ import static com.ruoyi.common.redispre.GlobalRedisPreName.DRIVER_SCHEDULING_PRE |
| 31 | 40 | * @author 20412 |
| 32 | 41 | */ |
| 33 | 42 | @Component("driverJob") |
| 43 | +@Slf4j | |
| 34 | 44 | public class DriverJob implements InitializingBean { |
| 35 | 45 | |
| 36 | 46 | @Autowired |
| ... | ... | @@ -39,6 +49,9 @@ public class DriverJob implements InitializingBean { |
| 39 | 49 | @Resource |
| 40 | 50 | private RestTemplate restTemplate; |
| 41 | 51 | |
| 52 | + @Resource | |
| 53 | + private ThreadJobService threadJobService; | |
| 54 | + | |
| 42 | 55 | @Autowired |
| 43 | 56 | private IDriverService driverService; |
| 44 | 57 | |
| ... | ... | @@ -46,14 +59,14 @@ public class DriverJob implements InitializingBean { |
| 46 | 59 | private String getDriverInfoUrl; |
| 47 | 60 | |
| 48 | 61 | |
| 49 | -// @Value("${api.personnel.token.tokenUrl}") | |
| 50 | -// private String tokenUrl; | |
| 62 | + @Value("${api.personnel.token.tokenUrl}") | |
| 63 | + private String tokenUrl; | |
| 51 | 64 | |
| 52 | -// @Value("${api.personnel.token.appKey}") | |
| 53 | -// private String appKey; | |
| 65 | + @Value("${api.personnel.token.appKey}") | |
| 66 | + private String appKey; | |
| 54 | 67 | |
| 55 | -// @Value("${api.personnel.token.appSecret}") | |
| 56 | -// private String appSecret; | |
| 68 | + @Value("${api.personnel.token.appSecret}") | |
| 69 | + private String appSecret; | |
| 57 | 70 | |
| 58 | 71 | @Value("${api.url.getSchedulingInfo}") |
| 59 | 72 | private String getSchedulingInfoUrl; |
| ... | ... | @@ -64,6 +77,7 @@ public class DriverJob implements InitializingBean { |
| 64 | 77 | @Value("${api.config.nonce}") |
| 65 | 78 | private String nonce; |
| 66 | 79 | |
| 80 | + private static ThreadJobService THREAD_JOB_SERVICE; | |
| 67 | 81 | private static String APP_KEY; |
| 68 | 82 | private static String TOKEN_URL; |
| 69 | 83 | private static String APP_SECRET; |
| ... | ... | @@ -79,45 +93,95 @@ public class DriverJob implements InitializingBean { |
| 79 | 93 | |
| 80 | 94 | /** |
| 81 | 95 | * 通过该定时任务获取驾驶员信息 并保存到数据库 |
| 82 | - * 排班信息映射 20分钟更新一次 | |
| 96 | + * 排班信息映射 不低于2小时更新一次 | |
| 83 | 97 | */ |
| 84 | 98 | public void getDriverInfo(String params) throws Exception { |
| 85 | 99 | try { |
| 86 | - String getDriverInfoUrl = String.format(GET_DRIVER_INFO_URL, params); | |
| 87 | - long timestamp = System.currentTimeMillis(); | |
| 100 | +// String getDriverInfoUrl = String.format(GET_DRIVER_INFO_URL, params); | |
| 101 | + //获取token | |
| 102 | + TokenResponseVo tokenVo = getToken(TOKEN_URL); | |
| 88 | 103 | // 获取驾驶员信息 |
| 89 | - List<Driver> drivers = getDrivers(APP_SECRET, String.valueOf(timestamp)); | |
| 90 | - // 格式化请求 | |
| 91 | - String getSchedulingInfoUrl = String.format(GET_SCHEDULING_INFO_URL, "99", ConstDateUtil.formatDate("yyyyMMdd"), timestamp, NONCE, PASSWORD, getSHA1(getStringStringMap(String.valueOf(timestamp)))); | |
| 92 | - // 获取排班信息并存入redis | |
| 93 | - saveSchedulingToRedis(getSchedulingInfoUrl, drivers,ConstDateUtil.formatDate("yyyyMMdd")); | |
| 94 | - // 分片插入 | |
| 95 | - List<List<Driver>> splitList = ListUtils.splitList(drivers, 1000); | |
| 96 | - System.out.println("开始更新数据-----"); | |
| 97 | - for (List<Driver> driverList : splitList) { | |
| 98 | - DRIVER_SERVICE.insertDrivers(driverList); | |
| 99 | - } | |
| 100 | - System.out.println("数据更新完毕-----"); | |
| 104 | + List<Driver> drivers = getDrivers(tokenVo.getAccessToken()); | |
| 105 | + // 插入信息 | |
| 106 | + saveDrivers(drivers, tokenVo.getAccessToken()); | |
| 107 | + | |
| 101 | 108 | } catch (Exception e) { |
| 102 | - System.out.println("执行失败:" + e.getMessage()); | |
| 109 | + log.info("执行失败:" + e.getMessage()); | |
| 103 | 110 | } |
| 104 | - System.out.println("执行结束"); | |
| 111 | + log.info("执行结束"); | |
| 105 | 112 | } |
| 106 | 113 | |
| 107 | - /** | |
| 108 | - * 获取员工数据 | |
| 109 | - */ | |
| 114 | + private void saveDrivers(List<Driver> drivers, String accessToken) { | |
| 115 | + // 获取图片 | |
| 116 | + List<List<Driver>> list = ListUtils.splitList(drivers, 800); | |
| 117 | + for (List<Driver> driverList : list) { | |
| 118 | + // 多线程插入数据 | |
| 119 | + THREAD_JOB_SERVICE.asyncUploadDriverWithUpdateImageUrl(driverList, accessToken); | |
| 120 | + log.info("开始插入"); | |
| 121 | + } | |
| 122 | +// String downloadImage = getDownloadImage(url, accessToken, ""); | |
| 110 | 123 | |
| 124 | + } | |
| 125 | + | |
| 126 | +// public static void main(String[] args) { | |
| 127 | +// String str = "[{\"previewUrl\":\"/ossFileHandle?appType=APP_HV8J7X8PFRXLJJW8JTZK&fileName=APP_HV8J7X8PFRXLJJW8JTZK_bWFuYWdlcjgxNF9QRTg2Nk1EMThYTUNaNkxVN002QTQ3N0hQV0E2MlNYMTMwQ0tMQTQ$.png&instId=&type=open&process=image/resize,m_fill,w_200,h_200,limit_0/quality,q_80\",\"size\":621992,\"name\":\"0332d25e3b9e80bca3d90daf0d5857d.png\",\"downloadUrl\":\"/ossFileHandle?appType=APP_HV8J7X8PFRXLJJW8JTZK&fileName=APP_HV8J7X8PFRXLJJW8JTZK_bWFuYWdlcjgxNF9QRTg2Nk1EMThYTUNaNkxVN002QTQ3N0hQV0E2MlNYMTMwQ0tMQTQ$.png&instId=&type=download\",\"fileUuid\":\"APP_HV8J7X8PFRXLJJW8JTZK_bWFuYWdlcjgxNF9QRTg2Nk1EMThYTUNaNkxVN002QTQ3N0hQV0E2MlNYMTMwQ0tMQTQ$.png\",\"url\":\"/ossFileHandle?appType=APP_HV8J7X8PFRXLJJW8JTZK&fileName=APP_HV8J7X8PFRXLJJW8JTZK_bWFuYWdlcjgxNF9QRTg2Nk1EMThYTUNaNkxVN002QTQ3N0hQV0E2MlNYMTMwQ0tMQTQ$.png&instId=&type=download\"}]"; | |
| 128 | +//// List<List> lists = JSONArray.parseArray(str, List.class); | |
| 129 | +// List<ImageField_lk9mk228> lists = JSONArray.parseArray(str, ImageField_lk9mk228.class); | |
| 130 | +// System.out.println(lists); | |
| 131 | +// } | |
| 132 | + | |
| 133 | + public static String getDownloadImageUrl(String accessToken, String preViewUrl) { | |
| 134 | + accessToken = REDIS_CACHE.getCacheObject(REDIS_PERSONNEL_TOKEN); | |
| 135 | + String url = "https://api.dingtalk.com/v1.0/yida/apps/temporaryUrls/APP_HV8J7X8PFRXLJJW8JTZK"; | |
| 136 | + String fileUrl = "https://scroix.aliwork.com"; | |
| 137 | + try { | |
| 138 | + fileUrl = URLEncoder.encode(fileUrl + preViewUrl, String.valueOf(StandardCharsets.UTF_8)); | |
| 139 | + } catch (UnsupportedEncodingException e) { | |
| 140 | + throw new RuntimeException(e); | |
| 141 | + } | |
| 142 | + Map<String, Object> param = new HashMap<>(); | |
| 143 | + param.put("userId", "InterfaceManagement"); | |
| 144 | + param.put("timeout", 86400000L); | |
| 145 | + param.put("fileUrl", fileUrl); | |
| 146 | + param.put("systemToken", "16A66291CHE9K5DPE1IDO9E63FOE2VWA09QFLV"); | |
| 147 | + Map<String, String> header = new HashMap<>(); | |
| 148 | + header.put("x-acs-dingtalk-access-token", accessToken); | |
| 149 | + header.put("Content-Type", "application/json"); | |
| 150 | + String result = ""; | |
| 151 | + | |
| 152 | + try { | |
| 153 | + String s = HttpUtils.doGet(url, param, header); | |
| 154 | + ImageUrlResultResponseVo vo = JSON.parseObject(s, ImageUrlResultResponseVo.class); | |
| 155 | + result = vo.getResult(); | |
| 156 | + // 可能需要重新获取token | |
| 157 | + }catch (Exception e){ | |
| 158 | + String token = DriverJob.getToken(TOKEN_URL).getAccessToken(); | |
| 159 | + header.put("x-acs-dingtalk-access-token", token); | |
| 160 | + String s = HttpUtils.doGet(url, param, header); | |
| 161 | + ImageUrlResultResponseVo vo = JSON.parseObject(s, ImageUrlResultResponseVo.class); | |
| 162 | + result = vo.getResult(); | |
| 163 | + } | |
| 164 | + return result; | |
| 165 | + } | |
| 111 | 166 | |
| 112 | 167 | /** |
| 113 | - * 导入图片任务 | |
| 168 | + * 获取排班任务请求 | |
| 169 | + * 12小时执行一次 | |
| 114 | 170 | */ |
| 115 | - public void importImages(){ | |
| 116 | - // TODO 获取用户列表 通过用户列表的jobCode来匹配对应的用户图像信息并保存到服务器 | |
| 117 | - | |
| 171 | + public void getSchedulingInfo() { | |
| 172 | + // 获取排班请求 | |
| 173 | + long timestamp = System.currentTimeMillis(); | |
| 174 | + String getSchedulingInfoUrl = null; | |
| 175 | + try { | |
| 176 | + getSchedulingInfoUrl = String.format(GET_SCHEDULING_INFO_URL, "99", ConstDateUtil.formatDate("yyyyMMdd"), timestamp, NONCE, PASSWORD, getSHA1(getStringStringMap(String.valueOf(timestamp)))); | |
| 177 | + } catch (Exception e) { | |
| 178 | + throw new RuntimeException(e); | |
| 179 | + } | |
| 180 | + // 获取排班信息并存入redis | |
| 181 | + saveSchedulingToRedis(getSchedulingInfoUrl, ConstDateUtil.formatDate("yyyyMMdd")); | |
| 118 | 182 | } |
| 119 | 183 | |
| 120 | - public Map<String, List<ResponseScheduling>> saveSchedulingToRedis(String getSchedulingInfoUrl, List<Driver> drivers,String dateKey) { | |
| 184 | + public Map<String, List<ResponseScheduling>> saveSchedulingToRedis(String getSchedulingInfoUrl, String dateKey) { | |
| 121 | 185 | List<ResponseScheduling> originSchedulingList = RESTTEMPLATE.exchange( |
| 122 | 186 | getSchedulingInfoUrl, |
| 123 | 187 | HttpMethod.GET, |
| ... | ... | @@ -125,10 +189,10 @@ public class DriverJob implements InitializingBean { |
| 125 | 189 | new ParameterizedTypeReference<List<ResponseScheduling>>() { |
| 126 | 190 | }).getBody(); |
| 127 | 191 | |
| 128 | - Map<String, List<ResponseScheduling>> driverSchedulingMap = new HashMap<>(); | |
| 192 | + Map<String, List<ResponseScheduling>> driverSchedulingMap = new HashMap<>(200); | |
| 129 | 193 | // 按照员工工号来获取排班信息 |
| 130 | 194 | originSchedulingList = originSchedulingList.stream() |
| 131 | - .map(subItem->{ | |
| 195 | + .map(subItem -> { | |
| 132 | 196 | subItem.setJobCode(subItem.getJsy().split("/")[0]); |
| 133 | 197 | return subItem; |
| 134 | 198 | }).collect(Collectors.toList()); |
| ... | ... | @@ -152,30 +216,66 @@ public class DriverJob implements InitializingBean { |
| 152 | 216 | return driverSchedulingMap; |
| 153 | 217 | } |
| 154 | 218 | |
| 155 | - private List<Driver> getDrivers(String url, String timestamp) throws Exception { | |
| 156 | - Map<String, String> configMap = getStringStringMap(timestamp); | |
| 157 | - String sign = getSHA1(configMap); | |
| 158 | - //生成签名 | |
| 159 | - TokenResponseVo tokenVo = getToken(url); | |
| 160 | -// redisCache.setCacheObject(); | |
| 161 | -// getPersonInfo(tokenVo); | |
| 219 | + public static List<Driver> getDrivers(String accessToken) throws Exception { | |
| 220 | +// Map<String, String> configMap = getStringStringMap(timestamp); | |
| 221 | +// String sign = getSHA1(configMap); | |
| 222 | + Date date = new Date(); | |
| 223 | + PersonnelResultResponseVo vo = getPersonInfo(accessToken); | |
| 224 | + return vo.getData().stream().map(item -> { | |
| 225 | + Driver driver = new Driver(); | |
| 226 | + FormData formData = item.getFormData(); | |
| 227 | + driver.setUpdateTime(date); | |
| 228 | + driver.setJobCode(formData.getTextField_lk9mk222()); | |
| 229 | + driver.setPersonnelName(formData.getTextField_lk9mk224()); | |
| 230 | + driver.setPosts(formData.getTextField_lk9mk226()); | |
| 231 | +// driver.setImage(form); | |
| 232 | + // 解析JSON字符串 | |
| 233 | + List<ImageField_lk9mk228> lists = JSONArray.parseArray(formData.getImageField_lk9mk228(), ImageField_lk9mk228.class); | |
| 234 | + driver.setImage(lists.get(0).getPreviewUrl()); | |
| 235 | + return driver; | |
| 236 | + }).collect(Collectors.toList()); | |
| 162 | 237 | // return drivers; |
| 163 | - return null; | |
| 164 | 238 | } |
| 165 | 239 | |
| 166 | - private TokenResponseVo getToken(String url) { | |
| 167 | - MultiValueMap<String, String> params = new LinkedMultiValueMap<>(); | |
| 168 | - params.add("appSecret", APP_SECRET); | |
| 169 | - params.add("appKey", APP_KEY); | |
| 240 | + private static PersonnelResultResponseVo getPersonInfo(String accessToken) { | |
| 241 | + RestTemplate restTemplate = new RestTemplate(); | |
| 242 | + String url = "https://api.dingtalk.com/v1.0/yida/forms/instances/search"; | |
| 243 | + PersonnelRequestVo vo = new PersonnelRequestVo(); | |
| 244 | + vo.setAppType("APP_HV8J7X8PFRXLJJW8JTZK"); | |
| 245 | + vo.setFormUuid("FORM-CP766081XRMCZBZC7URI45AVVB662XFNMKAKLB"); | |
| 246 | + vo.setUserId("InterfaceManagement"); | |
| 247 | + vo.setSystemToken("16A66291CHE9K5DPE1IDO9E63FOE2VWA09QFLV"); | |
| 248 | + // 工号组件 | |
| 249 | +// vo.setSearchFieldJson(" size = 4"); | |
| 170 | 250 | // 设置请求头 |
| 171 | 251 | HttpHeaders headers = new HttpHeaders(); |
| 172 | 252 | headers.setContentType(MediaType.APPLICATION_JSON); |
| 253 | + headers.set("x-acs-dingtalk-access-token", accessToken); | |
| 173 | 254 | // 创建HttpEntity对象 |
| 174 | - HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<>(params, headers); | |
| 255 | + HttpEntity<String> requestEntity = new HttpEntity<>(JSON.toJSONString(vo), headers); | |
| 175 | 256 | |
| 176 | 257 | // 发送POST请求 |
| 177 | - ResponseEntity<TokenResponseVo> responseEntity = restTemplate.postForEntity(url, requestEntity, TokenResponseVo.class); | |
| 178 | - return responseEntity.getBody(); | |
| 258 | + ResponseEntity<PersonnelResultResponseVo> result = restTemplate.postForEntity(url, requestEntity, PersonnelResultResponseVo.class); | |
| 259 | + PersonnelResultResponseVo body = result.getBody(); | |
| 260 | + return body; | |
| 261 | + } | |
| 262 | + | |
| 263 | + public static TokenResponseVo getToken(String url) { | |
| 264 | + TokenRequestVo request = new TokenRequestVo(); | |
| 265 | + request.setAppKey(APP_KEY); | |
| 266 | + request.setAppSecret(APP_SECRET); | |
| 267 | + String requestBody = JSON.toJSONString(request); | |
| 268 | + // 设置请求头 | |
| 269 | + HttpHeaders headers = new HttpHeaders(); | |
| 270 | + headers.setContentType(MediaType.APPLICATION_JSON); | |
| 271 | + // 创建HttpEntity对象 | |
| 272 | + HttpEntity<String> requestEntity = new HttpEntity<>(requestBody, headers); | |
| 273 | + // 发送POST请求 | |
| 274 | + ResponseEntity<TokenResponseVo> responseEntity = RESTTEMPLATE.postForEntity(url, requestEntity, TokenResponseVo.class); | |
| 275 | + TokenResponseVo vo = responseEntity.getBody(); | |
| 276 | + REDIS_CACHE.setCacheObject(REDIS_PERSONNEL_TOKEN, vo.getAccessToken(), vo.getExpireIn(), TimeUnit.SECONDS); | |
| 277 | + | |
| 278 | + return vo; | |
| 179 | 279 | } |
| 180 | 280 | |
| 181 | 281 | public Map<String, String> getStringStringMap(String timestamp) { |
| ... | ... | @@ -255,9 +355,9 @@ public class DriverJob implements InitializingBean { |
| 255 | 355 | DRIVER_SERVICE = driverService; |
| 256 | 356 | REDIS_CACHE = redisCache; |
| 257 | 357 | GET_SCHEDULING_INFO_URL = getSchedulingInfoUrl; |
| 258 | - | |
| 259 | -// TOKEN_URL = tokenUrl; | |
| 260 | -// APP_KEY = appKey; | |
| 261 | -// APP_SECRET = appSecret; | |
| 358 | + THREAD_JOB_SERVICE = threadJobService; | |
| 359 | + TOKEN_URL = tokenUrl; | |
| 360 | + APP_KEY = appKey; | |
| 361 | + APP_SECRET = appSecret; | |
| 262 | 362 | } |
| 263 | 363 | } | ... | ... |
ruoyi-admin/src/main/java/com/ruoyi/pojo/converter/AlcoholFlagConverter.java
| ... | ... | @@ -6,7 +6,7 @@ import com.alibaba.excel.metadata.CellData; |
| 6 | 6 | import com.alibaba.excel.metadata.GlobalConfiguration; |
| 7 | 7 | import com.alibaba.excel.metadata.property.ExcelContentProperty; |
| 8 | 8 | |
| 9 | -import static com.ruoyi.common.SignInEnum.*; | |
| 9 | +import static com.ruoyi.common.ConstSignInConstSignInProperties.*; | |
| 10 | 10 | |
| 11 | 11 | /** |
| 12 | 12 | * 酒精测试 | ... | ... |
ruoyi-admin/src/main/java/com/ruoyi/pojo/converter/SignInConvert.java
| ... | ... | @@ -6,7 +6,7 @@ import com.alibaba.excel.metadata.CellData; |
| 6 | 6 | import com.alibaba.excel.metadata.GlobalConfiguration; |
| 7 | 7 | import com.alibaba.excel.metadata.property.ExcelContentProperty; |
| 8 | 8 | |
| 9 | -import static com.ruoyi.common.SignInEnum.*; | |
| 9 | +import static com.ruoyi.common.ConstSignInConstSignInProperties.*; | |
| 10 | 10 | |
| 11 | 11 | /** |
| 12 | 12 | * 签到类型 | ... | ... |
ruoyi-admin/src/main/java/com/ruoyi/pojo/converter/SignInStatusConverter.java
| ... | ... | @@ -6,7 +6,7 @@ import com.alibaba.excel.metadata.CellData; |
| 6 | 6 | import com.alibaba.excel.metadata.GlobalConfiguration; |
| 7 | 7 | import com.alibaba.excel.metadata.property.ExcelContentProperty; |
| 8 | 8 | |
| 9 | -import static com.ruoyi.common.SignInEnum.*; | |
| 9 | +import static com.ruoyi.common.ConstSignInConstSignInProperties.*; | |
| 10 | 10 | |
| 11 | 11 | /** |
| 12 | 12 | * @author 20412 | ... | ... |
ruoyi-admin/src/main/java/com/ruoyi/pojo/converter/SignInTypeConverter.java
| ... | ... | @@ -6,7 +6,7 @@ import com.alibaba.excel.metadata.CellData; |
| 6 | 6 | import com.alibaba.excel.metadata.GlobalConfiguration; |
| 7 | 7 | import com.alibaba.excel.metadata.property.ExcelContentProperty; |
| 8 | 8 | |
| 9 | -import static com.ruoyi.common.SignInEnum.*; | |
| 9 | +import static com.ruoyi.common.ConstSignInConstSignInProperties.*; | |
| 10 | 10 | |
| 11 | 11 | /** |
| 12 | 12 | * @author 20412 | ... | ... |
ruoyi-admin/src/main/java/com/ruoyi/pojo/request/PersonnelRequestVo.java
0 → 100644
ruoyi-admin/src/main/java/com/ruoyi/pojo/response/personnel/FormData.java
0 → 100644
| 1 | +package com.ruoyi.pojo.response.personnel; | |
| 2 | + | |
| 3 | +/** | |
| 4 | + * Auto-generated: 2023-07-21 10:29:43 | |
| 5 | + * | |
| 6 | + * @author json.cn (i@json.cn) | |
| 7 | + * @website http://www.json.cn/java2pojo/ | |
| 8 | + */ | |
| 9 | +public class FormData { | |
| 10 | + | |
| 11 | + private String textField_lk9mk226; | |
| 12 | + private String imageField_lk9mk228; | |
| 13 | + private String textField_lk9mk222; | |
| 14 | + private String textField_lk9mk224; | |
| 15 | + public void setTextField_lk9mk226(String textField_lk9mk226) { | |
| 16 | + this.textField_lk9mk226 = textField_lk9mk226; | |
| 17 | + } | |
| 18 | + public String getTextField_lk9mk226() { | |
| 19 | + return textField_lk9mk226; | |
| 20 | + } | |
| 21 | + | |
| 22 | + public void setImageField_lk9mk228(String imageField_lk9mk228) { | |
| 23 | + this.imageField_lk9mk228 = imageField_lk9mk228; | |
| 24 | + } | |
| 25 | + public String getImageField_lk9mk228() { | |
| 26 | + return imageField_lk9mk228; | |
| 27 | + } | |
| 28 | + | |
| 29 | + public void setTextField_lk9mk222(String textField_lk9mk222) { | |
| 30 | + this.textField_lk9mk222 = textField_lk9mk222; | |
| 31 | + } | |
| 32 | + public String getTextField_lk9mk222() { | |
| 33 | + return textField_lk9mk222; | |
| 34 | + } | |
| 35 | + | |
| 36 | + public void setTextField_lk9mk224(String textField_lk9mk224) { | |
| 37 | + this.textField_lk9mk224 = textField_lk9mk224; | |
| 38 | + } | |
| 39 | + public String getTextField_lk9mk224() { | |
| 40 | + return textField_lk9mk224; | |
| 41 | + } | |
| 42 | + | |
| 43 | +} | |
| 0 | 44 | \ No newline at end of file | ... | ... |
ruoyi-admin/src/main/java/com/ruoyi/pojo/response/personnel/ImageField_lk9mk228.java
0 → 100644
| 1 | +package com.ruoyi.pojo.response.personnel; | |
| 2 | + | |
| 3 | + | |
| 4 | +/** | |
| 5 | + * Auto-generated: 2023-07-21 13:58:9 | |
| 6 | + * | |
| 7 | + * @author json.cn (i@json.cn) | |
| 8 | + * @website http://www.json.cn/java2pojo/ | |
| 9 | + */ | |
| 10 | +public class ImageField_lk9mk228 { | |
| 11 | + | |
| 12 | + private String previewUrl; | |
| 13 | + private String size; | |
| 14 | + private String name; | |
| 15 | + private String downloadUrl; | |
| 16 | + private String fileUuid; | |
| 17 | + private String url; | |
| 18 | + public void setPreviewUrl(String previewUrl) { | |
| 19 | + this.previewUrl = previewUrl; | |
| 20 | + } | |
| 21 | + public String getPreviewUrl() { | |
| 22 | + return previewUrl; | |
| 23 | + } | |
| 24 | + | |
| 25 | + public void setSize(String size) { | |
| 26 | + this.size = size; | |
| 27 | + } | |
| 28 | + public String getSize() { | |
| 29 | + return size; | |
| 30 | + } | |
| 31 | + | |
| 32 | + public void setName(String name) { | |
| 33 | + this.name = name; | |
| 34 | + } | |
| 35 | + public String getName() { | |
| 36 | + return name; | |
| 37 | + } | |
| 38 | + | |
| 39 | + public void setDownloadUrl(String downloadUrl) { | |
| 40 | + this.downloadUrl = downloadUrl; | |
| 41 | + } | |
| 42 | + public String getDownloadUrl() { | |
| 43 | + return downloadUrl; | |
| 44 | + } | |
| 45 | + | |
| 46 | + public void setFileUuid(String fileUuid) { | |
| 47 | + this.fileUuid = fileUuid; | |
| 48 | + } | |
| 49 | + public String getFileUuid() { | |
| 50 | + return fileUuid; | |
| 51 | + } | |
| 52 | + | |
| 53 | + public void setUrl(String url) { | |
| 54 | + this.url = url; | |
| 55 | + } | |
| 56 | + public String getUrl() { | |
| 57 | + return url; | |
| 58 | + } | |
| 59 | + | |
| 60 | +} | |
| 0 | 61 | \ No newline at end of file | ... | ... |
ruoyi-admin/src/main/java/com/ruoyi/pojo/response/personnel/ImageUrlResultResponseVo.java
0 → 100644
ruoyi-admin/src/main/java/com/ruoyi/pojo/response/personnel/ModifyUser.java
0 → 100644
| 1 | +package com.ruoyi.pojo.response.personnel; | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | +/** | |
| 6 | + * Auto-generated: 2023-07-21 10:29:43 | |
| 7 | + * | |
| 8 | + * @author json.cn (i@json.cn) | |
| 9 | + * @website http://www.json.cn/java2pojo/ | |
| 10 | + */ | |
| 11 | +public class ModifyUser { | |
| 12 | + | |
| 13 | + private UserName userName; | |
| 14 | + private String userId; | |
| 15 | + public void setUserName(UserName userName) { | |
| 16 | + this.userName = userName; | |
| 17 | + } | |
| 18 | + public UserName getUserName() { | |
| 19 | + return userName; | |
| 20 | + } | |
| 21 | + | |
| 22 | + public void setUserId(String userId) { | |
| 23 | + this.userId = userId; | |
| 24 | + } | |
| 25 | + public String getUserId() { | |
| 26 | + return userId; | |
| 27 | + } | |
| 28 | + | |
| 29 | +} | |
| 0 | 30 | \ No newline at end of file | ... | ... |
ruoyi-admin/src/main/java/com/ruoyi/pojo/response/personnel/Originator.java
0 → 100644
| 1 | +package com.ruoyi.pojo.response.personnel; | |
| 2 | + | |
| 3 | +/** | |
| 4 | + * Copyright 2023 json.cn | |
| 5 | + */ | |
| 6 | + | |
| 7 | + | |
| 8 | +/** | |
| 9 | + * Auto-generated: 2023-07-21 10:29:43 | |
| 10 | + * | |
| 11 | + * @author json.cn (i@json.cn) | |
| 12 | + * @website http://www.json.cn/java2pojo/ | |
| 13 | + */ | |
| 14 | +public class Originator { | |
| 15 | + | |
| 16 | + private UserName userName; | |
| 17 | + private String userId; | |
| 18 | + public void setUserName(UserName userName) { | |
| 19 | + this.userName = userName; | |
| 20 | + } | |
| 21 | + public UserName getUserName() { | |
| 22 | + return userName; | |
| 23 | + } | |
| 24 | + | |
| 25 | + public void setUserId(String userId) { | |
| 26 | + this.userId = userId; | |
| 27 | + } | |
| 28 | + public String getUserId() { | |
| 29 | + return userId; | |
| 30 | + } | |
| 31 | + | |
| 32 | +} | |
| 0 | 33 | \ No newline at end of file | ... | ... |
ruoyi-admin/src/main/java/com/ruoyi/pojo/response/personnel/PersonnelData.java
0 → 100644
| 1 | +package com.ruoyi.pojo.response.personnel; | |
| 2 | + | |
| 3 | +import lombok.Data; | |
| 4 | + | |
| 5 | +import java.util.Date; | |
| 6 | + | |
| 7 | +@Data | |
| 8 | +public class PersonnelData { | |
| 9 | + | |
| 10 | + private String creatorUserId; | |
| 11 | + private String formUuid; | |
| 12 | + private Date modifiedTimeGMT; | |
| 13 | + private Date createdTimeGMT; | |
| 14 | + private String formInstanceId; | |
| 15 | + private Originator originator; | |
| 16 | + private String modelUuid; | |
| 17 | + private String title; | |
| 18 | + private String instanceValue; | |
| 19 | + private int version; | |
| 20 | + private String modifierUserId; | |
| 21 | + private ModifyUser modifyUser; | |
| 22 | + private FormData formData; | |
| 23 | +} | ... | ... |
ruoyi-admin/src/main/java/com/ruoyi/pojo/response/personnel/PersonnelResultResponseVo.java
0 → 100644
| 1 | +package com.ruoyi.pojo.response.personnel; | |
| 2 | + | |
| 3 | +import java.util.List; | |
| 4 | + | |
| 5 | +public class PersonnelResultResponseVo { | |
| 6 | + private List<PersonnelData> data; | |
| 7 | + private int currentPage; | |
| 8 | + private int totalCount; | |
| 9 | + | |
| 10 | + @Override | |
| 11 | + public String toString() { | |
| 12 | + return "PersonnelResultResponseVo{" + | |
| 13 | + "data=" + data + | |
| 14 | + ", currentPage=" + currentPage + | |
| 15 | + ", totalCount=" + totalCount + | |
| 16 | + '}'; | |
| 17 | + } | |
| 18 | + | |
| 19 | + public List<PersonnelData> getData() { | |
| 20 | + return data; | |
| 21 | + } | |
| 22 | + | |
| 23 | + public void setData(List<PersonnelData> data) { | |
| 24 | + this.data = data; | |
| 25 | + } | |
| 26 | + | |
| 27 | + public int getCurrentPage() { | |
| 28 | + return currentPage; | |
| 29 | + } | |
| 30 | + | |
| 31 | + public void setCurrentPage(int currentPage) { | |
| 32 | + this.currentPage = currentPage; | |
| 33 | + } | |
| 34 | + | |
| 35 | + public int getTotalCount() { | |
| 36 | + return totalCount; | |
| 37 | + } | |
| 38 | + | |
| 39 | + public void setTotalCount(int totalCount) { | |
| 40 | + this.totalCount = totalCount; | |
| 41 | + } | |
| 42 | +} | ... | ... |
ruoyi-admin/src/main/java/com/ruoyi/pojo/response/TokenResponseVo.java renamed to ruoyi-admin/src/main/java/com/ruoyi/pojo/response/personnel/TokenResponseVo.java
ruoyi-admin/src/main/java/com/ruoyi/pojo/response/personnel/UserName.java
0 → 100644
| 1 | +package com.ruoyi.pojo.response.personnel; | |
| 2 | + | |
| 3 | +/** | |
| 4 | + * Auto-generated: 2023-07-21 10:29:43 | |
| 5 | + * | |
| 6 | + * @author json.cn (i@json.cn) | |
| 7 | + * @website http://www.json.cn/java2pojo/ | |
| 8 | + */ | |
| 9 | +public class UserName { | |
| 10 | + | |
| 11 | + private String nameInChinese; | |
| 12 | + private String nameInEnglish; | |
| 13 | + private String type; | |
| 14 | + public void setNameInChinese(String nameInChinese) { | |
| 15 | + this.nameInChinese = nameInChinese; | |
| 16 | + } | |
| 17 | + public String getNameInChinese() { | |
| 18 | + return nameInChinese; | |
| 19 | + } | |
| 20 | + | |
| 21 | + public void setNameInEnglish(String nameInEnglish) { | |
| 22 | + this.nameInEnglish = nameInEnglish; | |
| 23 | + } | |
| 24 | + public String getNameInEnglish() { | |
| 25 | + return nameInEnglish; | |
| 26 | + } | |
| 27 | + | |
| 28 | + public void setType(String type) { | |
| 29 | + this.type = type; | |
| 30 | + } | |
| 31 | + public String getType() { | |
| 32 | + return type; | |
| 33 | + } | |
| 34 | + | |
| 35 | +} | |
| 0 | 36 | \ No newline at end of file | ... | ... |
ruoyi-admin/src/main/java/com/ruoyi/service/ReportService.java
| ... | ... | @@ -18,7 +18,6 @@ import java.util.stream.Collectors; |
| 18 | 18 | |
| 19 | 19 | import static com.ruoyi.common.ErrorTypeProperties.EQUIPMENT_ERROR; |
| 20 | 20 | import static com.ruoyi.common.ErrorTypeProperties.SIGN_IN_ERROR; |
| 21 | -import static com.ruoyi.common.SignInEnum.EXPORT; | |
| 22 | 21 | |
| 23 | 22 | /** |
| 24 | 23 | * @author 20412 | ... | ... |
ruoyi-admin/src/main/java/com/ruoyi/service/ThreadJobService.java
| ... | ... | @@ -6,21 +6,29 @@ import com.ruoyi.common.constant.Constants; |
| 6 | 6 | import com.ruoyi.common.exception.file.FileUploadException; |
| 7 | 7 | import com.ruoyi.common.utils.DateUtils; |
| 8 | 8 | import com.ruoyi.common.utils.StringUtils; |
| 9 | +import com.ruoyi.common.utils.file.FileUploadUtils; | |
| 10 | +import com.ruoyi.common.utils.file.FileUtils; | |
| 9 | 11 | import com.ruoyi.common.utils.uuid.Seq; |
| 10 | 12 | import com.ruoyi.common.utils.uuid.UUID; |
| 13 | +import com.ruoyi.driver.domain.Driver; | |
| 11 | 14 | import com.ruoyi.driver.mapper.DriverMapper; |
| 15 | +import com.ruoyi.job.DriverJob; | |
| 16 | +import com.ruoyi.utils.HttpUtils; | |
| 12 | 17 | import lombok.extern.slf4j.Slf4j; |
| 13 | 18 | import org.apache.commons.io.FilenameUtils; |
| 14 | 19 | import org.springframework.beans.factory.annotation.Autowired; |
| 20 | +import org.springframework.beans.factory.annotation.Value; | |
| 15 | 21 | import org.springframework.scheduling.annotation.Async; |
| 16 | 22 | import org.springframework.scheduling.annotation.EnableAsync; |
| 17 | 23 | import org.springframework.stereotype.Component; |
| 24 | +import org.springframework.web.client.RestTemplate; | |
| 18 | 25 | import sun.misc.BASE64Decoder; |
| 19 | 26 | |
| 20 | -import java.io.File; | |
| 21 | -import java.io.FileOutputStream; | |
| 22 | -import java.io.IOException; | |
| 27 | +import java.io.*; | |
| 28 | +import java.nio.file.Files; | |
| 29 | +import java.nio.file.Paths; | |
| 23 | 30 | import java.util.Base64; |
| 31 | +import java.util.HashMap; | |
| 24 | 32 | import java.util.List; |
| 25 | 33 | import java.util.Objects; |
| 26 | 34 | |
| ... | ... | @@ -38,6 +46,8 @@ public class ThreadJobService { |
| 38 | 46 | @Autowired |
| 39 | 47 | private DriverMapper driverMapper; |
| 40 | 48 | |
| 49 | + @Value("${api.headImage}") | |
| 50 | + private String headImagePre; | |
| 41 | 51 | |
| 42 | 52 | |
| 43 | 53 | /** |
| ... | ... | @@ -49,7 +59,7 @@ public class ThreadJobService { |
| 49 | 59 | * @throws IOException |
| 50 | 60 | */ |
| 51 | 61 | @Async |
| 52 | - public void asyncStartUpload(String url, String base64) { | |
| 62 | + public void asyncStartUploadBase64Image(String url, String base64) { | |
| 53 | 63 | FileOutputStream outputStream = null; |
| 54 | 64 | base64 = base64.replaceAll(" ", ""); |
| 55 | 65 | BASE64Decoder decoder = new BASE64Decoder(); |
| ... | ... | @@ -76,27 +86,101 @@ public class ThreadJobService { |
| 76 | 86 | } |
| 77 | 87 | } |
| 78 | 88 | } |
| 89 | + | |
| 90 | + /** | |
| 91 | + * 签到人员与签到设备绑定 | |
| 92 | + * | |
| 93 | + * @param deviceId | |
| 94 | + * @param jobCodes | |
| 95 | + */ | |
| 79 | 96 | @Async |
| 80 | - public void asyncUpdateDriver(String deviceId, List<String> jobCodes){ | |
| 97 | + public void asyncInsertSignInContactEquipment(String deviceId, List<String> jobCodes) { | |
| 81 | 98 | Integer result = driverMapper.insertDriverFace(deviceId, jobCodes); |
| 82 | - log.info("注册设备与员工关联完毕:{}",result); | |
| 99 | + log.info("注册设备与员工关联完毕:{}", result); | |
| 100 | + } | |
| 101 | + | |
| 102 | + @Async | |
| 103 | + public void asyncUploadDriverWithUpdateImageUrl(List<Driver> drivers, String token) { | |
| 104 | + // 插入数据 | |
| 105 | + for (Driver driver : drivers) { | |
| 106 | + String imageUlr = driver.getImage(); | |
| 107 | + // 生成文件路径 | |
| 108 | + String fileName = driver.getJobCode() + ".png"; | |
| 109 | + String filePath = RuoYiConfig.getUploadPath() + headImagePre + "/" + fileName; | |
| 110 | + try { | |
| 111 | + fileName = FileUploadUtils.getPathFileName(RuoYiConfig.getUploadPath() + headImagePre, fileName); | |
| 112 | + } catch (IOException e) { | |
| 113 | + throw new RuntimeException(e); | |
| 114 | + } | |
| 115 | + driver.setImage(fileName); | |
| 116 | + // 插入数据 如果员工已经存在在不在下载图片 | |
| 117 | + int result = driverMapper.insertDriver(driver); | |
| 118 | + log.debug("插入完毕"); | |
| 119 | + if (result == 0) { | |
| 120 | + continue; | |
| 121 | + } | |
| 122 | + // 获取图片请求地址 | |
| 123 | + String imageUrl = DriverJob.getDownloadImageUrl(token, imageUlr); | |
| 124 | + // 获取图片数据 | |
| 125 | + InputStream is = HttpUtils.doGet(imageUrl, new HashMap<>()); | |
| 126 | + // 上传图片 | |
| 127 | + uploadImage(is, filePath); | |
| 128 | + } | |
| 129 | + | |
| 130 | + | |
| 131 | + } | |
| 132 | + | |
| 133 | + private void uploadImage(InputStream is, String filePath) { | |
| 134 | + File file = new File(filePath + File.separator); | |
| 135 | + if (!file.exists()) { | |
| 136 | + if (!file.getParentFile().exists()) { | |
| 137 | + file.getParentFile().mkdirs(); | |
| 138 | + } | |
| 139 | + } | |
| 140 | + // 保存图片到本地文件 | |
| 141 | + FileOutputStream fos = null; | |
| 142 | + try { | |
| 143 | + | |
| 144 | + fos = new FileOutputStream(file); | |
| 145 | + byte[] cbuf = new byte[1024]; | |
| 146 | + int len; | |
| 147 | + while ((len = is.read(cbuf)) != -1) { | |
| 148 | + fos.write(cbuf, 0, len); | |
| 149 | + } | |
| 150 | + } catch (IOException e) { | |
| 151 | + throw new RuntimeException(e); | |
| 152 | + } finally { | |
| 153 | + try { | |
| 154 | + if (is != null) { | |
| 155 | + is.close(); | |
| 156 | + } | |
| 157 | + } catch (IOException e) { | |
| 158 | + e.printStackTrace(); | |
| 159 | + } | |
| 160 | + try { | |
| 161 | + if (fos != null) { | |
| 162 | + fos.close(); | |
| 163 | + } | |
| 164 | + } catch (IOException e) { | |
| 165 | + e.printStackTrace(); | |
| 166 | + } | |
| 167 | + } | |
| 83 | 168 | } |
| 84 | 169 | |
| 85 | 170 | /** |
| 86 | 171 | * 检查文件类型 |
| 87 | 172 | * |
| 88 | - * @param base64ImgData | |
| 173 | + * @param b | |
| 89 | 174 | * @return |
| 90 | 175 | */ |
| 91 | - public static String checkImageBase64Format(String base64ImgData) { | |
| 92 | - byte[] b = Base64.getDecoder().decode(base64ImgData); | |
| 176 | + public static String checkImageBase64Format(byte[] b) { | |
| 93 | 177 | String type = ""; |
| 94 | 178 | if (0x424D == ((b[0] & 0xff) << 8 | (b[1] & 0xff))) { |
| 95 | - type = "bmp"; | |
| 179 | + type = ".bmp"; | |
| 96 | 180 | } else if (0x8950 == ((b[0] & 0xff) << 8 | (b[1] & 0xff))) { |
| 97 | - type = "png"; | |
| 181 | + type = ".png"; | |
| 98 | 182 | } else { |
| 99 | - type = "jpg"; | |
| 183 | + type = ".jpg"; | |
| 100 | 184 | } |
| 101 | 185 | // else if (0xFFD8 == ((b[0] & 0xff) << 8 | (b[1] & 0xff))) { |
| 102 | 186 | // type = "jpg"; |
| ... | ... | @@ -104,48 +188,5 @@ public class ThreadJobService { |
| 104 | 188 | return type; |
| 105 | 189 | } |
| 106 | 190 | |
| 107 | - /** | |
| 108 | - * 获取相对路径名 | |
| 109 | - * | |
| 110 | - * @param uploadDir | |
| 111 | - * @param fileName | |
| 112 | - * @return | |
| 113 | - * @throws IOException | |
| 114 | - */ | |
| 115 | - public File getAbsoluteFile(String uploadDir, String fileName) throws IOException { | |
| 116 | - File desc = new File(uploadDir + File.separator + fileName); | |
| 117 | - | |
| 118 | - if (!desc.exists()) { | |
| 119 | - if (!desc.getParentFile().exists()) { | |
| 120 | - desc.getParentFile().mkdirs(); | |
| 121 | - } | |
| 122 | - } | |
| 123 | - return desc; | |
| 124 | - } | |
| 125 | - | |
| 126 | - /** | |
| 127 | - * 获取扩展文件名 | |
| 128 | - * | |
| 129 | - * @param extendFileName | |
| 130 | - * @return | |
| 131 | - */ | |
| 132 | - public String extractFilename(String extendFileName) { | |
| 133 | - return StringUtils.format("{}/{}_{}.{}", DateUtils.datePath(), | |
| 134 | - FilenameUtils.getBaseName(UUID.randomUUID().toString().replace("-", "")), Seq.getId(Seq.uploadSeqType), extendFileName); | |
| 135 | - } | |
| 136 | - | |
| 137 | - /** | |
| 138 | - * @param uploadDir | |
| 139 | - * @param fileName | |
| 140 | - * @return | |
| 141 | - * @throws IOException | |
| 142 | - */ | |
| 143 | - public String getPathFileName(String uploadDir, String fileName) throws IOException { | |
| 144 | - int dirLastIndex = RuoYiConfig.getProfile().length() + 1; | |
| 145 | - String currentDir = StringUtils.substring(uploadDir, dirLastIndex); | |
| 146 | - return Constants.RESOURCE_PREFIX + "/" + currentDir + "/" + fileName; | |
| 147 | - } | |
| 148 | - | |
| 149 | - | |
| 150 | 191 | |
| 151 | 192 | } | ... | ... |
ruoyi-admin/src/main/java/com/ruoyi/utils/HttpUtils.java
0 → 100644
| 1 | +package com.ruoyi.utils; | |
| 2 | + | |
| 3 | +import lombok.extern.slf4j.Slf4j; | |
| 4 | +import org.apache.commons.collections.CollectionUtils; | |
| 5 | +import org.apache.commons.io.IOUtils; | |
| 6 | +import org.apache.http.HttpEntity; | |
| 7 | +import org.apache.http.HttpResponse; | |
| 8 | +import org.apache.http.NameValuePair; | |
| 9 | +import org.apache.http.client.config.RequestConfig; | |
| 10 | +import org.apache.http.client.entity.UrlEncodedFormEntity; | |
| 11 | +import org.apache.http.client.methods.CloseableHttpResponse; | |
| 12 | +import org.apache.http.client.methods.HttpGet; | |
| 13 | +import org.apache.http.client.methods.HttpPost; | |
| 14 | +import org.apache.http.conn.ssl.SSLConnectionSocketFactory; | |
| 15 | +import org.apache.http.conn.ssl.TrustStrategy; | |
| 16 | +import org.apache.http.entity.StringEntity; | |
| 17 | +import org.apache.http.impl.client.CloseableHttpClient; | |
| 18 | +import org.apache.http.impl.client.HttpClients; | |
| 19 | +import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; | |
| 20 | +import org.apache.http.message.BasicNameValuePair; | |
| 21 | +import org.apache.http.ssl.SSLContextBuilder; | |
| 22 | +import org.apache.http.util.EntityUtils; | |
| 23 | +import org.slf4j.Logger; | |
| 24 | +import org.slf4j.LoggerFactory; | |
| 25 | + | |
| 26 | +import javax.net.ssl.HostnameVerifier; | |
| 27 | +import javax.net.ssl.SSLContext; | |
| 28 | +import javax.net.ssl.SSLSession; | |
| 29 | +import java.io.IOException; | |
| 30 | +import java.io.InputStream; | |
| 31 | +import java.security.GeneralSecurityException; | |
| 32 | +import java.security.cert.CertificateException; | |
| 33 | +import java.security.cert.X509Certificate; | |
| 34 | +import java.util.*; | |
| 35 | + | |
| 36 | +@Slf4j | |
| 37 | +public class HttpUtils { | |
| 38 | + private static PoolingHttpClientConnectionManager connMgr; | |
| 39 | + private static RequestConfig requestConfig; | |
| 40 | + private static final int MAX_TIMEOUT = 10000; | |
| 41 | + | |
| 42 | + private static final Logger logger = LoggerFactory.getLogger(HttpUtils.class); | |
| 43 | + | |
| 44 | + static { | |
| 45 | + // 设置连接池 | |
| 46 | + connMgr = new PoolingHttpClientConnectionManager(); | |
| 47 | + // 设置连接池大小 | |
| 48 | + connMgr.setMaxTotal(20); | |
| 49 | + connMgr.setDefaultMaxPerRoute(connMgr.getMaxTotal()); | |
| 50 | + // Validate connections after 1 sec of inactivity | |
| 51 | + connMgr.setValidateAfterInactivity(5000); | |
| 52 | + RequestConfig.Builder configBuilder = RequestConfig.custom(); | |
| 53 | + // 设置连接超时 | |
| 54 | + configBuilder.setConnectTimeout(MAX_TIMEOUT); | |
| 55 | + // 设置读取超时 | |
| 56 | + configBuilder.setSocketTimeout(MAX_TIMEOUT); | |
| 57 | + // 设置从连接池获取连接实例的超时 | |
| 58 | + configBuilder.setConnectionRequestTimeout(MAX_TIMEOUT); | |
| 59 | + | |
| 60 | + requestConfig = configBuilder.build(); | |
| 61 | + } | |
| 62 | + | |
| 63 | + /** | |
| 64 | + * 发送 GET 请求(HTTP),不带输入数据 | |
| 65 | + * | |
| 66 | + * @param url | |
| 67 | + * @return | |
| 68 | + */ | |
| 69 | + public static String doGet(String url) { | |
| 70 | + return doGet(url, new HashMap<String, Object>(), new HashMap<>()); | |
| 71 | + } | |
| 72 | + | |
| 73 | + /** | |
| 74 | + * 发送 GET 请求(HTTP),K-V形式 | |
| 75 | + * | |
| 76 | + * @param url | |
| 77 | + * @param params | |
| 78 | + * @return | |
| 79 | + */ | |
| 80 | + public static String doGet(String url, Map<String, Object> params, Map<String, String> headers) { | |
| 81 | + String apiUrl = url; | |
| 82 | + StringBuffer param = new StringBuffer(); | |
| 83 | + int i = 0; | |
| 84 | + for (String key : params.keySet()) { | |
| 85 | + if (i == 0) | |
| 86 | + param.append("?"); | |
| 87 | + else | |
| 88 | + param.append("&"); | |
| 89 | + param.append(key).append("=").append(params.get(key)); | |
| 90 | + i++; | |
| 91 | + } | |
| 92 | + apiUrl += param; | |
| 93 | + String result = null; | |
| 94 | + CloseableHttpClient httpClient = null; | |
| 95 | + if (apiUrl.startsWith("https")) { | |
| 96 | + httpClient = HttpClients.custom().setSSLSocketFactory(createSSLConnSocketFactory()) | |
| 97 | + .setConnectionManager(connMgr).setDefaultRequestConfig(requestConfig).build(); | |
| 98 | + } else { | |
| 99 | + httpClient = HttpClients.createDefault(); | |
| 100 | + } | |
| 101 | + HttpResponse response = null; | |
| 102 | + try { | |
| 103 | + log.info("HttpUrl:{}",apiUrl); | |
| 104 | + HttpGet httpGet = new HttpGet(apiUrl); | |
| 105 | + httpGet.setConfig(requestConfig); | |
| 106 | + for (Map.Entry<String, String> header : headers.entrySet()) { | |
| 107 | + httpGet.addHeader(header.getKey(), header.getValue()); | |
| 108 | + } | |
| 109 | + response = httpClient.execute(httpGet); | |
| 110 | + HttpEntity entity = response.getEntity(); | |
| 111 | + if (entity != null) { | |
| 112 | + InputStream instream = entity.getContent(); | |
| 113 | + result = IOUtils.toString(instream, "UTF-8"); | |
| 114 | + logger.info("Http Result:{}",result); | |
| 115 | + } | |
| 116 | + } catch (IOException e) { | |
| 117 | + logger.error("Http Error:{}",e.getMessage()); | |
| 118 | + try { | |
| 119 | + if (httpClient != null) { | |
| 120 | + httpClient.close(); | |
| 121 | + } | |
| 122 | + if (response != null) { | |
| 123 | + EntityUtils.consume(response.getEntity()); | |
| 124 | + } | |
| 125 | + } catch (IOException exception) { | |
| 126 | + exception.printStackTrace(); | |
| 127 | + } | |
| 128 | + } | |
| 129 | + return result; | |
| 130 | + } | |
| 131 | + | |
| 132 | + public static InputStream doGet(String url,Map<String, Object> params) { | |
| 133 | + HashMap<String, String> headers = new HashMap<>(); | |
| 134 | + String apiUrl = url; | |
| 135 | + StringBuffer param = new StringBuffer(); | |
| 136 | + int i = 0; | |
| 137 | + for (String key : params.keySet()) { | |
| 138 | + if (i == 0) | |
| 139 | + param.append("?"); | |
| 140 | + else | |
| 141 | + param.append("&"); | |
| 142 | + param.append(key).append("=").append(params.get(key)); | |
| 143 | + i++; | |
| 144 | + } | |
| 145 | + apiUrl += param; | |
| 146 | + InputStream result = null; | |
| 147 | + CloseableHttpClient httpClient = null; | |
| 148 | + if (apiUrl.startsWith("https")) { | |
| 149 | + httpClient = HttpClients.custom().setSSLSocketFactory(createSSLConnSocketFactory()) | |
| 150 | + .setConnectionManager(connMgr).setDefaultRequestConfig(requestConfig).build(); | |
| 151 | + } else { | |
| 152 | + httpClient = HttpClients.createDefault(); | |
| 153 | + } | |
| 154 | + HttpResponse response = null; | |
| 155 | + try { | |
| 156 | + log.info("HttpUrl:{}",apiUrl); | |
| 157 | + HttpGet httpGet = new HttpGet(apiUrl); | |
| 158 | + httpGet.setConfig(requestConfig); | |
| 159 | + for (Map.Entry<String, String> header : headers.entrySet()) { | |
| 160 | + httpGet.addHeader(header.getKey(), header.getValue()); | |
| 161 | + } | |
| 162 | + response = httpClient.execute(httpGet); | |
| 163 | + HttpEntity entity = response.getEntity(); | |
| 164 | + if (entity != null) { | |
| 165 | + result = entity.getContent(); | |
| 166 | + logger.info("Http Result:{}",result); | |
| 167 | + } | |
| 168 | + } catch (IOException e) { | |
| 169 | + logger.error("Http Error:{}",e.getMessage()); | |
| 170 | + try { | |
| 171 | + if (httpClient != null) { | |
| 172 | + httpClient.close(); | |
| 173 | + } | |
| 174 | + if (response != null) { | |
| 175 | + EntityUtils.consume(response.getEntity()); | |
| 176 | + } | |
| 177 | + } catch (IOException exception) { | |
| 178 | + exception.printStackTrace(); | |
| 179 | + } | |
| 180 | + } | |
| 181 | + return result; | |
| 182 | + } | |
| 183 | + /** | |
| 184 | + * 发送 GET 请求(HTTP),K-V形式--------取消重定向!!!!!! | |
| 185 | + * | |
| 186 | + * @param url | |
| 187 | + * @param params | |
| 188 | + * @return | |
| 189 | + */ | |
| 190 | + public static HttpResponse doGetAndReturnResponse(String url, Map<String, Object> params, Map<String, String> headers) { | |
| 191 | + String apiUrl = url; | |
| 192 | + StringBuffer param = new StringBuffer(); | |
| 193 | + int i = 0; | |
| 194 | + for (String key : params.keySet()) { | |
| 195 | + if (i == 0) | |
| 196 | + param.append("?"); | |
| 197 | + else | |
| 198 | + param.append("&"); | |
| 199 | + param.append(key).append("=").append(params.get(key)); | |
| 200 | + i++; | |
| 201 | + } | |
| 202 | + apiUrl += param; | |
| 203 | + | |
| 204 | + CloseableHttpClient httpClient = null; | |
| 205 | + if (apiUrl.startsWith("https")) { | |
| 206 | + httpClient = HttpClients.custom().setSSLSocketFactory(createSSLConnSocketFactory()) | |
| 207 | + .setConnectionManager(connMgr).setDefaultRequestConfig(requestConfig).build(); | |
| 208 | + } else { | |
| 209 | + httpClient = HttpClients.createDefault(); | |
| 210 | + } | |
| 211 | + CloseableHttpResponse response = null; | |
| 212 | + try { | |
| 213 | + HttpGet httpGet = new HttpGet(apiUrl); | |
| 214 | + httpGet.setConfig(requestConfig); | |
| 215 | + | |
| 216 | + //取消强制重定向!!!!! | |
| 217 | + httpGet.setConfig(RequestConfig.custom().setRedirectsEnabled(false).build()); | |
| 218 | + | |
| 219 | + | |
| 220 | + for (Map.Entry<String, String> header : headers.entrySet()) { | |
| 221 | + httpGet.addHeader(header.getKey(), header.getValue()); | |
| 222 | + } | |
| 223 | + response = httpClient.execute(httpGet); | |
| 224 | + | |
| 225 | + return response; | |
| 226 | + } catch (IOException e) { | |
| 227 | + try { | |
| 228 | + if (httpClient != null) { | |
| 229 | + httpClient.close(); | |
| 230 | + } | |
| 231 | + if (response != null) { | |
| 232 | + EntityUtils.consume(response.getEntity()); | |
| 233 | + } | |
| 234 | + } catch (IOException exception) { | |
| 235 | + exception.printStackTrace(); | |
| 236 | + } | |
| 237 | + } | |
| 238 | + return null; | |
| 239 | + } | |
| 240 | + | |
| 241 | + | |
| 242 | + /** | |
| 243 | + * 发送 POST 请求(HTTP),不带输入数据 | |
| 244 | + * | |
| 245 | + * @param apiUrl | |
| 246 | + * @return | |
| 247 | + */ | |
| 248 | + public static String doPost(String apiUrl) { | |
| 249 | + return doPost(apiUrl, "", new HashMap<>()); | |
| 250 | + } | |
| 251 | + | |
| 252 | + /** | |
| 253 | + * 发送 POST 请求,K-V形式 | |
| 254 | + * | |
| 255 | + * @param apiUrl API接口URL | |
| 256 | + * @return | |
| 257 | + */ | |
| 258 | + public static String doPost(String apiUrl, String paramStr, Map<String, String> headers) { | |
| 259 | + CloseableHttpClient httpClient = null; | |
| 260 | + if (apiUrl.startsWith("https")) { | |
| 261 | + httpClient = HttpClients.custom().setSSLSocketFactory(createSSLConnSocketFactory()) | |
| 262 | + .setConnectionManager(connMgr).setDefaultRequestConfig(requestConfig).build(); | |
| 263 | + } else { | |
| 264 | + httpClient = HttpClients.createDefault(); | |
| 265 | + } | |
| 266 | + String httpStr = null; | |
| 267 | + HttpPost httpPost = new HttpPost(apiUrl); | |
| 268 | + CloseableHttpResponse response = null; | |
| 269 | + | |
| 270 | + try { | |
| 271 | + httpPost.setConfig(requestConfig); | |
| 272 | + if(CollectionUtils.isNotEmpty(headers.entrySet())){ | |
| 273 | + for (Map.Entry<String, String> header : headers.entrySet()) { | |
| 274 | + httpPost.addHeader(header.getKey(), header.getValue()); | |
| 275 | + } | |
| 276 | + } | |
| 277 | + httpPost.setEntity(new StringEntity(paramStr)); | |
| 278 | + response = httpClient.execute(httpPost); | |
| 279 | + HttpEntity entity = response.getEntity(); | |
| 280 | + httpStr = EntityUtils.toString(entity, "UTF-8"); | |
| 281 | + } catch (IOException e) { | |
| 282 | + log.error("Http调用异常:{}",e.getMessage()); | |
| 283 | + e.printStackTrace(); | |
| 284 | + } finally { | |
| 285 | + try { | |
| 286 | + if (httpClient != null) { | |
| 287 | + httpClient.close(); | |
| 288 | + } | |
| 289 | + if (response != null) { | |
| 290 | + EntityUtils.consume(response.getEntity()); | |
| 291 | + } | |
| 292 | + } catch (IOException exception) { | |
| 293 | + exception.printStackTrace(); | |
| 294 | + } | |
| 295 | + } | |
| 296 | + return httpStr; | |
| 297 | + } | |
| 298 | + | |
| 299 | + public static HttpResponse doPostAndReturnResponse(String apiUrl, Map<String, String> params, Map<String, String> headers) { | |
| 300 | + CloseableHttpClient httpClient = null; | |
| 301 | + if (apiUrl.startsWith("https")) { | |
| 302 | + httpClient = HttpClients.custom().setSSLSocketFactory(createSSLConnSocketFactory()) | |
| 303 | + .setConnectionManager(connMgr).setDefaultRequestConfig(requestConfig).build(); | |
| 304 | + } else { | |
| 305 | + httpClient = HttpClients.createDefault(); | |
| 306 | + } | |
| 307 | + HttpPost httpPost = new HttpPost(apiUrl); | |
| 308 | + CloseableHttpResponse response = null; | |
| 309 | + | |
| 310 | + try { | |
| 311 | + httpPost.setConfig(requestConfig); | |
| 312 | + for (Map.Entry<String, String> header : headers.entrySet()) { | |
| 313 | + httpPost.addHeader(header.getKey(), header.getValue()); | |
| 314 | + } | |
| 315 | + //组织请求参数 | |
| 316 | + List<NameValuePair> paramList = new ArrayList<NameValuePair>(); | |
| 317 | + if (params != null && params.size() > 0) { | |
| 318 | + Set<String> keySet = params.keySet(); | |
| 319 | + for (String key : keySet) { | |
| 320 | + paramList.add(new BasicNameValuePair(key, params.get(key))); | |
| 321 | + } | |
| 322 | + } | |
| 323 | + httpPost.setEntity(new UrlEncodedFormEntity(paramList, "UTF-8")); | |
| 324 | + response = httpClient.execute(httpPost); | |
| 325 | + return response; | |
| 326 | + } catch (IOException e) { | |
| 327 | + log.error("发送Http Post异常:{}", e); | |
| 328 | + } finally { | |
| 329 | + try { | |
| 330 | + if (httpClient != null) { | |
| 331 | + // httpClient.close(); | |
| 332 | + } | |
| 333 | + if (response != null) { | |
| 334 | + EntityUtils.consume(response.getEntity()); | |
| 335 | + } | |
| 336 | + } catch (IOException exception) { | |
| 337 | + exception.printStackTrace(); | |
| 338 | + } | |
| 339 | + } | |
| 340 | + return null; | |
| 341 | + } | |
| 342 | + | |
| 343 | + /** | |
| 344 | + * 发送 POST 请求,JSON形式,接收端需要支持json形式,否则取不到数据 | |
| 345 | + * | |
| 346 | + * @param apiUrl | |
| 347 | + * @param json json对象 | |
| 348 | + * @return | |
| 349 | + */ | |
| 350 | + public static String doPost(String apiUrl, String json) { | |
| 351 | + CloseableHttpClient httpClient = null; | |
| 352 | + if (apiUrl.startsWith("https")) { | |
| 353 | + httpClient = HttpClients.custom().setSSLSocketFactory(createSSLConnSocketFactory()).setConnectionManager(connMgr).setDefaultRequestConfig(requestConfig).build(); | |
| 354 | + } else { | |
| 355 | + httpClient = HttpClients.createDefault(); | |
| 356 | + } | |
| 357 | + String httpStr = null; | |
| 358 | + HttpPost httpPost = new HttpPost(apiUrl); | |
| 359 | + CloseableHttpResponse response = null; | |
| 360 | + | |
| 361 | + try { | |
| 362 | + httpPost.setConfig(requestConfig); | |
| 363 | + StringEntity stringEntity = new StringEntity(json, "UTF-8");// 解决中文乱码问题 | |
| 364 | + stringEntity.setContentEncoding("UTF-8"); | |
| 365 | + stringEntity.setContentType("application/json"); | |
| 366 | + httpPost.setEntity(stringEntity); | |
| 367 | + response = httpClient.execute(httpPost); | |
| 368 | + HttpEntity entity = response.getEntity(); | |
| 369 | + httpStr = EntityUtils.toString(entity, "UTF-8"); | |
| 370 | + } catch (IOException e) { | |
| 371 | + log.error("发送Http Post异常:{}}", e); | |
| 372 | + } finally { | |
| 373 | + try { | |
| 374 | + if (response != null) { | |
| 375 | + EntityUtils.consume(response.getEntity()); | |
| 376 | + } | |
| 377 | + } catch (IOException exception) { | |
| 378 | + exception.printStackTrace(); | |
| 379 | + } | |
| 380 | + } | |
| 381 | + return httpStr; | |
| 382 | + } | |
| 383 | + | |
| 384 | + /** | |
| 385 | + * 创建SSL安全连接 | |
| 386 | + * | |
| 387 | + * @return | |
| 388 | + */ | |
| 389 | + private static SSLConnectionSocketFactory createSSLConnSocketFactory() { | |
| 390 | + SSLConnectionSocketFactory sslsf = null; | |
| 391 | + try { | |
| 392 | + SSLContext sslContext = new SSLContextBuilder().loadTrustMaterial(null, new TrustStrategy() { | |
| 393 | + | |
| 394 | + public boolean isTrusted(X509Certificate[] chain, String authType) throws CertificateException { | |
| 395 | + return true; | |
| 396 | + } | |
| 397 | + }).build(); | |
| 398 | + sslsf = new SSLConnectionSocketFactory(sslContext, new HostnameVerifier() { | |
| 399 | + | |
| 400 | + @Override | |
| 401 | + public boolean verify(String arg0, SSLSession arg1) { | |
| 402 | + return true; | |
| 403 | + } | |
| 404 | + }); | |
| 405 | + } catch (GeneralSecurityException e) { | |
| 406 | + e.printStackTrace(); | |
| 407 | + } | |
| 408 | + return sslsf; | |
| 409 | + } | |
| 410 | + | |
| 411 | + | |
| 412 | +} | ... | ... |
ruoyi-admin/src/main/resources/application-druid-dev.yml
| ... | ... | @@ -7,7 +7,7 @@ spring: |
| 7 | 7 | # 主库数据源 |
| 8 | 8 | master: |
| 9 | 9 | # 测试地址 |
| 10 | - url: jdbc:mysql://localhost:3306/all-in-one?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 | |
| 10 | + url: jdbc:mysql://localhost:3306/all-in-one?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&useAffectedRows=true | |
| 11 | 11 | username: root |
| 12 | 12 | password: guzijian |
| 13 | 13 | # 从库数据源 |
| ... | ... | @@ -144,7 +144,13 @@ api: |
| 144 | 144 | nonce: adfsad |
| 145 | 145 | apk: |
| 146 | 146 | path: /apk/dev/ |
| 147 | + # 用户头像存放位置 | |
| 148 | + headImage: /head/image | |
| 149 | + | |
| 147 | 150 | personnel: |
| 148 | - tokenUrl: https://api.dingtalk.com/v1.0/oauth2/accessToken | |
| 149 | - appKey: dingsclwvxui5zilg1xk | |
| 150 | - appSecret: ckV20k3jMKJpUkfXXSGhLk077rQQjsSaAusiSVY-nm4glwweCmb_SMJ62Cpf4YQ5 | |
| 151 | 151 | \ No newline at end of file |
| 152 | + token: | |
| 153 | + tokenUrl: https://api.dingtalk.com/v1.0/oauth2/accessToken | |
| 154 | + appKey: dingsclwvxui5zilg1xk | |
| 155 | + appSecret: ckV20k3jMKJpUkfXXSGhLk077rQQjsSaAusiSVY-nm4glwweCmb_SMJ62Cpf4YQ5 | |
| 156 | + people: | |
| 157 | + url: https://api.dingtalk.com/v1.0/yida/forms/instances/search | |
| 152 | 158 | \ No newline at end of file | ... | ... |
ruoyi-admin/src/main/resources/application-druid-prd.yml
| ... | ... | @@ -71,7 +71,7 @@ ruoyi: |
| 71 | 71 | # 实例演示开关 |
| 72 | 72 | demoEnabled: true |
| 73 | 73 | # 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath) |
| 74 | - profile: D:/ruoyi/uploadPath | |
| 74 | + profile: /home/ruoyi/uploadPath | |
| 75 | 75 | # 获取ip地址开关 |
| 76 | 76 | addressEnabled: false |
| 77 | 77 | # 验证码类型 math 数字计算 char 字符验证 |
| ... | ... | @@ -104,6 +104,9 @@ api: |
| 104 | 104 | nonce: adfsad |
| 105 | 105 | apk: |
| 106 | 106 | path: /apk/dev/ |
| 107 | + # 用户头像存放位置 | |
| 108 | + headImage: /head/image | |
| 109 | + | |
| 107 | 110 | personnel: |
| 108 | 111 | tokenUrl: https://api.dingtalk.com/v1.0/oauth2/accessToken |
| 109 | 112 | appKey: dingsclwvxui5zilg1xk | ... | ... |
ruoyi-admin/src/main/resources/application-druid-uat.yml
ruoyi-admin/src/main/resources/mapper/driver/DriverMapper.xml
| ... | ... | @@ -188,6 +188,8 @@ |
| 188 | 188 | <if test="faceSignIn != null">#{faceSignIn},</if> |
| 189 | 189 | <if test="image != null">#{image}</if> |
| 190 | 190 | </trim> |
| 191 | + on duplicate key update | |
| 192 | + job_code = values(job_code) | |
| 191 | 193 | </insert> |
| 192 | 194 | |
| 193 | 195 | <update id="updateDriver" parameterType="Driver"> | ... | ... |
ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisCache.java
| ... | ... | @@ -46,6 +46,9 @@ public class RedisCache { |
| 46 | 46 | public <T> void setCacheObject(final String key, final T value, final Integer timeout, final TimeUnit timeUnit) { |
| 47 | 47 | redisTemplate.opsForValue().set(key, value, timeout, timeUnit); |
| 48 | 48 | } |
| 49 | + public <T> void setCacheObject(final String key, final T value, final Long timeout, final TimeUnit timeUnit) { | |
| 50 | + redisTemplate.opsForValue().set(key, value, timeout, timeUnit); | |
| 51 | + } | |
| 49 | 52 | |
| 50 | 53 | /** |
| 51 | 54 | * 设置有效时间 |
| ... | ... | @@ -263,7 +266,7 @@ public class RedisCache { |
| 263 | 266 | return redisTemplate.opsForHash().delete(key, hKey) > 0; |
| 264 | 267 | } |
| 265 | 268 | |
| 266 | - public Integer increment(String key, String hkey,Integer value){ | |
| 269 | + public Integer setIncrementMapValue(String key, String hkey, Integer value){ | |
| 267 | 270 | return redisTemplate.opsForHash().increment(key,hkey,value.longValue()).intValue(); |
| 268 | 271 | } |
| 269 | 272 | ... | ... |