中水北方修改

This commit is contained in:
pengjie 2025-07-11 18:18:24 +08:00
parent cc6ddce242
commit 389ffcd285
10 changed files with 641 additions and 0 deletions

View File

@ -229,6 +229,8 @@ public class ProjectUfaceConfigServiceImpl extends ServiceImpl<ProjectUfaceConfi
} else if (Objects.equals(ufaceConfig.getSupplierType(), SLINGSHOT.getCode())) {
//保存弹弓下发状态
dangongWorkerFaceStatusService.deleteStatus(workerInfo);
} else if (Objects.equals(ufaceConfig.getSupplierType(), MQTT.getCode())) {
MqttFaceDevUtil.deletePerson(workerInfo, workerInfo.getUfaceDevId());
}
}
}
@ -311,6 +313,9 @@ public class ProjectUfaceConfigServiceImpl extends ServiceImpl<ProjectUfaceConfi
} else if (Objects.equals(ufaceConfig.getSupplierType(), SLINGSHOT.getCode())) {
//保存弹弓下发状态
dangongWorkerFaceStatusService.saveStatus(workerInfo);
} else if (Objects.equals(ufaceConfig.getSupplierType(), MQTT.getCode())) {
//保存弹弓下发状态
MqttFaceDevUtil.addOrUpdatePerson(workerInfo, devBuilder.toString());
}
}
}
@ -500,6 +505,9 @@ public class ProjectUfaceConfigServiceImpl extends ServiceImpl<ProjectUfaceConfi
} else if (Objects.equals(ufaceConfig.getSupplierType(), SLINGSHOT.getCode())) {
//保存弹弓下发状态
dangongWorkerFaceStatusService.saveStatus(workerInfo);
} else if (Objects.equals(ufaceConfig.getSupplierType(), MQTT.getCode())) {
// mqtt下发人员
MqttFaceDevUtil.addOrUpdatePerson(workerInfo, devSns);
}
}

View File

