|
@@ -1,16 +1,24 @@
|
|
|
package com.pj.project.tb_car_filing;
|
|
|
|
|
|
+import java.io.File;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
import cn.dev33.satoken.stp.StpUtil;
|
|
|
+import cn.hutool.core.codec.Base64Encoder;
|
|
|
+import cn.hutool.core.io.FileUtil;
|
|
|
import cn.hutool.core.util.IdcardUtil;
|
|
|
import cn.hutool.core.util.RandomUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
+import cn.hutool.json.JSONObject;
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.IService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.pj.current.config.SystemObject;
|
|
|
import com.pj.current.global.BusinessException;
|
|
|
+import com.pj.current.netty.command.constants.CommandType;
|
|
|
+import com.pj.current.netty.command.handler.dto.WhitelistDTO;
|
|
|
import com.pj.current.satoken.StpUserUtil;
|
|
|
import com.pj.project.tb_car_black.TbCarBlack;
|
|
|
import com.pj.project.tb_car_black.TbCarBlackService;
|
|
@@ -18,7 +26,11 @@ import com.pj.project.tb_dept.TbDept;
|
|
|
import com.pj.project.tb_dept.TbDeptService;
|
|
|
import com.pj.project.tb_person_filing.TbPersonFiling;
|
|
|
import com.pj.project.tb_person_filing.TbPersonFilingService;
|
|
|
+import com.pj.project.tb_terminal.TbTerminal;
|
|
|
+import com.pj.project.tb_terminal.TbTerminalService;
|
|
|
import com.pj.project4sp.spcfg.SpCfgUtil;
|
|
|
+import com.pj.project4sp.uploadfile.UploadConfig;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -33,6 +45,7 @@ import javax.annotation.Resource;
|
|
|
*/
|
|
|
@Service
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
+@Slf4j
|
|
|
public class TbCarFilingService extends ServiceImpl<TbCarFilingMapper, TbCarFiling> implements IService<TbCarFiling> {
|
|
|
|
|
|
/**
|
|
@@ -47,12 +60,16 @@ public class TbCarFilingService extends ServiceImpl<TbCarFilingMapper, TbCarFili
|
|
|
private TbPersonFilingService tbPersonFilingService;
|
|
|
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* 增
|
|
|
*/
|
|
|
public void add(TbCarFiling t) {
|
|
|
String carNo = t.getCarNo().toUpperCase();
|
|
|
String idCarNo = t.getDriverIdCard();
|
|
|
+ if (!IdcardUtil.isValidCard(t.getDriverIdCard())) {
|
|
|
+ throw new BusinessException("身份证不正确");
|
|
|
+ }
|
|
|
//原来是否录入过
|
|
|
TbCarFiling checkFiling = this.findByDriverIdCar(idCarNo);
|
|
|
if (checkFiling != null) {
|
|
@@ -62,41 +79,45 @@ public class TbCarFilingService extends ServiceImpl<TbCarFilingMapper, TbCarFili
|
|
|
if (carNoCheckFiling != null) {
|
|
|
throw new BusinessException("车辆已备案");
|
|
|
}
|
|
|
- String needJudge = SpCfgUtil.getFillingJudge();
|
|
|
- if (StrUtil.equals(needJudge, "2")) {
|
|
|
- t.setJudgeState(1).setJudgeTime(new Date()).setJudgeBy("系统自动审核");
|
|
|
- }
|
|
|
- t.setCreateBy(StpUtil.getLoginIdAsString()).setCarNo(carNo)
|
|
|
- .setCreateTime(new Date());
|
|
|
- handler(t);
|
|
|
- this.handlerDriver(t);
|
|
|
+ t.setCarNo(carNo);
|
|
|
+ handlerDriver(t);
|
|
|
this.save(t);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 处理备案司机
|
|
|
+ *
|
|
|
* @param tbCarFiling
|
|
|
*/
|
|
|
private void handlerDriver(TbCarFiling tbCarFiling) {
|
|
|
String idCarNo = tbCarFiling.getDriverIdCard();
|
|
|
//人员是否备案
|
|
|
TbPersonFiling t = tbPersonFilingService.findByIdCard(idCarNo);
|
|
|
- Date now = new Date();
|
|
|
+ Long deptId = tbCarFiling.getDeptId();
|
|
|
+ TbDept tbDept = tbDeptService.getById(deptId);
|
|
|
+ tbCarFiling.setDeptName(tbDept.getName());
|
|
|
+ boolean judge = TbDept.NeedJudgeEnum.AUTO_JUDGE.getType().equals(tbDept.getNeedJudge());
|
|
|
+ if (judge) {
|
|
|
+ tbCarFiling.setJudgeState(1).setJudgeTime(new Date()).setJudgeBy("系统自动审核");
|
|
|
+ }
|
|
|
if (t == null) {
|
|
|
- // String pin = RandomUtil.randomNumbers(9);
|
|
|
- String pin=tbCarFiling.getDriverIdCard();
|
|
|
+ String pin = tbCarFiling.getDriverIdCard();
|
|
|
tbCarFiling.setDriverPin(pin);
|
|
|
t = new TbPersonFiling();
|
|
|
- t.setDeptId(tbCarFiling.getDeptId()).setPhoto(tbCarFiling.getDriverPhoto()).setPin(pin)
|
|
|
- .setIdCard(tbCarFiling.getDriverIdCard()).setName(tbCarFiling.getDriverName())
|
|
|
- .setPhone(tbCarFiling.getDriverPhoto()).setPin(tbCarFiling.getDriverPin());
|
|
|
- String needJudge = SpCfgUtil.getFillingJudge();
|
|
|
- if (StrUtil.equals(needJudge, "2")) {
|
|
|
- t.setJudgeState(1).setJudgeTime(now).setJudgeBy("系统自动审核");
|
|
|
+ t.setDeptId(tbDept.getId())
|
|
|
+ .setPhoto(tbCarFiling.getDriverPhoto())
|
|
|
+ .setDeptName(tbDept.getName())
|
|
|
+ .setType(tbCarFiling.getType())
|
|
|
+ .setPin(idCarNo)
|
|
|
+ .setIdCard(tbCarFiling.getDriverIdCard())
|
|
|
+ .setName(tbCarFiling.getDriverName())
|
|
|
+ .setPhone(tbCarFiling.getDriverContact());
|
|
|
+ if (judge) {
|
|
|
+ t.setJudgeState(1).setJudgeTime(new Date()).setJudgeBy("系统自动审核");
|
|
|
+ // todo 下发人脸到设备
|
|
|
+ tbPersonFilingService.issued(t);
|
|
|
}
|
|
|
- //下发司机白名单
|
|
|
- tbPersonFilingService.issued(t);
|
|
|
- } else {
|
|
|
- tbCarFiling.setDriverPin(t.getIdCard());
|
|
|
+ tbPersonFilingService.save(t);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -112,21 +133,6 @@ public class TbCarFilingService extends ServiceImpl<TbCarFilingMapper, TbCarFili
|
|
|
return getOne(ew);
|
|
|
}
|
|
|
|
|
|
- private void handler(TbCarFiling t) {
|
|
|
- if (!IdcardUtil.isValidCard(t.getDriverIdCard())) {
|
|
|
- // throw new BusinessException("身份证不正确");
|
|
|
- }
|
|
|
- TbDept tbDept = tbDeptService.getById(t.getDeptId());
|
|
|
- if (tbDept == null) {
|
|
|
- throw new BusinessException("请选择组织");
|
|
|
- }
|
|
|
- String carNo = t.getCarNo().toUpperCase();
|
|
|
- Date now = new Date();
|
|
|
- t.setDeptName(tbDept.getName()).setUpdateTime(now).setCarNo(carNo)
|
|
|
- .setUpdateBy(StpUtil.getLoginIdAsString());
|
|
|
- t.setCarNo(t.getCarNo().toUpperCase());
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
/**
|
|
|
* 删
|
|
@@ -138,7 +144,7 @@ public class TbCarFilingService extends ServiceImpl<TbCarFilingMapper, TbCarFili
|
|
|
//如果不存在白名单,则
|
|
|
if (tbPersonFiling == null) {
|
|
|
//删除设备的白名单
|
|
|
- tbPersonFilingService.deleteTerminalWhilte(db.getDriverPin());
|
|
|
+ tbPersonFilingService.deleteTerminalWhilte(db.getDriverPin(), true);
|
|
|
}
|
|
|
this.removeById(id);
|
|
|
}
|
|
@@ -147,25 +153,41 @@ public class TbCarFilingService extends ServiceImpl<TbCarFilingMapper, TbCarFili
|
|
|
* 改
|
|
|
*/
|
|
|
public void update(TbCarFiling t) {
|
|
|
- handler(t);
|
|
|
- String carNo = t.getCarNo();
|
|
|
+ String carNo = t.getCarNo().toUpperCase();
|
|
|
TbCarFiling carNoCheck = this.findByCarNo(carNo);
|
|
|
if (carNoCheck != null && t.getId().longValue() != carNoCheck.getId().longValue()) {
|
|
|
throw new BusinessException("车辆已备案");
|
|
|
}
|
|
|
TbCarFiling db = this.getById(t.getId());
|
|
|
+ if (!t.getDeptId().equals(db.getDeptId())) {
|
|
|
+ TbDept tbDept = tbDeptService.getById(t.getDeptId());
|
|
|
+ t.setDeptName(tbDept.getName());
|
|
|
+ }
|
|
|
String idCarNo = t.getDriverIdCard();
|
|
|
- //改了身份证
|
|
|
- if (!StrUtil.equals(idCarNo, db.getDriverIdCard())) {
|
|
|
+ String oldIdCardNo = db.getDriverIdCard();
|
|
|
+ //改了身份证或者人脸或者姓名
|
|
|
+ if (!StrUtil.equals(idCarNo, oldIdCardNo)
|
|
|
+ || !StrUtil.equals(t.getDriverPhoto(), db.getDriverPhoto())
|
|
|
+ || !StrUtil.equals(t.getDriverName(), db.getDriverName())
|
|
|
+ ) {
|
|
|
//原来是否录入过
|
|
|
TbCarFiling checkFiling = this.findByDriverIdCar(idCarNo);
|
|
|
if (checkFiling != null) {
|
|
|
throw new BusinessException("司机已备案其他车辆");
|
|
|
}
|
|
|
+ //更改备案人信息
|
|
|
+ TbPersonFiling tbPersonFiling = tbPersonFilingService.findByIdCard(oldIdCardNo);
|
|
|
+ if (tbPersonFiling != null) {
|
|
|
+ tbPersonFiling.setIdCard(idCarNo)
|
|
|
+ .setName(t.getDriverName())
|
|
|
+ .setPhone(t.getDriverContact());
|
|
|
+ tbPersonFilingService.updateById(tbPersonFiling);
|
|
|
+ }
|
|
|
//司机身份证不一样 删除旧的,下发新的
|
|
|
- tbPersonFilingService.deleteTerminalWhilte(db.getDriverPin());
|
|
|
- this.handlerDriver(t);
|
|
|
+ tbPersonFilingService.deleteTerminalWhilte(db.getDriverIdCard(), false);
|
|
|
+ tbPersonFilingService.issued(idCarNo);
|
|
|
}
|
|
|
+ t.setCarNo(t.getCarNo().toUpperCase());
|
|
|
this.updateById(t);
|
|
|
}
|
|
|
|
|
@@ -191,9 +213,17 @@ public class TbCarFilingService extends ServiceImpl<TbCarFilingMapper, TbCarFili
|
|
|
return list.isEmpty() ? null : list.get(0);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 审核
|
|
|
+ *
|
|
|
+ * @param t
|
|
|
+ */
|
|
|
public void judge(TbCarFiling t) {
|
|
|
- t.setJudgeTime(new Date()).setJudgeBy(StpUserUtil.getAdminName());
|
|
|
- this.updateById(t);
|
|
|
+ TbCarFiling db=this.getById(t.getId());
|
|
|
+ db.setJudgeTime(new Date()).setJudgeBy(StpUserUtil.getAdminName()).setJudgeState(t.getJudgeState());
|
|
|
+ this.updateById(db);
|
|
|
+ //人员备案审核
|
|
|
+ tbPersonFilingService.judgeByIdCard(db.getDriverIdCard(), db.getJudgeState());
|
|
|
}
|
|
|
|
|
|
public List<TbCarFiling> getForWx(SoMap soMap) {
|
|
@@ -204,4 +234,6 @@ public class TbCarFilingService extends ServiceImpl<TbCarFilingMapper, TbCarFili
|
|
|
public List<TbCarFiling> getOuterList(SoMap soMap) {
|
|
|
return tbCarFilingMapper.getOuterList(soMap);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
}
|