|
|
@@ -1,7 +1,9 @@
|
|
|
package com.sckw.fleet.service;
|
|
|
|
|
|
+import com.sckw.core.common.enums.enums.DictEnum;
|
|
|
import com.sckw.core.exception.SystemException;
|
|
|
import com.sckw.core.model.constant.Global;
|
|
|
+import com.sckw.core.model.enums.SystemTypeEnum;
|
|
|
import com.sckw.core.utils.BeanUtils;
|
|
|
import com.sckw.core.utils.CollectionUtils;
|
|
|
import com.sckw.core.utils.PasswordUtils;
|
|
|
@@ -12,8 +14,7 @@ import com.sckw.core.web.response.HttpResult;
|
|
|
import com.sckw.fleet.dao.*;
|
|
|
import com.sckw.fleet.model.*;
|
|
|
import com.sckw.fleet.model.dto.*;
|
|
|
-import com.sckw.fleet.model.vo.KwfDriverVo;
|
|
|
-import com.sckw.fleet.model.vo.KwfTableTopCount;
|
|
|
+import com.sckw.fleet.model.vo.*;
|
|
|
import com.sckw.redis.constant.RedisConstant;
|
|
|
import com.sckw.redis.utils.RedissonUtils;
|
|
|
import com.sckw.system.api.RemoteSystemService;
|
|
|
@@ -50,6 +51,8 @@ public class KwfDriverService {
|
|
|
@Autowired
|
|
|
KwfDriverQualificationMapper KwfDriverQualificationDao;
|
|
|
@Autowired
|
|
|
+ KwfTruckReportMapper truckReportDao;
|
|
|
+ @Autowired
|
|
|
KwfFleetDriverMapper fleetDriverDao;
|
|
|
@DubboReference(version = "1.0.0", group = "design", check = false)
|
|
|
private RemoteSystemService remoteSystemService;
|
|
|
@@ -64,6 +67,63 @@ public class KwfDriverService {
|
|
|
return driverDao.selectById(key);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @param driverId 司机ID
|
|
|
+ * @desc 司机信息查询
|
|
|
+ * @author zk
|
|
|
+ * @date 2023/7/11
|
|
|
+ **/
|
|
|
+ public KwfDriverDetailVo detail(Long driverId) {
|
|
|
+ //司机信息
|
|
|
+ KwfDriver driver = this.selectByKey(driverId);
|
|
|
+ KwfDriverDetailVo driverDetailVo = new KwfDriverDetailVo();
|
|
|
+ BeanUtils.copyPropertiesValue(driver, driverDetailVo);
|
|
|
+
|
|
|
+ //数据查询
|
|
|
+ if (driver != null) {
|
|
|
+ //身份证信息
|
|
|
+ KwfDriverCard cardJson = this.findCarByKey(driverId);
|
|
|
+ KwfDriverCardVo driverCardVo = new KwfDriverCardVo();
|
|
|
+ BeanUtils.copyPropertiesValue(cardJson, driverCardVo);
|
|
|
+ driverDetailVo.setDriverCard(driverCardVo);
|
|
|
+
|
|
|
+ //司机驾驶证信息
|
|
|
+ KwfDriverLicense licenseJson = this.findLicenseByKey(driverId);
|
|
|
+ KwfDriverLicenseVo driverLicenseVo = new KwfDriverLicenseVo();
|
|
|
+ BeanUtils.copyPropertiesValue(licenseJson, driverLicenseVo);
|
|
|
+ driverDetailVo.setDriverLicense(driverLicenseVo);
|
|
|
+
|
|
|
+ //司机从业资格证
|
|
|
+ KwfDriverQualification qualificationJson = this.findQualificationByKey(driverId);
|
|
|
+ KwfDriverQualificationVo qualificationVo = new KwfDriverQualificationVo();
|
|
|
+ BeanUtils.copyPropertiesValue(qualificationJson, qualificationVo);
|
|
|
+ driverDetailVo.setDriverQualification(qualificationVo);
|
|
|
+
|
|
|
+ //车队班组
|
|
|
+ KwfFleet fleet = this.findByFleetDriver(driverId, LoginUserHolder.getEntId());
|
|
|
+ driverDetailVo.setFleetId(fleet != null ? fleet.getId() : null);
|
|
|
+ driverDetailVo.setFleetName(fleet != null ? fleet.getName() : null);
|
|
|
+
|
|
|
+ //司机关联车辆(车辆上报)
|
|
|
+ if (LoginUserHolder.getSystemType() == SystemTypeEnum.DRIVER.getCode()) {
|
|
|
+ List<Map<String, Object>> trucks = new ArrayList();
|
|
|
+ List<Map<String, Object>> reports = truckReportDao.findList(new HashMap() {{
|
|
|
+ put("driverId", driverId);
|
|
|
+ }});
|
|
|
+ for (Map<String, Object> report : reports) {
|
|
|
+ trucks.add(new HashMap() {{
|
|
|
+ put("truckId", report.get("truckId"));
|
|
|
+ put("truckNo", report.get("truckNo"));
|
|
|
+ put("trailerNo", report.get("truckTrailerNo"));
|
|
|
+ }});
|
|
|
+ }
|
|
|
+ driverDetailVo.setTrucks(trucks);
|
|
|
+ }
|
|
|
+ return driverDetailVo;
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @param params 参数
|
|
|
* @desc 统计
|
|
|
@@ -362,6 +422,10 @@ public class KwfDriverService {
|
|
|
/**数据copy**/
|
|
|
KwfDriverCard driverCard = new KwfDriverCard();
|
|
|
BeanUtils.copyProperties(params, driverCard);
|
|
|
+ driverCard.setStatus(Global.YES);
|
|
|
+ if (StringUtils.isBlank(driverCard.getCertificateMain()) && StringUtils.isBlank(driverCard.getCertificateRevolt())) {
|
|
|
+ driverCard.setStatus(Global.NO);
|
|
|
+ }
|
|
|
|
|
|
/**数据更新**/
|
|
|
int count = 0;
|
|
|
@@ -407,6 +471,10 @@ public class KwfDriverService {
|
|
|
/**数据copy**/
|
|
|
KwfDriverLicense driverLicense = new KwfDriverLicense();
|
|
|
BeanUtils.copyProperties(params, driverLicense);
|
|
|
+ driverLicense.setStatus(Global.YES);
|
|
|
+ if (StringUtils.isBlank(driverLicense.getCertificateMain()) && StringUtils.isBlank(driverLicense.getCertificateRevolt())) {
|
|
|
+ driverLicense.setStatus(Global.NO);
|
|
|
+ }
|
|
|
|
|
|
/**数据更新**/
|
|
|
int count = 0;
|
|
|
@@ -453,6 +521,10 @@ public class KwfDriverService {
|
|
|
/**数据copy**/
|
|
|
KwfDriverQualification driverQual = new KwfDriverQualification();
|
|
|
BeanUtils.copyProperties(params, driverQual);
|
|
|
+ driverQual.setStatus(Global.YES);
|
|
|
+ if (StringUtils.isBlank(driverQual.getCertificateMain()) && StringUtils.isBlank(driverQual.getCertificateRevolt())) {
|
|
|
+ driverQual.setStatus(Global.NO);
|
|
|
+ }
|
|
|
|
|
|
/**数据更新**/
|
|
|
int count = 0;
|
|
|
@@ -534,7 +606,6 @@ public class KwfDriverService {
|
|
|
return fleetDriverDao.findByFleetDriver(driverId, entId);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* @param params 参数
|
|
|
* @desc: 修改密码
|
|
|
@@ -583,13 +654,13 @@ public class KwfDriverService {
|
|
|
}
|
|
|
|
|
|
/**从缓存中取出验证码/校验**/
|
|
|
- String valueKey = StringUtils.format(RedisConstant.MESSAGE_SMS_VERIFY_CODE_VALUE_KEY, params.getPhone());
|
|
|
- String phoneCaptcha = RedissonUtils.getString(valueKey);
|
|
|
- if (StringUtils.isBlank(phoneCaptcha)) {
|
|
|
- return HttpResult.error("手机验证码不正确请确认!");
|
|
|
+ String key = StringUtils.format(RedisConstant.MESSAGE_SMS_VERIFY_CODE_VALUE_KEY, params.getPhone());
|
|
|
+ String smsCaptcha = RedissonUtils.getString(key);
|
|
|
+ if (StringUtils.isBlank(smsCaptcha)) {
|
|
|
+ return HttpResult.error("验证码已过期,请重新获取!!");
|
|
|
}
|
|
|
- if (!phoneCaptcha.equals(params.getCaptcha())) {
|
|
|
- return HttpResult.error("手机验证码不正确请确认!");
|
|
|
+ if (!smsCaptcha.equals(params.getCaptcha())) {
|
|
|
+ return HttpResult.error("验证码不正确,请确认再输入!");
|
|
|
}
|
|
|
|
|
|
/**唯一性交易**/
|
|
|
@@ -604,6 +675,42 @@ public class KwfDriverService {
|
|
|
return count > 0 ? HttpResult.ok("手机号更换成功!") : HttpResult.error("手机号更换失败!");
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @param {account 账号、password 密码、captcha 验证码}
|
|
|
+ * @description 忘记密码
|
|
|
+ * @author zk
|
|
|
+ * @date 2023/08/15
|
|
|
+ **/
|
|
|
+ public HttpResult forgetPassword(ForgetPasswordDto params) {
|
|
|
+ /**校验**/
|
|
|
+ String key = StringUtils.format(RedisConstant.MESSAGE_SMS_VERIFY_CODE_VALUE_KEY, DictEnum.SMS_UPDATE_PASSWORD.getValue(), params.getAccount());
|
|
|
+ RedissonUtils.putString(key, params.getCaptcha(), RedisConstant.SMS_VERIFY_CODE_VALID_TIME);
|
|
|
+ String smsCaptcha = RedissonUtils.getString(key);
|
|
|
+ if (StringUtils.isBlank(smsCaptcha)){
|
|
|
+ return HttpResult.error(HttpStatus.UN_LOGIN_CODE, "验证码不能为空!");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(smsCaptcha)){
|
|
|
+ return HttpResult.error(HttpStatus.UN_LOGIN_CODE, "验证码已过期,请重新获取!");
|
|
|
+ }
|
|
|
+ if (!params.getCaptcha().equals(smsCaptcha)){
|
|
|
+ return HttpResult.error(HttpStatus.UN_LOGIN_CODE, "验证码不正确,请确认再输入!");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**查询**/
|
|
|
+ List<KwfDriver> drivers = driverDao.findDriver(new HashMap(){{ put("phone", params.getAccount()); }});
|
|
|
+ if (CollectionUtils.isEmpty(drivers)) {
|
|
|
+ return HttpResult.error("账号不存在,请确认后再输入!");
|
|
|
+ }
|
|
|
+ KwfDriver driver = drivers.get(Global.NUMERICAL_ZERO);
|
|
|
+
|
|
|
+ /**更新数据**/
|
|
|
+ driver.setPassword(PasswordUtils.entryptPassword(params.getPassword()));
|
|
|
+ driver.setSalt(PasswordUtils.getSaltSubPwd(driver.getPassword()));
|
|
|
+ int count = driverDao.updateById(driver);
|
|
|
+ return count > 0 ? HttpResult.ok("密码修改成功!") : HttpResult.error("密码修改失败!");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* @param params 参数
|
|
|
* @desc 校验司机是否有证书
|
|
|
@@ -612,15 +719,18 @@ public class KwfDriverService {
|
|
|
**/
|
|
|
public boolean checkLicense(KwfDriverDto params) {
|
|
|
//身份证
|
|
|
- if (params.getDriverCard() == null || StringUtils.isBlank(params.getDriverCard().getIdcard())) {
|
|
|
+ KwfDriverCardDto card = params.getDriverCard();
|
|
|
+ if (card == null || (StringUtils.isBlank(card.getCertificateMain()) && StringUtils.isBlank(card.getCertificateRevolt()))) {
|
|
|
return false;
|
|
|
}
|
|
|
//司机驾驶证信息
|
|
|
- if (params.getDriverLicense() == null || StringUtils.isBlank(params.getDriverLicense().getDriverNo())) {
|
|
|
+ KwfDriverLicenseDto license = params.getDriverLicense();
|
|
|
+ if (license == null || (StringUtils.isBlank(license.getCertificateMain()) && StringUtils.isBlank(license.getCertificateRevolt()))) {
|
|
|
return false;
|
|
|
}
|
|
|
//司机从业资格证
|
|
|
- if (params.getDriverQualification() == null || StringUtils.isBlank(params.getDriverQualification().getQualiNo())) {
|
|
|
+ KwfDriverQualificationDto quali = params.getDriverQualification();
|
|
|
+ if (quali == null || (StringUtils.isBlank(quali.getCertificateMain()) && StringUtils.isBlank(quali.getCertificateRevolt()))) {
|
|
|
return false;
|
|
|
}
|
|
|
return true;
|