@ -0,0 +1,285 @@
package com.zhgd.xmgl.modules.worker.controller;
import com.zhgd.annotation.OperLog;
import com.zhgd.xmgl.security.util.SecurityUtils;
import com.zhgd.xmgl.util.PageUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.zhgd.jeecg.common.api.vo.Result;
import com.zhgd.jeecg.common.system.query.QueryGenerator;
import com.zhgd.jeecg.common.util.oConvertUtils;
import com.zhgd.xmgl.modules.worker.entity.RegionViolation;
import com.zhgd.xmgl.modules.worker.service.IRegionViolationService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.MapUtils;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;
import com.alibaba.fastjson.JSON;
import springfox.documentation.annotations.ApiIgnore;
/**
* @Title: Controller
* @Description: 中水北方区域违规记录
* @author pengj
* @date 2025-07-10
* @version V1.0
*/
@RestController
@RequestMapping("/xmgl/regionViolation")
@Slf4j
@Api(tags = "中水北方区域违规记录管理")
public class RegionViolationController {
@Autowired
private IRegionViolationService regionViolationService;
/**
* 分页列表查询
*
* @return
*/
@OperLog(operModul = "中水北方区域违规记录管理", operType = "分页查询", operDesc = "分页列表查询中水北方区域违规记录信息")
@ApiOperation(value = " 分页列表查询中水北方区域违规记录信息", notes = "分页列表查询中水北方区域违规记录信息", httpMethod = "POST")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNo", value = "页数", paramType = "body", required = true, defaultValue = "1", dataType = "Integer"),
@ApiImplicitParam(name = "pageSize", value = "每页条数", paramType = "body", required = true, defaultValue = "10", dataType = "Integer")
})
@PostMapping(value = "/page")
public Result<IPage<RegionViolation>> queryPageList(@ApiIgnore @RequestBody Map<String, Object> map) {
QueryWrapper<RegionViolation> queryWrapper = QueryGenerator.initPageQueryWrapper(RegionViolation.class, map);
Page<RegionViolation> page = PageUtil.getPage(map);
IPage<RegionViolation> pageList = regionViolationService.page(page, queryWrapper);
return Result.success(pageList);
}
/**
* 列表查询
*
* @param regionViolation
* @return
*/
@OperLog(operModul = "中水北方区域违规记录管理", operType = "列表查询", operDesc = "列表查询中水北方区域违规记录信息")
@ApiOperation(value = " 列表查询中水北方区域违规记录信息", notes = "列表查询中水北方区域违规记录信息", httpMethod = "POST")
@PostMapping(value = "/list")
public Result<List<RegionViolation>> queryList(@RequestBody RegionViolation regionViolation) {
QueryWrapper<RegionViolation> queryWrapper = QueryGenerator.initQueryWrapper(regionViolation);
List<RegionViolation> list = regionViolationService.list(queryWrapper);
return Result.success(list);
}
/**
* 添加
*
* @param regionViolation
* @return
*/
@OperLog(operModul = "中水北方区域违规记录管理", operType = "新增", operDesc = "添加中水北方区域违规记录信息")
@ApiOperation(value = " 添加中水北方区域违规记录信息", notes = "添加中水北方区域违规记录信息", httpMethod = "POST")
@PostMapping(value = "/add")
public Result<Object> add(@RequestBody RegionViolation regionViolation) {
Result<RegionViolation> result = new Result<RegionViolation>();
regionViolationService.save(regionViolation);
return Result.success("添加成功!");
}
/**
* 编辑
*
* @param regionViolation
* @return
*/
@OperLog(operModul = "中水北方区域违规记录管理", operType = "修改", operDesc = "编辑中水北方区域违规记录信息")
@ApiOperation(value = "编辑中水北方区域违规记录信息", notes = "编辑中水北方区域违规记录信息", httpMethod = "POST")
@PostMapping(value = "/edit")
public Result<RegionViolation> edit(@RequestBody RegionViolation regionViolation) {
Result<RegionViolation> result = new Result<RegionViolation>();
RegionViolation regionViolationEntity = regionViolationService.getById(regionViolation.getId());
if (regionViolationEntity == null) {
result.error500("未找到对应实体");
} else {
boolean ok = regionViolationService.updateById(regionViolation);
if (ok) {
result.success("修改成功!");
} else {
result.success("操作失败!");
}
}
return result;
}
/**
* 通过id删除
*
* @return
*/
@OperLog(operModul = "中水北方区域违规记录管理", operType = "删除", operDesc = "删除中水北方区域违规记录信息")
@ApiOperation(value = "删除中水北方区域违规记录信息", notes = "删除中水北方区域违规记录信息", httpMethod = "POST")
@ApiImplicitParam(name = "id", value = "中水北方区域违规记录ID", paramType = "body", required = true, dataType = "Integer")
@PostMapping(value = "/delete")
public Result<RegionViolation> delete(@RequestBody RegionViolation regionViolation) {
Result<RegionViolation> result = new Result<RegionViolation>();
RegionViolation regionViolationEntity = regionViolationService.getById(regionViolation.getId());
if (regionViolationEntity == null) {
result.error500("未找到对应实体");
} else {
boolean ok = regionViolationService.removeById(regionViolation.getId());
if (ok) {
result.success("删除成功!");
} else {
result.success("操作失败!");
}
}
return result;
}
/**
* 批量删除
*
* @return
*/
@OperLog(operModul = "中水北方区域违规记录管理", operType = "批量删除", operDesc = "批量删除中水北方区域违规记录信息")
@ApiOperation(value = "批量删除中水北方区域违规记录信息", notes = "批量删除中水北方区域违规记录信息", httpMethod = "POST")
@ApiImplicitParam(name = "ids", value = "中水北方区域违规记录ID字符串", paramType = "body", required = true, dataType = "String")
@PostMapping(value = "/deleteBatch")
public Result<RegionViolation> deleteBatch(@ApiIgnore @RequestBody Map<String, Object> map) {
Result<RegionViolation> result = new Result<RegionViolation>();
String ids = MapUtils.getString(map, "ids");
if (ids == null || "".equals(ids.trim())) {
result.error500("参数不识别!");
} else {
this.regionViolationService.removeByIds(Arrays.asList(ids.split(",")));
result.success("删除成功!");
}
return result;
}
/**
* 通过id查询
*
* @return
*/
@OperLog(operModul = "中水北方区域违规记录管理", operType = "查询", operDesc = "通过id查询中水北方区域违规记录信息")
@ApiOperation(value = "通过id查询中水北方区域违规记录信息", notes = "通过id查询中水北方区域违规记录信息", httpMethod = "POST")
@ApiImplicitParam(name = "id", value = "中水北方区域违规记录ID", paramType = "body", required = true, dataType = "Integer")
@PostMapping(value = "/queryById")
public Result<RegionViolation> queryById(@ApiIgnore @RequestBody Map<String, Object> map) {
Result<RegionViolation> result = new Result<RegionViolation>();
RegionViolation regionViolation = regionViolationService.getById(MapUtils.getString(map, "id"));
if (regionViolation == null) {
result.error500("未找到对应实体");
} else {
result.setResult(regionViolation);
result.setSuccess(true);
}
return result;
}
/**
* 导出excel
*
* @param request
* @param response
*/
@ApiOperation(value = "导出excel中水北方区域违规记录信息", notes = "导出excel中水北方区域违规记录信息", httpMethod = "POST")
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
// Step.1 组装查询条件
QueryWrapper<RegionViolation> queryWrapper = null;
try {
String paramsStr = request.getParameter("paramsStr");
if (oConvertUtils.isNotEmpty(paramsStr)) {
String deString = URLDecoder.decode(paramsStr, "UTF-8");
RegionViolation regionViolation = JSON.parseObject(deString, RegionViolation.class);
queryWrapper = QueryGenerator.initQueryWrapper(regionViolation, request.getParameterMap());
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
//Step.2 AutoPoi 导出Excel
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
List<RegionViolation> pageList = regionViolationService.list(queryWrapper);
for (RegionViolation regionViolation : pageList) {
if (regionViolation.getWorkerType() == 1) {
regionViolation.setWorkerTypeName("劳务人员");
} else if (regionViolation.getWorkerType() == 1) {
regionViolation.setWorkerTypeName("管理人员");
} else {
regionViolation.setWorkerTypeName("临时人员");
}
}
//导出文件名称
mv.addObject(NormalExcelConstants.FILE_NAME, "中水北方区域违规记录列表");
mv.addObject(NormalExcelConstants.CLASS, RegionViolation.class);
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("中水北方区域违规记录列表数据", "导出人:" + SecurityUtils.getUser().getRealName(), "导出信息"));
mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
return mv;
}
/**
* 通过excel导入数据
*
* @param request
* @param response
* @return
*/
@ApiOperation(value = "通过excel导入中水北方区域违规记录信息", notes = "通过excel导入中水北方区域违规记录信息", httpMethod = "POST")
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
MultipartFile file = entity.getValue();// 获取上传文件对象
ImportParams params = new ImportParams();
params.setTitleRows(2);
params.setHeadRows(1);
params.setNeedSave(true);
try {
List<RegionViolation> listRegionViolations = ExcelImportUtil.importExcel(file.getInputStream(), RegionViolation.class, params);
for (RegionViolation regionViolationExcel : listRegionViolations) {
regionViolationService.save(regionViolationExcel);
}
return Result.ok("文件导入成功!数据行数:" + listRegionViolations.size());
} catch (Exception e) {
log.error(e.getMessage());
return Result.error("文件导入失败!");
} finally {
try {
file.getInputStream().close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return Result.ok("文件导入失败!");
}
}

