|
|
@@ -1,8 +1,13 @@
|
|
|
package com.sckw.fleet.service;
|
|
|
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+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.SystemException;
|
|
|
import com.sckw.core.model.constant.Global;
|
|
|
+import com.sckw.core.model.page.PageHelperUtil;
|
|
|
+import com.sckw.core.model.page.PageResult;
|
|
|
import com.sckw.core.utils.BeanUtils;
|
|
|
import com.sckw.core.utils.CollectionUtils;
|
|
|
import com.sckw.core.utils.PasswordUtils;
|
|
|
@@ -19,6 +24,7 @@ import com.sckw.fleet.model.dto.KwfDriverQualificationDto;
|
|
|
import com.sckw.fleet.model.vo.KwfDriverVo;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
@@ -29,6 +35,7 @@ import java.util.Map;
|
|
|
* @date 2023/7/6 0006
|
|
|
*/
|
|
|
@Service
|
|
|
+@Transactional(rollbackFor = Exception.class)
|
|
|
public class KwfDriverService {
|
|
|
|
|
|
@Autowired
|
|
|
@@ -68,8 +75,8 @@ public class KwfDriverService {
|
|
|
* @author zk
|
|
|
* @date 2023/7/6
|
|
|
**/
|
|
|
- public List<KwfDriver> findList(Map<String, Object> params) {
|
|
|
- return driverDao.selectPage(null, null);
|
|
|
+ public List<Map<String, Object>> findList(Map<String, Object> params) {
|
|
|
+ return driverDao.findList(params);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -83,21 +90,30 @@ public class KwfDriverService {
|
|
|
KwfDriver driver = new KwfDriver();
|
|
|
BeanUtils.copyProperties(params, driver);
|
|
|
HttpResult result = driverEdit(driver);
|
|
|
- if (result != null) {
|
|
|
+ if (result.getCode() != HttpStatus.SUCCESS_CODE) {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/**身份证信息**/
|
|
|
- params.getDriverCard().setDriverId(params.getId());
|
|
|
- driverCardEdit(params.getDriverCard());
|
|
|
+ KwfDriverCardDto driverCardDto = params.getDriverCard();
|
|
|
+ if (driverCardDto != null) {
|
|
|
+ driverCardDto.setDriverId(String.valueOf(driver.getId()));
|
|
|
+ driverCardEdit(driverCardDto);
|
|
|
+ }
|
|
|
|
|
|
/**司机驾驶证信息**/
|
|
|
- params.getDriverLicense().setDriverId(params.getId());
|
|
|
- driverLicenseEdit(params.getDriverLicense());
|
|
|
+ KwfDriverLicenseDto driverLicenseDto = params.getDriverLicense();
|
|
|
+ if (driverLicenseDto != null) {
|
|
|
+ driverLicenseDto.setDriverId(String.valueOf(driver.getId()));
|
|
|
+ driverLicenseEdit(driverLicenseDto);
|
|
|
+ }
|
|
|
|
|
|
/**司机从业资格证**/
|
|
|
- params.getDriverQualification().setDriverId(params.getId());
|
|
|
- driverQualificationEdit(params.getDriverQualification());
|
|
|
+ KwfDriverQualificationDto driverQualificationDto = params.getDriverQualification();
|
|
|
+ if (driverQualificationDto != null) {
|
|
|
+ driverQualificationDto.setDriverId(String.valueOf(driver.getId()));
|
|
|
+ driverQualificationEdit(driverQualificationDto);
|
|
|
+ }
|
|
|
|
|
|
/**司机信息与企业关联信息**/
|
|
|
driverEntEdit(driver);
|
|
|
@@ -123,22 +139,31 @@ public class KwfDriverService {
|
|
|
/**司机信息**/
|
|
|
BeanUtils.copyProperties(params, driver);
|
|
|
HttpResult result = driverEdit(driver);
|
|
|
- if (result != null) {
|
|
|
+ if (result.getCode() != HttpStatus.SUCCESS_CODE) {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/**身份证信息**/
|
|
|
- params.getDriverCard().setDriverId(params.getId());
|
|
|
- driverCardEdit(params.getDriverCard());
|
|
|
+ KwfDriverCardDto driverCardDto = params.getDriverCard();
|
|
|
+ if (driverCardDto != null) {
|
|
|
+ driverCardDto.setDriverId(String.valueOf(driver.getId()));
|
|
|
+ driverCardEdit(driverCardDto);
|
|
|
+ }
|
|
|
|
|
|
/**司机驾驶证信息**/
|
|
|
- params.getDriverLicense().setDriverId(params.getId());
|
|
|
- driverLicenseEdit(params.getDriverLicense());
|
|
|
+ KwfDriverLicenseDto driverLicenseDto = params.getDriverLicense();
|
|
|
+ if (driverLicenseDto != null) {
|
|
|
+ driverLicenseDto.setDriverId(String.valueOf(driver.getId()));
|
|
|
+ driverLicenseEdit(driverLicenseDto);
|
|
|
+ }
|
|
|
|
|
|
/**司机从业资格证**/
|
|
|
- params.getDriverQualification().setDriverId(params.getId());
|
|
|
- driverQualificationEdit(params.getDriverQualification());
|
|
|
- return HttpResult.ok("司机信息新增成功!");
|
|
|
+ KwfDriverQualificationDto driverQualificationDto = params.getDriverQualification();
|
|
|
+ if (driverQualificationDto != null) {
|
|
|
+ driverQualificationDto.setDriverId(String.valueOf(driver.getId()));
|
|
|
+ driverQualificationEdit(driverQualificationDto);
|
|
|
+ }
|
|
|
+ return HttpResult.ok("司机信息修改成功!");
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -155,14 +180,14 @@ public class KwfDriverService {
|
|
|
|
|
|
/**数据组装**/
|
|
|
String[] idArray = ids.split(",");
|
|
|
- KwfDriver driverQuery = new KwfDriver();
|
|
|
- driverQuery.setEntId(LoginUserHolder.getEntId());
|
|
|
+ KwfDriverEnt driverEntQuery = new KwfDriverEnt();
|
|
|
+ driverEntQuery.setEntId(LoginUserHolder.getEntId());
|
|
|
for (String id : idArray) {
|
|
|
- driverQuery.setId(Long.parseLong(id));
|
|
|
- KwfDriver driver = driverDao.findEntDriver(driverQuery);
|
|
|
- if (driver != null) {
|
|
|
- driver.setDelFlag(Global.YES);
|
|
|
- if (driverDao.updateById(driver) <= 0) {
|
|
|
+ driverEntQuery.setDriverId(Long.parseLong(id));
|
|
|
+ KwfDriverEnt driverEnt = driverEntDao.findByDriverEnt(driverEntQuery);
|
|
|
+ if (driverEnt != null) {
|
|
|
+ driverEnt.setDelFlag(Global.YES);
|
|
|
+ if (driverEntDao.updateById(driverEnt) <= 0) {
|
|
|
throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.DELETE_FAIL);
|
|
|
}
|
|
|
}
|
|
|
@@ -190,8 +215,9 @@ public class KwfDriverService {
|
|
|
params.setSalt(PasswordUtils.getSaltSubPwd(password));
|
|
|
params.setPassword(password);
|
|
|
params.setEntId(LoginUserHolder.getEntId());
|
|
|
+ params.setEntId(params.getEntId() == null ? 1 : params.getEntId());// 暂时处理---------------zk
|
|
|
int count = driverDao.insert(params);
|
|
|
- return count > 0 ? null : HttpResult.error("司机信息新增失败!");
|
|
|
+ return count > 0 ? HttpResult.ok() : HttpResult.error("司机信息新增失败!");
|
|
|
} else {
|
|
|
/**唯一性交易**/
|
|
|
List<Map<String, Object>> drivers = driverDao.findList(new HashMap(){{ put("phone", params.getPhone()); }});
|
|
|
@@ -203,7 +229,7 @@ public class KwfDriverService {
|
|
|
|
|
|
/**更新**/
|
|
|
int count = driverDao.updateById(params);
|
|
|
- return count > 0 ? null : HttpResult.error("司机信息修改失败!");
|
|
|
+ return count > 0 ? HttpResult.ok() : HttpResult.error("司机信息修改失败!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -222,11 +248,12 @@ public class KwfDriverService {
|
|
|
KwfDriverCard card = KwfDriverCardDao.findByDriverId(params.getDriverId());
|
|
|
if (card == null) {
|
|
|
int count = KwfDriverCardDao.insert(driverCard);
|
|
|
+ return count > 0 ? HttpResult.ok("身份证信息更新成功!") : HttpResult.error("身份证信息更新失败!");
|
|
|
} else {
|
|
|
driverCard.setId(card.getId());
|
|
|
int count = KwfDriverCardDao.updateById(driverCard);
|
|
|
+ return count > 0 ? HttpResult.ok("身份证信息修改成功!") : HttpResult.error("身份证信息修改失败!");
|
|
|
}
|
|
|
- return null;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -254,11 +281,12 @@ public class KwfDriverService {
|
|
|
KwfDriverLicense license = KwfDriverLicenseDao.findByDriverId(params.getDriverId());
|
|
|
if (license == null) {
|
|
|
int 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("司机驾驶证信息修改失败!");
|
|
|
}
|
|
|
- return null;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -286,11 +314,12 @@ public class KwfDriverService {
|
|
|
KwfDriverQualification qualification = KwfDriverQualificationDao.findByDriverId(params.getDriverId());
|
|
|
if (qualification == null) {
|
|
|
int count = KwfDriverQualificationDao.insert(driverQual);
|
|
|
+ return count > 0 ? HttpResult.ok("司机从业资格证信息更新成功!") : HttpResult.error("司机从业资格证信息更新失败!");
|
|
|
} else {
|
|
|
driverQual.setId(qualification.getId());
|
|
|
int count = KwfDriverQualificationDao.updateById(driverQual);
|
|
|
+ return count > 0 ? HttpResult.ok("司机从业资格证信息修改成功!") : HttpResult.error("司机从业资格证信息修改失败!");
|
|
|
}
|
|
|
- return null;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -310,12 +339,10 @@ public class KwfDriverService {
|
|
|
* @date 2023/7/7
|
|
|
**/
|
|
|
public void driverEntEdit(KwfDriver params) {
|
|
|
- if (StringUtils.isBlank(params.getId())) {
|
|
|
- KwfDriverEnt driverEnt = new KwfDriverEnt();
|
|
|
- driverEnt.setDriverId(params.getId());
|
|
|
- driverEnt.setEntId(params.getEntId());
|
|
|
- driverEntDao.insert(driverEnt);
|
|
|
- }
|
|
|
+ KwfDriverEnt driverEnt = new KwfDriverEnt();
|
|
|
+ driverEnt.setDriverId(params.getId());
|
|
|
+ driverEnt.setEntId(params.getEntId());
|
|
|
+ driverEntDao.insert(driverEnt);
|
|
|
}
|
|
|
|
|
|
}
|