|
@@ -36,12 +36,16 @@ import com.pj.current.satoken.StpUserUtil;
|
|
|
import com.pj.current.task.TaskService;
|
|
|
import com.pj.project.tb_car_filing.TbCarFiling;
|
|
|
import com.pj.project.tb_car_filing.TbCarFilingService;
|
|
|
+import com.pj.project.tb_department.TbDepartment;
|
|
|
+import com.pj.project.tb_department.TbDepartmentService;
|
|
|
import com.pj.project.tb_dept.TbDept;
|
|
|
import com.pj.project.tb_dept.TbDeptService;
|
|
|
import com.pj.project.tb_person_black.TbPersonBlack;
|
|
|
import com.pj.project.tb_person_filing.task.DelayIsuuedList;
|
|
|
import com.pj.project.tb_terminal.TbTerminal;
|
|
|
import com.pj.project.tb_terminal.TbTerminalService;
|
|
|
+import com.pj.project.tb_venues.TbVenues;
|
|
|
+import com.pj.project.tb_venues.TbVenuesService;
|
|
|
import com.pj.project4sp.spcfg.SpCfgUtil;
|
|
|
import com.pj.project4sp.uploadfile.UploadConfig;
|
|
|
import com.pj.project4sp.uploadfile.UploadUtil;
|
|
@@ -90,6 +94,9 @@ public class TbPersonFilingService extends ServiceImpl<TbPersonFilingMapper, TbP
|
|
|
@Lazy
|
|
|
private TbCarFilingService tbCarFilingService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private TbVenuesService tbVenuesService;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 增
|
|
@@ -105,25 +112,27 @@ public class TbPersonFilingService extends ServiceImpl<TbPersonFilingMapper, TbP
|
|
|
}
|
|
|
t.setPin(idCard);
|
|
|
TbDept tbDept = tbDeptService.getById(t.getDeptId());
|
|
|
- if (TbDept.NeedJudgeEnum.AUTO_JUDGE.getType().equals(tbDept.getNeedJudge())) {
|
|
|
+ if (tbDept!=null&&TbDept.NeedJudgeEnum.AUTO_JUDGE.getType().equals(tbDept.getNeedJudge())) {
|
|
|
t.setJudgeState(1).setJudgeTime(new Date()).setJudgeBy("系统自动审核");
|
|
|
}
|
|
|
- t.setCreateTime(new Date()).setCreateBy(StpUserUtil.getAdminName());
|
|
|
+ TbVenues tbVenues = tbVenuesService.getById(t.getVenuesId());
|
|
|
+ t.setDepartmentId(tbVenues.getDepartmentId());
|
|
|
this.save(t);
|
|
|
issued(t);
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 删
|
|
|
*/
|
|
|
public void delete(Integer id) {
|
|
|
TbPersonFiling db = this.getById(id);
|
|
|
- TbCarFiling tbCarFiling = tbCarFilingService.findByDriverIdCar(db.getIdCard());
|
|
|
- if (tbCarFiling == null || tbCarFiling.getJudgeState() == 0) {//车辆司机不存在或者未审核,删除备案
|
|
|
- deleteTerminalWhilte(db.getPin(), true);
|
|
|
- }
|
|
|
+ List<TbCarFiling> tbCarFilingList = tbCarFilingService.findByDriverIdCar(db.getIdCard());
|
|
|
+ tbCarFilingList.forEach(tbCarFiling -> {
|
|
|
+ if (tbCarFiling.getJudgeState() == 0) {//车辆司机不存在或者未审核,删除备案
|
|
|
+ deleteTerminalWhilte(db.getPin(), true);
|
|
|
+ }
|
|
|
+ });
|
|
|
this.removeById(id);
|
|
|
}
|
|
|
|
|
@@ -153,7 +162,8 @@ public class TbPersonFilingService extends ServiceImpl<TbPersonFilingMapper, TbP
|
|
|
//下发新的
|
|
|
issued(t);
|
|
|
}
|
|
|
-
|
|
|
+ TbVenues tbVenues = tbVenuesService.getById(t.getVenuesId());
|
|
|
+ t.setDepartmentId(tbVenues.getDepartmentId());
|
|
|
this.updateById(t);
|
|
|
}
|
|
|
|
|
@@ -184,7 +194,7 @@ public class TbPersonFilingService extends ServiceImpl<TbPersonFilingMapper, TbP
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 下发单个白名单到所有设备
|
|
|
+ * 下发单个白名单到设备
|
|
|
*
|
|
|
* @param filing
|
|
|
*/
|
|
@@ -193,7 +203,12 @@ public class TbPersonFilingService extends ServiceImpl<TbPersonFilingMapper, TbP
|
|
|
log.error("人员白名单未审核通过,不下发:{}", JSONUtil.toJsonStr(filing));
|
|
|
return;
|
|
|
}
|
|
|
- List<TbTerminal> tbTerminalList = tbTerminalService.list();
|
|
|
+ //备案场所
|
|
|
+ Long venuesId = filing.getVenuesId();
|
|
|
+ TbVenues tbVenues = tbVenuesService.getById(venuesId);
|
|
|
+ //下发到等级比自己低或者同等级的场所设备
|
|
|
+ Integer level = tbVenues.getLevel();
|
|
|
+ List<TbTerminal> tbTerminalList = tbTerminalService.findByVenuesLevel(level);
|
|
|
JSONObject params = builderParams(filing);
|
|
|
tbTerminalList.forEach(tbTerminal -> {
|
|
|
tbTerminalService.setCommand(CommandType.ISSUED_USER_COMMAND.getFuncId(), params, tbTerminal);
|
|
@@ -213,7 +228,7 @@ public class TbPersonFilingService extends ServiceImpl<TbPersonFilingMapper, TbP
|
|
|
log.error("人员白名单未审核通过,不下发:{}", JSONUtil.toJsonStr(filing));
|
|
|
return;
|
|
|
}
|
|
|
- List<TbTerminal> tbTerminalList = tbTerminalService.list();
|
|
|
+ List<TbTerminal> tbTerminalList = tbTerminalService.findByVenuesId(filing.getVenuesId());
|
|
|
log.info("排除设备下发人脸信息:{},{}", sn, JSONUtil.toJsonStr(filing));
|
|
|
JSONObject params = builderParams(filing);
|
|
|
tbTerminalList.stream().filter(t -> !StrUtil.equals(t.getSn(), sn)).forEach(tbTerminal -> {
|
|
@@ -224,12 +239,20 @@ public class TbPersonFilingService extends ServiceImpl<TbPersonFilingMapper, TbP
|
|
|
|
|
|
|
|
|
/**
|
|
|
- * 下发所有人员白名单到单个设备
|
|
|
+ * 下发人员白名单到单个设备
|
|
|
*
|
|
|
* @param t
|
|
|
*/
|
|
|
public void issued(TbTerminal t) {
|
|
|
- List<TbPersonFiling> list = this.list();
|
|
|
+ Long channelId = t.getChannelId();
|
|
|
+ //通道
|
|
|
+ TbVenues channel = tbVenuesService.getById(channelId);
|
|
|
+ //场所
|
|
|
+ TbVenues venues = tbVenuesService.getById(channel.getPId());
|
|
|
+ List<TbVenues> hightVenuesList = tbVenuesService.getHightLevel(venues.getLevel());
|
|
|
+ List<TbVenues> venuesList = new ArrayList<>(hightVenuesList);
|
|
|
+ venuesList.add(venues);
|
|
|
+ List<TbPersonFiling> list = this.findByVenuesId(venuesList.stream().map(TbVenues::getId).collect(Collectors.toList()));
|
|
|
//过滤审核通过的
|
|
|
list = list.stream().filter(tbPersonFiling -> tbPersonFiling.getJudgeState() == 1).collect(Collectors.toList());
|
|
|
list.forEach(tbPersonFiling -> {
|
|
@@ -239,10 +262,46 @@ public class TbPersonFilingService extends ServiceImpl<TbPersonFilingMapper, TbP
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 根据场所查找备案人员
|
|
|
+ *
|
|
|
+ * @param venuesId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<TbPersonFiling> findByVenuesId(Long venuesId) {
|
|
|
+ QueryWrapper<TbPersonFiling> ew = new QueryWrapper<>();
|
|
|
+ ew.lambda().eq(TbPersonFiling::getVenuesId, venuesId);
|
|
|
+ return list(ew);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据场所id上查找
|
|
|
+ *
|
|
|
+ * @param venuesIdList
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<TbPersonFiling> findByVenuesId(List<Long> venuesIdList) {
|
|
|
+ if (venuesIdList.isEmpty()) {
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
+ QueryWrapper<TbPersonFiling> ew = new QueryWrapper<>();
|
|
|
+ ew.lambda().in(TbPersonFiling::getVenuesId, venuesIdList);
|
|
|
+ return list(ew);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 删除设备某个人的白名单
|
|
|
*/
|
|
|
public void deleteTerminalWhilte(String pin, boolean setHeart) {
|
|
|
- List<TbTerminal> tbTerminalList = tbTerminalService.list();
|
|
|
+ TbPersonFiling filing = this.findByPin(pin);
|
|
|
+ if (filing==null){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //备案场所
|
|
|
+ Long venuesId = filing.getVenuesId();
|
|
|
+ TbVenues tbVenues = tbVenuesService.getById(venuesId);
|
|
|
+ //删除级比自己低或者同等级的场所设备
|
|
|
+ Integer level = tbVenues.getLevel();
|
|
|
+ List<TbTerminal> tbTerminalList = tbTerminalService.findByVenuesLevel(level);
|
|
|
JSONObject params = new JSONObject();
|
|
|
params.putIfAbsent("pin", Collections.singleton(pin));
|
|
|
tbTerminalList.forEach(tbTerminal -> {
|
|
@@ -301,6 +360,9 @@ public class TbPersonFilingService extends ServiceImpl<TbPersonFilingMapper, TbP
|
|
|
*/
|
|
|
public void judge(TbPersonFiling filing) {
|
|
|
TbPersonFiling db = this.getById(filing.getId());
|
|
|
+ if (db.getVenuesId()==null){
|
|
|
+ throw new AjaxError("请先选择备案场所");
|
|
|
+ }
|
|
|
db.setJudgeBy(StpUserUtil.getAdminName()).setJudgeTime(new Date()).setJudgeState(filing.getJudgeState());
|
|
|
this.updateById(db);
|
|
|
if (StrUtil.isNotEmpty(db.getPhoto())) {
|
|
@@ -414,14 +476,17 @@ public class TbPersonFilingService extends ServiceImpl<TbPersonFilingMapper, TbP
|
|
|
* @param list
|
|
|
*/
|
|
|
public void isuuedList(List<TbPersonFiling> list) {
|
|
|
- List<TbTerminal> tbTerminalList = tbTerminalService.list();
|
|
|
- tbTerminalList.stream().parallel().forEach(tbTerminal -> {
|
|
|
- list.forEach(tbPersonFiling -> {
|
|
|
- JSONObject params = builderParams(tbPersonFiling);
|
|
|
- tbTerminalService.setCommand(CommandType.ISSUED_USER_COMMAND.getFuncId(), params, tbTerminal);
|
|
|
- });
|
|
|
- tbTerminalService.startHeartCommand(tbTerminal.getSn());
|
|
|
- });
|
|
|
+ list.stream().collect(Collectors.groupingBy(TbPersonFiling::getVenuesId))
|
|
|
+ .forEach((venuesId, venuesList) -> {
|
|
|
+ List<TbTerminal> tbTerminalList = tbTerminalService.findByVenuesId(venuesId);
|
|
|
+ tbTerminalList.stream().parallel().forEach(tbTerminal -> {
|
|
|
+ list.forEach(tbPersonFiling -> {
|
|
|
+ JSONObject params = builderParams(tbPersonFiling);
|
|
|
+ tbTerminalService.setCommand(CommandType.ISSUED_USER_COMMAND.getFuncId(), params, tbTerminal);
|
|
|
+ });
|
|
|
+ tbTerminalService.startHeartCommand(tbTerminal.getSn());
|
|
|
+ });
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -436,4 +501,21 @@ public class TbPersonFilingService extends ServiceImpl<TbPersonFilingMapper, TbP
|
|
|
}
|
|
|
issued(tbPersonFiling);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 下发到某场所及其等级低于等于场所的 设备
|
|
|
+ *
|
|
|
+ * @param tbVenues
|
|
|
+ * @param personFilings
|
|
|
+ */
|
|
|
+ public void issued(TbVenues tbVenues, List<TbPersonFiling> personFilings) {
|
|
|
+ List<TbTerminal> list = tbTerminalService.findByVenuesLevel(tbVenues.getLevel());
|
|
|
+ list.stream().parallel().forEach(tbTerminal -> {
|
|
|
+ personFilings.forEach(tbPersonFiling -> {
|
|
|
+ JSONObject params = builderParams(tbPersonFiling);
|
|
|
+ tbTerminalService.setCommand(CommandType.ISSUED_USER_COMMAND.getFuncId(), params, tbTerminal);
|
|
|
+ });
|
|
|
+ tbTerminalService.startHeartCommand(tbTerminal.getSn());
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|