View File

@ -0,0 +1,100 @@
package com.zhgd.xmgl.modules.worker.entity;
import java.io.Serializable;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;
import org.jeecgframework.poi.excel.annotation.Excel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* @Description: 中水北方区域违规记录
* @author pengj
* @date 2025-07-10
* @version V1.0
*/
@Data
@TableName("region_violation")
@ApiModel(value = "RegionViolation实体类", description = "RegionViolation")
public class RegionViolation implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 区域违规ID
*/
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "区域违规ID")
private Long id;
@ApiModelProperty(value = "人员ID")
private Long workerId;
/**
* 人员类型
*/
@ApiModelProperty(value = "人员类型")
private Integer workerType;
@TableField(exist = false)
@Excel(name = "人员类型", width = 15)
@ApiModelProperty(value = "人员类型")
private String workerTypeName;
/**
* 企业名称
*/
@Excel(name = "企业名称", width = 15)
@ApiModelProperty(value = "企业名称")
private String enterpriseName;
/**
* 部门/班组名称
*/
@Excel(name = "部门/班组名称", width = 15)
@ApiModelProperty(value = "部门/班组名称")
private String teamName;
/**
* 人员名称
*/
@Excel(name = "人员名称", width = 15)
@ApiModelProperty(value = "人员名称")
private String workerName;
/**
* 进场时间
*/
@Excel(name = "进场时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "进场时间")
private String enterTime;
/**
* 出场时间
*/
@Excel(name = "出场时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "出场时间")
private String outTime;
/**
* 在场时长
*/
@Excel(name = "在场时长", width = 15)
@ApiModelProperty(value = "在场时长")
private String duration;
/**
* 出场位置
*/
@Excel(name = "出场位置", width = 15)
@ApiModelProperty(value = "出场位置")
private String address;
/**
* 区域ID
*/
@ApiModelProperty(value = "区域ID")
private Long regionId;
/**
* 项目SN
*/
@ApiModelProperty(value = "项目SN")
private String projectSn;
}

View File

@ -0,0 +1,19 @@
package com.zhgd.xmgl.modules.worker.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import com.zhgd.xmgl.modules.worker.entity.RegionViolation;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @Description: 中水北方区域违规记录
* @author pengj
* @date 2025-07-10
* @version V1.0
*/
@Mapper
public interface RegionViolationMapper extends BaseMapper<RegionViolation> {
}

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zhgd.xmgl.modules.worker.mapper.RegionViolationMapper">
</mapper>

View File

@ -0,0 +1,14 @@
package com.zhgd.xmgl.modules.worker.service;
import com.zhgd.xmgl.modules.worker.entity.RegionViolation;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @Description: 中水北方区域违规记录
* @author pengj
* @date 2025-07-10
* @version V1.0
*/
public interface IRegionViolationService extends IService<RegionViolation> {
}

View File

@ -0,0 +1,19 @@
package com.zhgd.xmgl.modules.worker.service.impl;
import com.zhgd.xmgl.modules.worker.entity.RegionViolation;
import com.zhgd.xmgl.modules.worker.mapper.RegionViolationMapper;
import com.zhgd.xmgl.modules.worker.service.IRegionViolationService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
/**
* @Description: 中水北方区域违规记录
* @author pengj
* @date 2025-07-10
* @version V1.0
*/
@Service
public class RegionViolationServiceImpl extends ServiceImpl<RegionViolationMapper, RegionViolation> implements IRegionViolationService {
}

View File

@ -20,6 +20,7 @@ import com.arcsoft.face.toolkit.ImageInfo;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zhgd.jeecg.common.api.vo.Result;
@ -180,6 +181,10 @@ public class WorkerAttendanceServiceImpl extends ServiceImpl<WorkerAttendanceMap
time = time.substring(0, 10);
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd");
String nowTime = sdf1.format(new Date());
if (StringUtils.isBlank(workerAttendance.getImageUrl())) {
WorkerInfo workerInfo = workerInfoService.getOne(Wrappers.<WorkerInfo>lambdaQuery().eq(WorkerInfo::getPersonSn, workerAttendance.getPersonSn()));
workerAttendance.setImageUrl(workerInfo == null ? "" : workerInfo.getFieldAcquisitionUrl());
}
workerAttendanceMapper.insert(workerAttendance);
//计算在场
workerAttendancePresenceService.addWorkerAttendancePresence(workerAttendance);

View File

@ -1,6 +1,7 @@
package com.zhgd.xmgl.task;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.BetweenFormatter;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
@ -10,6 +11,8 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zhgd.xmgl.constant.Cts;
@ -28,6 +31,8 @@ import com.zhgd.xmgl.modules.project.entity.ProjectUfaceConfig;
import com.zhgd.xmgl.modules.project.mapper.ProjectExternalSystemServiceMapper;
import com.zhgd.xmgl.modules.project.mapper.ProjectMapper;
import com.zhgd.xmgl.modules.project.service.IProjectUfaceConfigService;
import com.zhgd.xmgl.modules.quality.entity.QualityRegion;
import com.zhgd.xmgl.modules.quality.service.IQualityRegionService;
import com.zhgd.xmgl.modules.worker.entity.*;
import com.zhgd.xmgl.modules.worker.mapper.WorkerBlacklistMapper;
import com.zhgd.xmgl.modules.worker.mapper.WorkerCertificateMapper;
@ -86,6 +91,10 @@ public class WorkerTask {
@Autowired
WorkerInfoServiceImpl workerInfoService;
@Autowired
IQualityRegionService qualityRegionService;
@Autowired
IRegionViolationService regionViolationService;
@Autowired
ISystemUserService systemUserService;
@Autowired
private ProjectExternalSystemServiceMapper projectExternalSystemServiceMapper;
@ -862,4 +871,81 @@ public class WorkerTask {
}
}
/**
* 中水北方区域人员滞留超过一天进行记录
*/
@Scheduled(cron = "0 0/2 * * * ?")
@SchedulerLock(name = "regionViolation", lockAtMostFor = 1000 * 55, lockAtLeastFor = 1000 * 55)
@RequestMapping("regionViolation")
public void regionViolation() {
List<RegionViolation> list = new ArrayList<>();
List<RegionViolation> violations = regionViolationService.list(Wrappers.<RegionViolation>lambdaQuery().isNull(RegionViolation::getOutTime));
List<Long> exist = violations.stream().map(v -> v.getWorkerId()).collect(Collectors.toList());
List<QualityRegion> regionList = qualityRegionService.list(Wrappers.<QualityRegion>lambdaQuery().eq(QualityRegion::getProjectSn, "554F52F52835441386247F5061D4F9DD"));
for (QualityRegion qualityRegion : regionList) {
Map<String,Object> map = new HashMap();
map.put("projectSn", "554F52F52835441386247F5061D4F9DD");
map.put("pageNo", 1);
map.put("pageSize", 1000);
map.put("presence", 1);
map.put("regionIdForUface", qualityRegion.getId());
List<WorkerInfo> workerInfoIList = workerInfoService.selectWorkerInfoList(map).getRecords();
for (WorkerInfo workerInfo : workerInfoIList) {
if (StringUtils.isNotBlank(workerInfo.getAlarmFlag())) {
if (!exist.contains(workerInfo.getId())) {
RegionViolation regionViolation = new RegionViolation();
regionViolation.setWorkerType(workerInfo.getPersonType());
regionViolation.setWorkerId(workerInfo.getId());
regionViolation.setEnterpriseName(workerInfo.getEnterpriseName());
String teamName = StringUtils.isNotEmpty(workerInfo.getTeamName()) ? workerInfo.getTeamName() : "";
String departmentName =StringUtils.isNotEmpty(workerInfo.getDepartmentName()) ? workerInfo.getDepartmentName() : "";
regionViolation.setTeamName(teamName + departmentName);
regionViolation.setWorkerName(workerInfo.getWorkerName());
regionViolation.setEnterTime(workerInfo.getAttendTime());
regionViolation.setProjectSn(workerInfo.getProjectSn());
regionViolation.setRegionId(qualityRegion.getId());
list.add(regionViolation);
}
}
}
List<Long> regionExist = violations.stream().filter(v -> v.getRegionId().toString().equals(qualityRegion.getId().toString()))
.map(v -> v.getWorkerId()).collect(Collectors.toList());
for (Long workerId : regionExist) {
if (!workerInfoIList.contains(workerId)) {
WorkerInfo workerInfo = workerInfoService.getById(workerId);
WorkerAttendance enter = workerAttendanceService.getOne(Wrappers.<WorkerAttendance>lambdaQuery()
.eq(WorkerAttendance::getPersonSn, workerInfo.getPersonSn())
.eq(WorkerAttendance::getPassType, 1)
.orderByDesc(WorkerAttendance::getCreateTime).last(" limit 1"));
WorkerAttendance out = workerAttendanceService.getOne(Wrappers.<WorkerAttendance>lambdaQuery()
.eq(WorkerAttendance::getPersonSn, workerInfo.getPersonSn())
.eq(WorkerAttendance::getPassType, 2)
.orderByDesc(WorkerAttendance::getCreateTime).last(" limit 1"));
if (out != null) {
UfaceDev one = ufaceDevService.getOne(Wrappers.<UfaceDev>lambdaQuery().eq(UfaceDev::getDevSn, out.getDevSn()));
LambdaUpdateWrapper<RegionViolation> wrapper = Wrappers.<RegionViolation>lambdaUpdate();
wrapper.eq(RegionViolation::getWorkerId, workerInfo.getId());
wrapper.isNull(RegionViolation::getOutTime);
wrapper.set(RegionViolation::getOutTime, out.getCreateTime());
wrapper.set(RegionViolation::getAddress, one.getDevName());
wrapper.set(RegionViolation::getDuration, DateUtil.formatBetween(DateUtil.parseDateTime(enter.getCreateTime()),
DateUtil.parseDateTime(out.getCreateTime()), BetweenFormatter.Level.SECOND));
regionViolationService.update(wrapper);
}
}
}
}
regionViolationService.saveBatch(list);
}
// /**
// * MQTT同步下发人员信息
// */
// @Scheduled(cron = "0 0/10 * * * ?")
// @SchedulerLock(name = "mqttIssuedWorkerInfo", lockAtMostFor = 1000 * 55, lockAtLeastFor = 1000 * 55)
// @RequestMapping("mqttIssuedWorkerInfo")
// public void mqttIssuedWorkerInfo() {
//
// }
}

