|
|
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
+import com.sckw.core.exception.BusinessException;
|
|
|
import com.sckw.core.exception.SystemException;
|
|
|
import com.sckw.core.model.constant.Global;
|
|
|
import com.sckw.core.model.page.PageHelperUtil;
|
|
|
@@ -15,19 +16,28 @@ import com.sckw.core.utils.StringUtils;
|
|
|
import com.sckw.core.web.constant.HttpStatus;
|
|
|
import com.sckw.core.web.context.LoginUserHolder;
|
|
|
import com.sckw.core.web.response.HttpResult;
|
|
|
+import com.sckw.excel.utils.EasyExcelUtil;
|
|
|
import com.sckw.fleet.dao.*;
|
|
|
import com.sckw.fleet.model.*;
|
|
|
-import com.sckw.fleet.model.dto.KwfDriverCardDto;
|
|
|
-import com.sckw.fleet.model.dto.KwfDriverDto;
|
|
|
-import com.sckw.fleet.model.dto.KwfDriverLicenseDto;
|
|
|
-import com.sckw.fleet.model.dto.KwfDriverQualificationDto;
|
|
|
+import com.sckw.fleet.model.dto.*;
|
|
|
import com.sckw.fleet.model.vo.KwfDriverVo;
|
|
|
+import com.sckw.fleet.model.vo.KwfTableTopCount;
|
|
|
+import com.sckw.redis.constant.RedisConstant;
|
|
|
+import com.sckw.redis.utils.RedissonUtils;
|
|
|
+import com.sckw.system.api.RemoteSystemService;
|
|
|
+import com.sckw.system.api.model.dto.res.EntCacheResDto;
|
|
|
+import com.sckw.system.api.model.dto.res.UserCacheResDto;
|
|
|
+import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
+import java.io.IOException;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @desc 司机
|
|
|
@@ -48,6 +58,8 @@ public class KwfDriverService {
|
|
|
KwfDriverLicenseMapper KwfDriverLicenseDao;
|
|
|
@Autowired
|
|
|
KwfDriverQualificationMapper KwfDriverQualificationDao;
|
|
|
+ @DubboReference(version = "2.0.0", group = "design", check = false)
|
|
|
+ private RemoteSystemService remoteSystemService;
|
|
|
|
|
|
/**
|
|
|
* @param key 逐渐id
|
|
|
@@ -59,6 +71,33 @@ public class KwfDriverService {
|
|
|
return driverDao.selectById(key);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @param params 参数
|
|
|
+ * @desc 统计
|
|
|
+ * @author zk
|
|
|
+ * @date 2023/7/11
|
|
|
+ **/
|
|
|
+ public Map statistics(Map<String, Object> params) {
|
|
|
+ /**统计数据**/
|
|
|
+ List<KwfTableTopCount> counts = driverDao.statistics(params);
|
|
|
+ long tatol = 0;
|
|
|
+ for (KwfTableTopCount topCount:counts) {
|
|
|
+ tatol += topCount.getTotal();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**全部数据-处理**/
|
|
|
+ KwfTableTopCount allCount = new KwfTableTopCount();
|
|
|
+ allCount.setValue(String.valueOf(Global.NUMERICAL_ZERO));
|
|
|
+ allCount.setTotal(tatol);
|
|
|
+ counts.add(allCount);
|
|
|
+
|
|
|
+ /**数据组装**/
|
|
|
+ Map tableCount = new HashMap();
|
|
|
+ tableCount.put("tableTop", counts);
|
|
|
+ tableCount.put("tableBottom", tatol);
|
|
|
+ return tableCount;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @param params 分页参数
|
|
|
* @desc 分页查询
|
|
|
@@ -66,7 +105,34 @@ public class KwfDriverService {
|
|
|
* @date 2023/7/6
|
|
|
**/
|
|
|
public List<KwfDriverVo> findPage(Map<String, Object> params) {
|
|
|
- return driverDao.findPage(params);
|
|
|
+ /**查询分页数据**/
|
|
|
+ List<KwfDriverVo> drivers = driverDao.findPage(params);
|
|
|
+ if (CollectionUtils.isEmpty(drivers)) {
|
|
|
+ return drivers;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**获取查询数据**/
|
|
|
+ List<Long> createBys = new ArrayList<>();
|
|
|
+ List<Long> entIds = new ArrayList<>();
|
|
|
+ for (KwfDriverVo driverVo:drivers) {
|
|
|
+ createBys.add(Long.parseLong(driverVo.getCreateBy()));
|
|
|
+ entIds.add(Long.parseLong(driverVo.getEntId()));
|
|
|
+ }
|
|
|
+ //用户数据集
|
|
|
+ createBys = createBys.stream().distinct().collect(Collectors.toList());
|
|
|
+ Map<Long, UserCacheResDto> users = remoteSystemService.queryUserCacheMapByIds(createBys);
|
|
|
+ //企业数据集
|
|
|
+ entIds = entIds.stream().distinct().collect(Collectors.toList());
|
|
|
+ Map<Long, EntCacheResDto> ents = remoteSystemService.queryEntCacheMapByIds(entIds);
|
|
|
+
|
|
|
+ /**数据组装**/
|
|
|
+ for (KwfDriverVo driverVo:drivers) {
|
|
|
+ UserCacheResDto user = users == null ? null : users.get(Long.parseLong(driverVo.getCreateBy()));
|
|
|
+ EntCacheResDto ent = ents == null ? null : ents.get(Long.parseLong(driverVo.getEntId()));
|
|
|
+ driverVo.setCreateByName(user != null ? user.getName() : null);
|
|
|
+ driverVo.setFirmName(ent != null ? ent.getFirmName() : null);
|
|
|
+ }
|
|
|
+ return drivers;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -79,6 +145,16 @@ public class KwfDriverService {
|
|
|
return driverDao.findList(params);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @param {}
|
|
|
+ * @description 导出
|
|
|
+ * @author zk
|
|
|
+ * @date 2023/07/11
|
|
|
+ **/
|
|
|
+ public HttpResult importExcel(MultipartFile file) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @param params 参数
|
|
|
* @desc 新增司机
|
|
|
@@ -89,6 +165,13 @@ public class KwfDriverService {
|
|
|
/**司机信息**/
|
|
|
KwfDriver driver = new KwfDriver();
|
|
|
BeanUtils.copyProperties(params, driver);
|
|
|
+ //证件都有数据则为已认证(前端校验认证数据必填)
|
|
|
+ boolean bool = checkLicense(params);
|
|
|
+ if (bool) {
|
|
|
+ driver.setStatus(Global.NUMERICAL_ONE);
|
|
|
+ } else {
|
|
|
+ driver.setStatus(Global.NUMERICAL_TWO);
|
|
|
+ }
|
|
|
HttpResult result = driverEdit(driver);
|
|
|
if (result.getCode() != HttpStatus.SUCCESS_CODE) {
|
|
|
return result;
|
|
|
@@ -138,6 +221,11 @@ public class KwfDriverService {
|
|
|
|
|
|
/**司机信息**/
|
|
|
BeanUtils.copyProperties(params, driver);
|
|
|
+ //证件都有数据则为已认证(前端校验认证数据必填)
|
|
|
+ boolean bool = checkLicense(params);
|
|
|
+ if (bool) {
|
|
|
+ driver.setStatus(Global.NUMERICAL_ONE);
|
|
|
+ }
|
|
|
HttpResult result = driverEdit(driver);
|
|
|
if (result.getCode() != HttpStatus.SUCCESS_CODE) {
|
|
|
return result;
|
|
|
@@ -245,15 +333,18 @@ public class KwfDriverService {
|
|
|
BeanUtils.copyProperties(params, driverCard);
|
|
|
|
|
|
/**数据更新**/
|
|
|
+ int count = 0;
|
|
|
KwfDriverCard card = KwfDriverCardDao.findByDriverId(params.getDriverId());
|
|
|
if (card == null) {
|
|
|
- int count = KwfDriverCardDao.insert(driverCard);
|
|
|
- return count > 0 ? HttpResult.ok("身份证信息更新成功!") : HttpResult.error("身份证信息更新失败!");
|
|
|
+ count = KwfDriverCardDao.insert(driverCard);
|
|
|
} else {
|
|
|
driverCard.setId(card.getId());
|
|
|
- int count = KwfDriverCardDao.updateById(driverCard);
|
|
|
- return count > 0 ? HttpResult.ok("身份证信息修改成功!") : HttpResult.error("身份证信息修改失败!");
|
|
|
+ count = KwfDriverCardDao.updateById(driverCard);
|
|
|
}
|
|
|
+
|
|
|
+ /**校验司机是否有证书并更新状态**/
|
|
|
+ checkLicense(driverCard.getDriverId());
|
|
|
+ return count > 0 ? HttpResult.ok("身份证信息修改成功!") : HttpResult.error("身份证信息修改失败!");
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -278,15 +369,19 @@ public class KwfDriverService {
|
|
|
BeanUtils.copyProperties(params, driverLicense);
|
|
|
|
|
|
/**数据更新**/
|
|
|
+ int count = 0;
|
|
|
KwfDriverLicense license = KwfDriverLicenseDao.findByDriverId(params.getDriverId());
|
|
|
if (license == null) {
|
|
|
- int count = KwfDriverLicenseDao.insert(driverLicense);
|
|
|
+ count = KwfDriverLicenseDao.insert(driverLicense);
|
|
|
return count > 0 ? HttpResult.ok("司机驾驶证信息更新成功!") : HttpResult.error("司机驾驶证信息更新失败!");
|
|
|
} else {
|
|
|
driverLicense.setId(license.getId());
|
|
|
- int count = KwfDriverLicenseDao.updateById(driverLicense);
|
|
|
- return count > 0 ? HttpResult.ok("司机驾驶证信息修改成功!") : HttpResult.error("司机驾驶证信息修改失败!");
|
|
|
+ count = KwfDriverLicenseDao.updateById(driverLicense);
|
|
|
}
|
|
|
+
|
|
|
+ /**校验司机是否有证书并更新状态**/
|
|
|
+ checkLicense(driverLicense.getDriverId());
|
|
|
+ return count > 0 ? HttpResult.ok("司机驾驶证信息修改成功!") : HttpResult.error("司机驾驶证信息修改失败!");
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -311,15 +406,18 @@ public class KwfDriverService {
|
|
|
BeanUtils.copyProperties(params, driverQual);
|
|
|
|
|
|
/**数据更新**/
|
|
|
+ int count = 0;
|
|
|
KwfDriverQualification qualification = KwfDriverQualificationDao.findByDriverId(params.getDriverId());
|
|
|
if (qualification == null) {
|
|
|
- int count = KwfDriverQualificationDao.insert(driverQual);
|
|
|
- return count > 0 ? HttpResult.ok("司机从业资格证信息更新成功!") : HttpResult.error("司机从业资格证信息更新失败!");
|
|
|
+ count = KwfDriverQualificationDao.insert(driverQual);
|
|
|
} else {
|
|
|
driverQual.setId(qualification.getId());
|
|
|
- int count = KwfDriverQualificationDao.updateById(driverQual);
|
|
|
- return count > 0 ? HttpResult.ok("司机从业资格证信息修改成功!") : HttpResult.error("司机从业资格证信息修改失败!");
|
|
|
+ count = KwfDriverQualificationDao.updateById(driverQual);
|
|
|
}
|
|
|
+
|
|
|
+ /**校验司机是否有证书并更新状态**/
|
|
|
+ checkLicense(driverQual.getDriverId());
|
|
|
+ return count > 0 ? HttpResult.ok("司机从业资格证信息修改成功!") : HttpResult.error("司机从业资格证信息修改失败!");
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -345,4 +443,123 @@ public class KwfDriverService {
|
|
|
driverEntDao.insert(driverEnt);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @param params 参数
|
|
|
+ * @desc: 修改密码
|
|
|
+ * @author: zk
|
|
|
+ * @date: 2023/7/11
|
|
|
+ */
|
|
|
+ public HttpResult updatePassword(UpdatePasswordDto params) {
|
|
|
+ /**获取信息**/
|
|
|
+ Long driverId = null;//LoginUserHolder.getUserId(); //暂时----------------zk
|
|
|
+ driverId = driverId == null ? params.getDriverId() : driverId;
|
|
|
+ KwfDriver driver = driverDao.selectById(driverId);
|
|
|
+ if (driver == null) {
|
|
|
+ return HttpResult.error("信息不存在!");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**原密码校验**/
|
|
|
+ if (!PasswordUtils.validatePassword(params.getPassword(), driver.getPassword())) {
|
|
|
+ return HttpResult.error("原密码不正确!");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**新旧密码不能一只**/
|
|
|
+ if (PasswordUtils.validatePassword(params.getNewPassword(), driver.getPassword())) {
|
|
|
+ return HttpResult.error("原密码与新密码不能一致!");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**更新数据**/
|
|
|
+ driver.setPassword(PasswordUtils.entryptPassword(params.getNewPassword()));
|
|
|
+ driver.setSalt(PasswordUtils.getSaltSubPwd(driver.getPassword()));
|
|
|
+ int count = driverDao.updateById(driver);
|
|
|
+ return count > 0 ? HttpResult.ok("密码修改成功!") : HttpResult.error("密码修改失败!");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param {driverId 司机主键id/登陆后缓存中取、phone 手机号、captcha 短信验证码}
|
|
|
+ * @description 更换手机号
|
|
|
+ * @author zk
|
|
|
+ * @date 2023/07/11
|
|
|
+ **/
|
|
|
+ public HttpResult replacePhone(ReplacePhoneDto params) {
|
|
|
+ /**获取信息**/
|
|
|
+ Long driverId = null;//LoginUserHolder.getUserId(); //暂时----------------zk
|
|
|
+ driverId = driverId == null ? params.getDriverId() : driverId;
|
|
|
+ KwfDriver driver = driverDao.selectById(driverId);
|
|
|
+ if (driver == null) {
|
|
|
+ return HttpResult.error("信息不存在!");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**从缓存中取出验证码/校验**/
|
|
|
+ String valueKey = StringUtils.getKey(RedisConstant.MESSAGE_SMS_VERIFY_CODE_VALUE_KEY, params.getPhone());
|
|
|
+ String phoneCaptcha = RedissonUtils.getString(valueKey);
|
|
|
+ if (StringUtils.isBlank(phoneCaptcha)) {
|
|
|
+ return HttpResult.error("手机验证码不正确请确认!");
|
|
|
+ }
|
|
|
+ if (!phoneCaptcha.equals(params.getCaptcha())) {
|
|
|
+ return HttpResult.error("手机验证码不正确请确认!");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**唯一性交易**/
|
|
|
+ List<Map<String, Object>> drivers = driverDao.findList(new HashMap(){{ put("phone", params.getPhone()); }});
|
|
|
+ if (!CollectionUtils.isEmpty(drivers)) {
|
|
|
+ return HttpResult.error("电话号码已存在!");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**更新数据**/
|
|
|
+ driver.setPhone(params.getPhone());
|
|
|
+ int count = driverDao.updateById(driver);
|
|
|
+ return count > 0 ? HttpResult.ok("手机号更换成功!") : HttpResult.error("手机号更换失败!");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param params 参数
|
|
|
+ * @desc 校验司机是否有证书
|
|
|
+ * @author zk
|
|
|
+ * @date 2023/7/11
|
|
|
+ **/
|
|
|
+ public boolean checkLicense(KwfDriverDto params) {
|
|
|
+ //身份证
|
|
|
+ if (params.getDriverCard() == null || StringUtils.isBlank(params.getDriverCard().getIdcard())) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ //司机驾驶证信息
|
|
|
+ if (params.getDriverLicense() == null || StringUtils.isBlank(params.getDriverLicense().getDriverNo())) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ //司机从业资格证
|
|
|
+ if (params.getDriverQualification() == null || StringUtils.isBlank(params.getDriverQualification().getQualiNo())) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param driverId 司机id
|
|
|
+ * @desc 校验司机是否有证书并更新状态
|
|
|
+ * @author zk
|
|
|
+ * @date 2023/7/11
|
|
|
+ **/
|
|
|
+ public void checkLicense(Long driverId) {
|
|
|
+ //身份证
|
|
|
+ KwfDriverCard card = this.findCarByKey(driverId);
|
|
|
+ if (card == null || StringUtils.isBlank(card)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //司机驾驶证信息
|
|
|
+ KwfDriverLicense license = this.findLicenseByKey(driverId);
|
|
|
+ if (license == null || StringUtils.isBlank(license.getDriverNo())) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //司机从业资格证
|
|
|
+ KwfDriverQualification quali = this.findQualificationByKey(driverId);
|
|
|
+ if (quali == null || StringUtils.isBlank(quali.getQualiNo())) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //更新数据
|
|
|
+ KwfDriver driver = new KwfDriver();
|
|
|
+ driver.setId(driverId);
|
|
|
+ driver.setStatus(Global.NUMERICAL_ONE);
|
|
|
+ driverDao.updateById(driver);
|
|
|
+ }
|
|
|
}
|