View File

@ -0,0 +1,100 @@
package com.zhgd.xmgl.util;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.zhgd.jeecg.common.util.SpringContextUtils;
import com.zhgd.mqtt.server.IMqttSender;
import com.zhgd.xmgl.modules.project.entity.ProjectUfaceConfig;
import com.zhgd.xmgl.modules.worker.entity.WorkerInfo;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
/**
* MQTT下发人员信息
*/
@Slf4j
public class MqttFaceDevUtil {
@Value("${basePath}")
private static String basePath;
private static String mqttTopic = "mqtt/face/";
/**
* 添加修改人员
*
* @param workerInfo
* @param devSn
*/
public static void addOrUpdatePerson(WorkerInfo workerInfo, String devSn) {
if (StrUtil.isNotBlank(devSn)) {
String[] splitArr = StringUtils.split(devSn, ",");
for (int i = 0; i < splitArr.length; i++) {
String ds = splitArr[i];
Map<String, Object> map = build(workerInfo);
String payload = JSON.toJSONString(map);
String topic = mqttTopic + ds;
log.info("发送主题信息:{},主题为:{}", payload, topic);
IMqttSender mqttSender = SpringContextUtils.getBean(IMqttSender.class);
mqttSender.sendToMqtt(topic, 2, payload);
}
} else {
log.info("未查询到设备sn");
}
}
/**
* 删除人员
*
* @param workerInfo
*/
public static void deletePerson(WorkerInfo workerInfo, String devSn) {
if (StrUtil.isNotBlank(devSn)) {
String[] splitArr = StringUtils.split(devSn, ",");
for (int i = 0; i < splitArr.length; i++) {
String ds = splitArr[i];
Map<String, Object> map = new HashMap<>();
map.put("operator", "DelPerson");
map.put("messageId", "ID:" + System.currentTimeMillis() + ":" + workerInfo.getPersonSn());
Map<String, Object> info = new HashMap<>();
info.put("customId", workerInfo.getPersonSn());
map.put("info", info);
String payload = JSON.toJSONString(map);
String topic = mqttTopic + ds;
log.info("发送主题信息:{},主题为:{}", payload, topic);
IMqttSender mqttSender = SpringContextUtils.getBean(IMqttSender.class);
mqttSender.sendToMqtt(topic, 2, payload);
}
} else {
log.error("未查询到设备sn");
}
}
private static Map<String, Object> build(WorkerInfo workerInfo) {
Map<String, Object> map = new HashMap<>();
map.put("messageId", "ID:" + System.currentTimeMillis() + ":" + workerInfo.getPersonSn());
map.put("operator", "EditPerson");
Map<String, Object> info = new HashMap<>();
info.put("customId", workerInfo.getPersonSn());
info.put("name", workerInfo.getWorkerName());
info.put("nation", 1);
info.put("gender", workerInfo.getSex() - 1);
info.put("birthday", workerInfo.getBirthday());
info.put("address", workerInfo.getNowPlace());
info.put("idCard", workerInfo.getIdCard());
info.put("tempCardType", 0);
info.put("telnum1", workerInfo.getPhoneNumber());
info.put("native", workerInfo.getNativePlace());
info.put("personType", 0);
info.put("cardType", 0);
info.put("pic", basePath + "/" + workerInfo.getFieldAcquisitionUrl());
map.put("info", info);
return map;
}
}