bug修复

This commit is contained in:
guoshengxiong 2025-08-22 19:47:15 +08:00
parent ca6f3100e1
commit 2bdd14aec2
22 changed files with 336 additions and 71 deletions

View File

@ -1,14 +1,6 @@
package com.zhgd.mqtt.server;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.zhgd.mybatis.DataScopeHandler;
import com.zhgd.xmgl.constant.Cts;
import com.zhgd.xmgl.modules.worker.service.IWorkerAttendanceService;
import com.zhgd.xmgl.modules.worker.service.IWorkerInfoService;
import com.zhgd.xmgl.modules.xz.service.IXzHikvisionSyncService;
import lombok.Setter;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
import org.slf4j.Logger;
@ -185,8 +177,8 @@ public class MqttConfig {
String topic = message.getHeaders().get("mqtt_receivedTopic").toString();
LOGGER.info("消息主题:{}", topic);
Object payLoad = message.getPayload();
LOGGER.info("主题:{},消息接收到的数据:{}", message.getHeaders().get("mqtt_receivedTopic"),payLoad);
LOGGER.error("===================={}============", payLoad);
LOGGER.info("主题:{},消息接收到的数据:{}", message.getHeaders().get("mqtt_receivedTopic"), payLoad);
LOGGER.info("===================={}============", payLoad);
dispatchHandler.message(topic, payLoad);
} catch (Exception e) {
}

View File

@ -21,7 +21,9 @@ import com.zhgd.xmgl.modules.worker.entity.vo.StatsEnterpriseWeekVo;
import com.zhgd.xmgl.modules.worker.service.IDepartmentInfoService;
import com.zhgd.xmgl.modules.worker.service.IEnterpriseInfoService;
import com.zhgd.xmgl.modules.worker.service.ITeamInfoService;
import com.zhgd.xmgl.modules.worker.service.IWorkerInfoService;
import com.zhgd.xmgl.util.ListUtils;
import com.zhgd.xmgl.util.MapBuilder;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
@ -60,6 +62,9 @@ public class EnterpriseInfoController {
@Lazy
@Autowired
private ITeamInfoService teamInfoService;
@Lazy
@Autowired
private IWorkerInfoService workerInfoService;
/**
* 列表查询
@ -293,6 +298,10 @@ public class EnterpriseInfoController {
.eq(DepartmentInfo::getProjectSn, projectSn));
List<TeamInfo> teamInfoList = teamInfoService.list(new LambdaQueryWrapper<TeamInfo>()
.eq(TeamInfo::getProjectSn, projectSn));
Map<Integer, Map<Long, Integer>> personType2DepartmentTeamId2WorkerNumMap = workerInfoService.countDepartTeamWorkerNumByPersonType(new MapBuilder<String, Object>()
.put("projectSn", projectSn)
.put("inServiceType", 1)
.build());
Map<Long, String> enterpriseId2UniqueIdMap = new HashMap<>();
List<EnterpriseDepartmentTeamTreeVo> enterprises = enterpriseInfoService.getEnterpriseInfos(param).stream().map(e -> {
enterpriseId2UniqueIdMap.put(e.getId(), e.getId() + "");
@ -313,6 +322,7 @@ public class EnterpriseInfoController {
vo.setOriginalId(d.getId() + "");
vo.setTypeName("部门");
vo.setCategory(2);
vo.setWorkerNum(Optional.ofNullable(personType2DepartmentTeamId2WorkerNumMap.get(2)).map(m -> m.get(d.getId())).orElse(null));
return vo;
}).collect(Collectors.toList());
List<EnterpriseDepartmentTeamTreeVo> teams = teamInfoList.stream().filter(t -> Objects.nonNull(enterpriseId2UniqueIdMap.get(t.getEnterpriseId()))).map(t -> {
@ -323,6 +333,7 @@ public class EnterpriseInfoController {
vo.setOriginalId(t.getId() + "");
vo.setTypeName("班组");
vo.setCategory(3);
vo.setWorkerNum(Optional.ofNullable(personType2DepartmentTeamId2WorkerNumMap.get(1)).map(m -> m.get(t.getId())).orElse(null));
return vo;
}).collect(Collectors.toList());
all.addAll(enterprises);

View File

@ -552,12 +552,15 @@ public class WorkerAttendanceController {
@ApiOperation(value = "人员考勤导出excel记录", notes = "人员考勤导出excel记录", httpMethod = "POST")
@ApiImplicitParams({
@ApiImplicitParam(name = "projectSn", value = "项目sn", paramType = "body", required = true, dataType = "String"),
@ApiImplicitParam(name = "idList", value = "考勤idList", paramType = "body", required = false, dataType = "String"),
})
@PostMapping(value = "/exportXls")
public void exportXls(HttpServletResponse response, @RequestBody HashMap<String, Object> param) {
String templateUrl = null;
try {
Map<String, Object> map = new HashMap<>();
param.put("pageNo", 1);
param.put("pageSize", -1);
List<WorkerAttendanceVo> records = workerAttendanceService.selectWorkerAttendancePage(param).getRecords();
List<Map<String, Object>> listMap = new ArrayList<>();
for (int i = 0; i < records.size(); i++) {
@ -596,7 +599,6 @@ public class WorkerAttendanceController {
templateUrl = Fileutils.getExportTemplateFile("excel/人员考勤记录导出.xlsx").getAbsolutePath();
TemplateExportParams params = new TemplateExportParams(templateUrl);
Workbook workbook = ExcelExportUtil.exportExcel(params, map);
//设置下拉
ExcelUtils.downLoadExcel("风险点清单导出模板.xlsx", response, workbook);
} catch (IOException e) {
log.error("", e);

View File

@ -780,6 +780,8 @@ public class WorkerDailyAttendanceStatisticsV2Controller {
@ApiImplicitParam(name = "departmentId", value = "部门ID", paramType = "body", required = false, dataType = "String"),
@ApiImplicitParam(name = "inserviceType", value = "在职状态 1在职 2离职", paramType = "body", required = false, dataType = "Integer"),
@ApiImplicitParam(name = "containEnterpriseId", value = "包含下级的单位的人员的单位id", paramType = "body", required = false, dataType = "String"),
@ApiImplicitParam(name = "attendanceStatus", value = "正常出勤,异常出勤,未出勤(多个,分割)", paramType = "body", required = false, dataType = "String"),
@ApiImplicitParam(name = "downloadType", value = "1每日明细上下午打卡2进出场打卡", paramType = "body", required = false, dataType = "String"),
})
@PostMapping(value = "/getWorkerDailyAttendancePageForWorkerByDate")
public Result<IPage<WorkerDailyAttendanceStatisticsV2Vo>> getWorkerDailyAttendancePageForWorkerByDate(@RequestBody HashMap<String, Object> param) {
@ -903,7 +905,7 @@ public class WorkerDailyAttendanceStatisticsV2Controller {
value = getExcelAmPmAttendanceByDate(personSn2Date2AttendancesMap, vo, dateTime, downloadType);
} else if (Objects.equals(downloadType, 3)) {
//每日工时
value = Optional.ofNullable(vo.getDailyHourMap().get(DateUtil.formatDate(dateTime))).map(decimal -> decimal.toString()).orElse("");
value = Optional.ofNullable(vo.getDailyHourMap().get(DateUtil.formatDate(dateTime))).map(BigDecimal::toString).orElse("0.0");
} else {
//每日明细
value = Optional.ofNullable(vo.getDailyAttendanceMap().get(DateUtil.formatDate(dateTime))).map(integer -> Objects.equals(integer, 1) ? "" : "×").orElse("x");
@ -1032,7 +1034,7 @@ public class WorkerDailyAttendanceStatisticsV2Controller {
DateTime dateTime = dateTimes.get(z);
sheetMap2.put("date" + (z + 1), DateUtil.format(dateTime, "M/d"));
//每日工时
String value = Optional.ofNullable(vo.getDailyHourMap().get(DateUtil.formatDate(dateTime))).map(decimal -> decimal.toString()).orElse("");
String value = Optional.ofNullable(vo.getDailyHourMap().get(DateUtil.formatDate(dateTime))).map(decimal -> decimal.toString()).orElse("0.0");
map.put("attendanceByDate" + (z + 1), value);
}
listMap2.add(map);

View File

@ -211,10 +211,14 @@ public class WorkerInfoController {
@ApiImplicitParam(name = "projectSn", value = "项目SN", paramType = "body", required = true, dataType = "String"),
@ApiImplicitParam(name = "projectSnList", value = "项目SN列表", paramType = "body", required = false, dataType = "String"),
@ApiImplicitParam(name = "userEnterpriseId", value = "用户能查看的企业", paramType = "body", required = false, dataType = "String"),
@ApiImplicitParam(name = "containEnterpriseId", value = "包含下级的单位的人员的单位id", paramType = "body", required = false, dataType = "String"),
@ApiImplicitParam(name = "isContainSubEnterprise", value = "1包含下级的单位", paramType = "body", required = false, dataType = "String"),
})
@PostMapping("/selectPersonTypeAndEduStatistics")
public Result<PersonTypeAndEduStatisticsVo> selectPersonTypeAndEduStatistics(@RequestBody Map<String, Object> map) {
if (Objects.equals(MapUtils.getInteger(map, "isContainSubEnterprise"), 1)) {
map.put("containEnterpriseId", map.get("userEnterpriseId"));
map.put("userEnterpriseId", null);
}
return Result.success(workerInfoService.selectPersonTypeAndEduStatistics(map));
}
@ -882,13 +886,11 @@ public class WorkerInfoController {
public Result<EmploymentOverviewVo> getEmploymentOverview(@ApiIgnore @RequestBody Map<String, Object> paramMap) {
WorkerInfo workerInfo = workerInfoService.queryById(MapUtils.getString(paramMap, "workerId"));
EmploymentOverviewVo vo = new EmploymentOverviewVo();
if (StrUtil.isNotBlank(workerInfo.getEnterDate())) {
vo.setInServe((int) DateUtil.betweenDay(DateUtil.parseDate(workerInfo.getEnterDate()), new Date(), true) + 1);
paramMap.put("personSn", workerInfo.getPersonSn());
int count = workerAttendanceService.getWorkerAttendanceCountDay(paramMap);
vo.setAttendance(count);
vo.setAbsence(vo.getInServe() - vo.getAttendance());
}
vo.setInServe((int) DateUtil.betweenDay(StrUtil.isNotBlank(workerInfo.getEnterDate()) ? DateUtil.parseDate(workerInfo.getEnterDate()) : workerInfo.getAddTime(), new Date(), true) + 1);
paramMap.put("personSn", workerInfo.getPersonSn());
int count = workerAttendanceService.getWorkerAttendanceCountDay(paramMap);
vo.setAttendance(count);
vo.setAbsence(vo.getInServe() - vo.getAttendance());
return Result.success(vo);
}

View File

@ -77,4 +77,25 @@ public class WorkerDailyAttendanceStatisticsV2 implements Serializable {
*/
@ApiModelProperty(value = "在职状态 1在职 2离职")
private java.lang.Integer inserviceType;
/**
* 进场打卡(首次)
*/
@ApiModelProperty(value = "进场打卡(首次)")
private String firstInTime;
/**
* 出场打卡(末次)
*/
@ApiModelProperty(value = "出场打卡(末次)")
private String endOutTime;
/**
* 上午打卡(首次)
*/
@ApiModelProperty(value = "上午打卡(首次)")
private String firstTimeAm;
/**
* 下午打卡(未次)
*/
@ApiModelProperty(value = "下午打卡(未次)")
private String endTimePm;
}

View File

@ -0,0 +1,10 @@
package com.zhgd.xmgl.modules.worker.entity.bo;
import lombok.Data;
@Data
public class CountDepartTeamWorkerNumByPersonTypeBo {
private Integer personType;
private Long departTeamId;
private Integer countNum;
}

View File

@ -42,4 +42,9 @@ public class EnterpriseDepartmentTeamTreeVo {
*/
@ApiModelProperty("children")
private List<EnterpriseDepartmentTeamTreeVo> children;
/**
* 人员数量
*/
@ApiModelProperty("人员数量")
private Integer workerNum;
}

View File

@ -7,6 +7,7 @@ import com.zhgd.jeecg.common.mybatis.EntityMap;
import com.zhgd.xmgl.entity.vo.NumberTimeTableVo;
import com.zhgd.xmgl.modules.realnamestatistics.entity.vo.WorkerAttendanceVo;
import com.zhgd.xmgl.modules.worker.entity.WorkerAttendance;
import com.zhgd.xmgl.modules.worker.entity.WorkerInfo;
import com.zhgd.xmgl.modules.worker.entity.bo.WorkerAttendanceBo;
import com.zhgd.xmgl.modules.worker.entity.dto.GetPassRecordDto;
import com.zhgd.xmgl.modules.worker.entity.vo.PresentByMonthVo;
@ -17,6 +18,7 @@ import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -331,4 +333,6 @@ public interface WorkerAttendanceMapper extends BaseMapper<WorkerAttendance> {
* @return
*/
List<PresentDayByMonthVo> getPresentDayByMonth(Map<String, Object> paramMap);
List<WorkerInfo> getAutoExitWorkers(HashMap<String, Object> param);
}

View File

@ -7,7 +7,9 @@ import com.zhgd.annotation.DataScope;
import com.zhgd.jeecg.common.mybatis.EntityMap;
import com.zhgd.xmgl.base.entity.vo.TrendOneVo;
import com.zhgd.xmgl.modules.worker.entity.WorkerInfo;
import com.zhgd.xmgl.modules.worker.entity.bo.CountDepartTeamWorkerNumByPersonTypeBo;
import com.zhgd.xmgl.modules.worker.entity.vo.*;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
@ -730,4 +732,5 @@ public interface WorkerInfoMapper extends BaseMapper<WorkerInfo> {
int selectWorkerNumByMl(@Param("projectSn") String projectSn);
List<CountDepartTeamWorkerNumByPersonTypeBo> countDepartTeamWorkerNumByPersonType(Map<String, Object> param);
}

View File

@ -62,6 +62,12 @@
LEFT JOIN department_info d ON b.department_id = d.id
LEFT JOIN enterprise_info ei on ei.id=b.enterprise_id
WHERE a.project_sn = #{param.projectSn}
<if test="param.idList != null and param.idList.size() != 0">
and a.id in
<foreach collection="param.idList" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="param.containEnterpriseId != null and param.containEnterpriseId != '' and param.projectSn != null and param.projectSn != ''">
and (b.enterprise_id = #{param.containEnterpriseId} OR b.enterprise_id IN ( SELECT t.enterprise_id FROM
project_enterprise t WHERE find_in_set((select id from project_enterprise where enterprise_id =
@ -1051,4 +1057,48 @@
</if>
group by month
</select>
<select id="getAutoExitWorkers" resultType="com.zhgd.xmgl.modules.worker.entity.WorkerInfo">
select
distinct wi.*
from
worker_info wi
left join (
SELECT person_sn, MAX( create_time ) create_time FROM worker_attendance WHERE project_sn = #{projectSn} GROUP BY
person_sn
) wa ON wi.person_sn = wa.person_sn
where wi.project_sn=#{projectSn}
and (wa.create_time &lt; DATE_SUB(NOW(), INTERVAL #{exitIfAbsenceDay} DAY) or wa.create_time is null)
and (1=1
<if test="workerIdList != null and workerIdList != '' and workerIdList.size() != 0">
and wi.id in
<foreach collection="workerIdList" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="enterpriseIdList != null and enterpriseIdList != '' and enterpriseIdList.size() != 0">
and wi.enterprise_id in
<foreach collection="enterpriseIdList" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="(departmentIdList != null and departmentIdList != '' and departmentIdList.size() != 0) or
(teamIdList != null and teamIdList != '' and teamIdList.size() != 0)">
and (1=0
<if test="departmentIdList != null and departmentIdList != '' and departmentIdList.size() != 0">
or wi.department_id in
<foreach collection="departmentIdList" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="teamIdList != null and teamIdList != '' and teamIdList.size() != 0">
or wi.team_id in
<foreach collection="teamIdList" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
)
</if>
)
</select>
</mapper>

View File

@ -34,6 +34,34 @@
<if test="param.endTime != null and param.endTime != ''">
and t.attendance_date &lt;= DATE_FORMAT(#{param.endTime},'%Y-%m-%d')
</if>
<if test="param.attendanceStatus != null and param.attendanceStatus != ''">
and ( 1=0
<if test="param.attendanceStatus.contains('正常出勤'.toString())">
or (t.is_attendance = 1 and
<if test="param.downloadType == '1'.toString()">
t.first_time_am is not null and t.end_time_pm is not null
</if>
<if test="param.downloadType == '2'.toString()">
t.first_in_time is not null and t.end_out_time is not null
</if>
)
</if>
<if test="param.attendanceStatus.contains('异常出勤'.toString())">
or (t.is_attendance = 1 and (
<if test="param.downloadType == '1'.toString()">
t.first_time_am is null or t.end_time_pm is null
</if>
<if test="param.downloadType == '2'.toString()">
t.first_in_time is null or t.end_out_time is null
</if>
)
)
</if>
<if test="param.attendanceStatus.contains('未出勤'.toString())">
or t.is_attendance = 0
</if>
)
</if>
)t
${ew.customSqlSegment}
</select>

View File

@ -2690,11 +2690,36 @@
<select id="selectWorkerNumByMl" resultType="java.lang.Integer" parameterType="java.util.Map">
SELECT COUNT(DISTINCT(id)) from (SELECT
w1.id id
FROM
worker_info w1
INNER JOIN worker_attendance_presence p ON w1.person_sn = p.person_sn WHERE w1.project_sn = #{projectSn}
UNION
SELECT worker_info_id id FROM safety_hat_dev WHERE `online` = 1 AND project_sn = #{projectSn}) a
w1.id id
FROM
worker_info w1
INNER JOIN worker_attendance_presence p ON w1.person_sn = p.person_sn WHERE w1.project_sn = #{projectSn}
UNION
SELECT worker_info_id id FROM safety_hat_dev WHERE `online` = 1 AND project_sn = #{projectSn}) a
</select>
<select id="countDepartTeamWorkerNumByPersonType"
resultType="com.zhgd.xmgl.modules.worker.entity.bo.CountDepartTeamWorkerNumByPersonTypeBo">
SELECT
1 as personType,
team_id as depart_team_id,
COUNT(*) as countNum
FROM worker_info
WHERE project_sn = #{projectSn} AND person_type = 1
<if test="inServiceType != null and inServiceType != ''">
and inService_type = #{inServiceType}
</if>
GROUP BY team_id
UNION ALL
SELECT
2 as personType,
department_id as depart_team_id,
COUNT(*) as countNum
FROM worker_info
WHERE project_sn = #{projectSn} AND person_type = 2
<if test="inServiceType != null and inServiceType != ''">
and inService_type = #{inServiceType}
</if>
GROUP BY department_id
</select>
</mapper>

View File

@ -2,7 +2,6 @@ package com.zhgd.xmgl.modules.worker.service;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zhgd.jeecg.common.api.vo.Result;
import com.zhgd.jeecg.common.mybatis.EntityMap;
@ -10,15 +9,16 @@ import com.zhgd.xmgl.entity.vo.AttendanceOfEachCompanyVo;
import com.zhgd.xmgl.entity.vo.NumberTimeTableVo;
import com.zhgd.xmgl.modules.realnamestatistics.entity.vo.WorkerAttendanceVo;
import com.zhgd.xmgl.modules.worker.entity.WorkerAttendance;
import com.zhgd.xmgl.modules.worker.entity.WorkerInfo;
import com.zhgd.xmgl.modules.worker.entity.dto.GetPassRecordDto;
import com.zhgd.xmgl.modules.worker.entity.dto.WorkerAttendanceDto;
import com.zhgd.xmgl.modules.worker.entity.vo.PresentByMonthVo;
import com.zhgd.xmgl.modules.worker.entity.vo.PresentDayByMonthVo;
import com.zhgd.xmgl.modules.worker.entity.vo.SafetyPerformanceAnalysisVo;
import com.zhgd.xmgl.modules.worker.entity.vo.UploadAttendanceByDevDto;
import com.zhgd.xmgl.modules.xz.security.entity.vo.XzSecurityPostponeRectifyApplyVo;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -321,4 +321,12 @@ public interface IWorkerAttendanceService extends IService<WorkerAttendance> {
void mqttRec(String deviceSn, JSONObject obj);
void zyMqttRec(JSONObject obj);
/**
* 获取超期自动退场的人员
*
* @param projectSn
* @return
*/
List<WorkerInfo> getAutoExitWorkers(HashMap<String, Object> projectSn);
}

View File

@ -609,4 +609,12 @@ public interface IWorkerInfoService extends IService<WorkerInfo> {
* @return
*/
Map<Long, WorkerInfo> getWorkerMapByProjectSn(String projectSn);
/**
* 统计班组部门的人员数量
*
* @param param
* @return
*/
Map<Integer, Map<Long, Integer>> countDepartTeamWorkerNumByPersonType(Map<String, Object> param);
}

View File

@ -1497,6 +1497,11 @@ status 状态码 String 1表示成功其余表示失败
uploadAttendanceByDev(dto);
}
@Override
public List<WorkerInfo> getAutoExitWorkers(HashMap<String, Object> param) {
return baseMapper.getAutoExitWorkers(param);
}
private void setTotalCount(List<SafetyPerformanceAnalysisVo> vos, SafetyPerformanceAnalysisVo vo) {
Integer notPerformNum = 0;
Integer inServiceNum = 0;

View File

@ -189,7 +189,13 @@ public class WorkerDailyAttendanceStatisticsV2ServiceImpl extends ServiceImpl<Wo
}
@Override
public void calAndSaveStatistics(String projectSn, String personSn, Integer inserviceType, DateTime date, WorkerAttendanceRuleV2 ruleV2, List<CalAttendanceBo> attendances, List<CalAttendanceBo> allAttendances) {
public void calAndSaveStatistics(String projectSn,
String personSn,
Integer inserviceType,
DateTime date,
WorkerAttendanceRuleV2 ruleV2,
List<CalAttendanceBo> attendances,
List<CalAttendanceBo> allAttendances) {
attendances = attendances.stream().filter(o -> Objects.equals(o.getPersonSn(), personSn) &&
(DateUtil.isSameDay(DateUtil.offsetDay(date, -1), o.getDate())
|| DateUtil.isSameDay(date, o.getDate())
@ -296,8 +302,17 @@ public class WorkerDailyAttendanceStatisticsV2ServiceImpl extends ServiceImpl<Wo
//5.计算考勤
sta.setProjectSn(projectSn);
sta.setPersonSn(personSn);
String dateStr = DateUtil.formatDate(date);
sta.setAttendanceDate(date);
sta.setIsAttendance(attendances.stream().anyMatch(o -> DateUtil.isSameDay(date, o.getDate())) ? 1 : 0);
sta.setFirstInTime(allAttendances.stream().filter(w -> Objects.equals(w.getPassType(), 1)).min(Comparator.comparing(CalAttendanceBo::getDate))
.map(bo -> DateUtil.format(bo.getDate(), "HH:mm:ss")).orElse(null));
sta.setEndOutTime(allAttendances.stream().filter(w -> Objects.equals(w.getPassType(), 2)).max(Comparator.comparing(CalAttendanceBo::getDate))
.map(bo -> DateUtil.format(bo.getDate(), "HH:mm:ss")).orElse(null));
sta.setFirstTimeAm(allAttendances.stream().filter(w -> DateUtil.compare(w.getDate(), DateUtil.parseDateTime(dateStr + " 12:00:00")) < 0).min(Comparator.comparing(CalAttendanceBo::getDate))
.map(bo -> DateUtil.format(bo.getDate(), "HH:mm:ss")).orElse(null));
sta.setEndTimePm(allAttendances.stream().filter(w -> DateUtil.compare(w.getDate(), DateUtil.parseDateTime(dateStr + " 12:00:00")) >= 0).max(Comparator.comparing(CalAttendanceBo::getDate))
.map(bo -> DateUtil.format(bo.getDate(), "HH:mm:ss")).orElse(null));
if (sta.getId() == null) {
this.save(sta);
} else {
@ -307,6 +322,10 @@ public class WorkerDailyAttendanceStatisticsV2ServiceImpl extends ServiceImpl<Wo
.set(WorkerDailyAttendanceStatisticsV2::getIsAttendance, sta.getIsAttendance())
.set(WorkerDailyAttendanceStatisticsV2::getOvertimeHourVal, sta.getOvertimeHourVal())
.set(WorkerDailyAttendanceStatisticsV2::getOvertimeDayVal, sta.getOvertimeDayVal())
.set(WorkerDailyAttendanceStatisticsV2::getFirstInTime, sta.getFirstInTime())
.set(WorkerDailyAttendanceStatisticsV2::getEndOutTime, sta.getEndOutTime())
.set(WorkerDailyAttendanceStatisticsV2::getFirstTimeAm, sta.getFirstTimeAm())
.set(WorkerDailyAttendanceStatisticsV2::getEndTimePm, sta.getEndTimePm())
.eq(WorkerDailyAttendanceStatisticsV2::getId, sta.getId())
);
}
@ -515,12 +534,12 @@ public class WorkerDailyAttendanceStatisticsV2ServiceImpl extends ServiceImpl<Wo
Optional<List<WorkerAttendance>> workerAttendancesOpt = Optional.ofNullable(personSn2DateMap.get(vo.getPersonSn())).map(m -> m.get(date));
String firstInTime = workerAttendancesOpt.flatMap(m -> m.stream().filter(w -> Objects.equals(w.getPassType(), 1)).min(Comparator.comparing(WorkerAttendance::getCreateTime)).map(WorkerAttendance::getCreateTime)).orElse(null);
String endOutTime = workerAttendancesOpt.flatMap(m -> m.stream().filter(w -> Objects.equals(w.getPassType(), 2)).max(Comparator.comparing(WorkerAttendance::getCreateTime)).map(WorkerAttendance::getCreateTime)).orElse(null);
vo.setFirstInTime(firstInTime);
vo.setEndOutTime(endOutTime);
// vo.setFirstInTime(firstInTime);
// vo.setEndOutTime(endOutTime);
String firstTimeAm = workerAttendancesOpt.flatMap(m -> m.stream().filter(w -> DateUtil.compare(DateUtil.parseDateTime(w.getCreateTime()), DateUtil.parseDateTime(date + " 12:00:00")) < 0).min(Comparator.comparing(WorkerAttendance::getCreateTime)).map(WorkerAttendance::getCreateTime)).orElse(null);
vo.setFirstTimeAm(firstTimeAm);
// vo.setFirstTimeAm(firstTimeAm);
String endTimePm = workerAttendancesOpt.flatMap(m -> m.stream().filter(w -> DateUtil.compare(DateUtil.parseDateTime(w.getCreateTime()), DateUtil.parseDateTime(date + " 12:00:00")) >= 0).max(Comparator.comparing(WorkerAttendance::getCreateTime)).map(WorkerAttendance::getCreateTime)).orElse(null);
vo.setEndTimePm(endTimePm);
// vo.setEndTimePm(endTimePm);
}
}
return pageList;

View File

@ -64,6 +64,7 @@ import com.zhgd.xmgl.modules.safetyhat.entity.SafetyHatDev;
import com.zhgd.xmgl.modules.safetyhat.mapper.SafetyHatDevMapper;
import com.zhgd.xmgl.modules.video.mapper.AiAnalyseHardWareAlarmRecordMapper;
import com.zhgd.xmgl.modules.worker.entity.*;
import com.zhgd.xmgl.modules.worker.entity.bo.CountDepartTeamWorkerNumByPersonTypeBo;
import com.zhgd.xmgl.modules.worker.entity.bo.InServeByDateBo;
import com.zhgd.xmgl.modules.worker.entity.dto.GetWorkerInfoByDevDto;
import com.zhgd.xmgl.modules.worker.entity.vo.*;
@ -2951,4 +2952,19 @@ public class WorkerInfoServiceImpl extends ServiceImpl<WorkerInfoMapper, WorkerI
return this.list(new LambdaQueryWrapper<WorkerInfo>()
.eq(WorkerInfo::getProjectSn, projectSn)).stream().collect(Collectors.toMap(WorkerInfo::getId, Function.identity(), (o1, o2) -> o1));
}
@Override
public Map<Integer, Map<Long, Integer>> countDepartTeamWorkerNumByPersonType(Map<String, Object> param) {
List<CountDepartTeamWorkerNumByPersonTypeBo> bos = baseMapper.countDepartTeamWorkerNumByPersonType(param);
return bos.stream()
.collect(Collectors.groupingBy(
CountDepartTeamWorkerNumByPersonTypeBo::getPersonType,
Collectors.toMap(
CountDepartTeamWorkerNumByPersonTypeBo::getDepartTeamId,
CountDepartTeamWorkerNumByPersonTypeBo::getCountNum,
(existing, replacement) -> existing
)
));
}
}

View File

@ -13,7 +13,6 @@ 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.google.common.collect.Lists;
@ -34,10 +33,6 @@ import com.zhgd.xmgl.modules.project.mapper.ProjectExternalSystemServiceMapper;
import com.zhgd.xmgl.modules.project.mapper.ProjectMapper;
import com.zhgd.xmgl.modules.project.mapper.ProjectUfaceConfigMapper;
import com.zhgd.xmgl.modules.project.service.IProjectUfaceConfigService;
import com.zhgd.xmgl.modules.worker.entity.WorkerAttendance;
import com.zhgd.xmgl.modules.worker.entity.WorkerBlacklist;
import com.zhgd.xmgl.modules.worker.entity.WorkerInfo;
import com.zhgd.xmgl.modules.worker.entity.WorkerMonthAttendanceStatistics;
import com.zhgd.xmgl.modules.quality.entity.QualityRegion;
import com.zhgd.xmgl.modules.quality.service.IQualityRegionService;
import com.zhgd.xmgl.modules.worker.entity.*;
@ -46,11 +41,6 @@ import com.zhgd.xmgl.modules.worker.mapper.WorkerCertificateMapper;
import com.zhgd.xmgl.modules.worker.mapper.WorkerInfoMapper;
import com.zhgd.xmgl.modules.worker.service.*;
import com.zhgd.xmgl.modules.worker.service.impl.WorkerInfoServiceImpl;
import com.zhgd.xmgl.modules.xz.entity.XzCertificateExpireAlarmRecord;
import com.zhgd.xmgl.modules.xz.entity.XzWorkerSafeWatchAlarm;
import com.zhgd.xmgl.modules.xz.entity.XzWorkerSafeWatchConfig;
import com.zhgd.xmgl.modules.xz.entity.XzWorkerSafeWatchManager;
import com.zhgd.xmgl.modules.worker.service.IDangongWorkerFaceStatusService;
import com.zhgd.xmgl.modules.xz.entity.*;
import com.zhgd.xmgl.modules.xz.security.entity.XzSecurityInspectTaskItemRecord;
import com.zhgd.xmgl.modules.xz.security.entity.XzSecurityInspectTaskRecord;
@ -85,7 +75,6 @@ import java.util.concurrent.CompletableFuture;
import java.util.function.Function;
import java.util.stream.Collectors;
import static com.zhgd.xmgl.modules.project.enums.ProjectUfaceConfigSupplierTypeEnum.MQTT;
import static com.zhgd.xmgl.modules.project.enums.ProjectUfaceConfigSupplierTypeEnum.ZYMQTT;
/**
@ -172,6 +161,12 @@ public class WorkerTask {
@Value("${basePath}")
private String basePath;
@Lazy
@Autowired
private IWorkerExitConfigService workerExitConfigService;
@Lazy
@Autowired
private IWorkerBlacklistService workerBlacklistService;
/**
* 定时修改用户码状态
@ -880,6 +875,29 @@ public class WorkerTask {
workerAttendanceService.saveExternalPassRecord(map);
}
// /**
// * MQTT同步下发人员信息
// */
// @Scheduled(cron = "0 0/15 * * * ?")
// @SchedulerLock(name = "mqttIssuedWorkerInfo", lockAtMostFor = 1000 * 55, lockAtLeastFor = 1000 * 55)
// @RequestMapping("mqttIssuedWorkerInfo")
// public void mqttIssuedWorkerInfo() {
// List<ProjectUfaceConfig> configList = projectUfaceConfigMapper.selectList(Wrappers.<ProjectUfaceConfig>lambdaQuery()
// .eq(ProjectUfaceConfig::getSupplierType, MQTT.getCode())
// .eq(ProjectUfaceConfig::getIssueDev, 1));
// for (ProjectUfaceConfig projectUfaceConfig : configList) {
// List<XzHikvisionSync> list = xzHikvisionSyncService.list(Wrappers.<XzHikvisionSync>lambdaQuery()
// .eq(XzHikvisionSync::getProjectSn, projectUfaceConfig.getProjectSn())
// .eq(XzHikvisionSync::getIsSuccess, 0)
// .eq(XzHikvisionSync::getType, 1)
// .eq(XzHikvisionSync::getBigType, 1));
// for (XzHikvisionSync sync : list) {
// WorkerInfo workerInfo = workerInfoMapper.selectById(sync.getWhoId());
// MqttFaceDevUtil.addOrUpdatePerson(workerInfo, sync.getDeviceSn());
// }
// }
// }
/**
* 弹弓下发状态把超过一个小时没有接受到异常状态的人员的图片标志成正常状态
*/
@ -904,7 +922,6 @@ public class WorkerTask {
}
}
/**
* 中水北方区域人员滞留超过一天进行记录
*/
@ -917,7 +934,7 @@ public class WorkerTask {
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<String, Object> map = new HashMap();
map.put("projectSn", "554F52F52835441386247F5061D4F9DD");
map.put("pageNo", 1);
map.put("pageSize", 1000);
@ -932,7 +949,7 @@ public class WorkerTask {
regionViolation.setWorkerId(workerInfo.getId());
regionViolation.setEnterpriseName(workerInfo.getEnterpriseName());
String teamName = StringUtils.isNotEmpty(workerInfo.getTeamName()) ? workerInfo.getTeamName() : "";
String departmentName =StringUtils.isNotEmpty(workerInfo.getDepartmentName()) ? workerInfo.getDepartmentName() : "";
String departmentName = StringUtils.isNotEmpty(workerInfo.getDepartmentName()) ? workerInfo.getDepartmentName() : "";
regionViolation.setTeamName(teamName + departmentName);
regionViolation.setWorkerName(workerInfo.getWorkerName());
regionViolation.setEnterTime(workerInfo.getAttendTime());
@ -972,29 +989,6 @@ public class WorkerTask {
regionViolationService.saveBatch(list);
}
// /**
// * MQTT同步下发人员信息
// */
// @Scheduled(cron = "0 0/15 * * * ?")
// @SchedulerLock(name = "mqttIssuedWorkerInfo", lockAtMostFor = 1000 * 55, lockAtLeastFor = 1000 * 55)
// @RequestMapping("mqttIssuedWorkerInfo")
// public void mqttIssuedWorkerInfo() {
// List<ProjectUfaceConfig> configList = projectUfaceConfigMapper.selectList(Wrappers.<ProjectUfaceConfig>lambdaQuery()
// .eq(ProjectUfaceConfig::getSupplierType, MQTT.getCode())
// .eq(ProjectUfaceConfig::getIssueDev, 1));
// for (ProjectUfaceConfig projectUfaceConfig : configList) {
// List<XzHikvisionSync> list = xzHikvisionSyncService.list(Wrappers.<XzHikvisionSync>lambdaQuery()
// .eq(XzHikvisionSync::getProjectSn, projectUfaceConfig.getProjectSn())
// .eq(XzHikvisionSync::getIsSuccess, 0)
// .eq(XzHikvisionSync::getType, 1)
// .eq(XzHikvisionSync::getBigType, 1));
// for (XzHikvisionSync sync : list) {
// WorkerInfo workerInfo = workerInfoMapper.selectById(sync.getWhoId());
// MqttFaceDevUtil.addOrUpdatePerson(workerInfo, sync.getDeviceSn());
// }
// }
// }
/**
* 正赢 MQTT同步下发人员信息
*/
@ -1018,4 +1012,62 @@ public class WorkerTask {
}
}
}
/**
* 更新人员自动退场
*/
@Scheduled(cron = "0 0 1 * * ?")
@SchedulerLock(name = "updateWorkerExit", lockAtMostFor = 1000 * 55, lockAtLeastFor = 1000 * 55)
@RequestMapping("updateWorkerExit")
public void updateWorkerExit() {
Map<String, WorkerExitConfig> project2ConfigMap = workerExitConfigService.list(new LambdaQueryWrapper<WorkerExitConfig>()
.eq(WorkerExitConfig::getEnable, 1)).stream().collect(Collectors.toMap(WorkerExitConfig::getProjectSn, Function.identity(), (o1, o2) -> o1));
List<Project> projects = projectMapper.selectList(new LambdaQueryWrapper<Project>());
for (Project project : projects) {
String projectSn = project.getProjectSn();
WorkerExitConfig config = project2ConfigMap.get(projectSn);
if (config != null) {
//退场人员列表
HashMap<String, Object> param = new MapBuilder<String, Object>()
.put("projectSn", projectSn)
.put("exitIfAbsenceDay", config.getExitIfAbsenceDay())
.build();
param.put("workerIdList", StrUtil.split(config.getWorkerIds(), ","));
param.put("departmentIdList", StrUtil.split(config.getDepartmentIds(), ","));
param.put("teamIdList", StrUtil.split(config.getTeamIds(), ","));
param.put("enterpriseIdList", StrUtil.split(config.getEnterpriseIds(), ","));
// if (StrUtil.isNotBlank(config.getWorkerIds())) {
// } else if (StrUtil.isNotBlank(config.getDepartmentIds()) || StrUtil.isNotBlank(config.getTeamIds())) {
// } else if (StrUtil.isNotBlank(config.getEnterpriseIds())) {
// }
List<WorkerInfo> exitWorkers = workerAttendanceService.getAutoExitWorkers(param);
if (CollUtil.isEmpty(exitWorkers)) {
continue;
}
try {
if (Objects.equals(config.getEnableBlack(), 1)) {
for (WorkerInfo worker : exitWorkers) {
WorkerBlacklist workerBlacklist = new WorkerBlacklist();
workerBlacklist.setProjectSn(projectSn);
workerBlacklist.setWorkerId(worker.getId());
workerBlacklist.setWorkerName(worker.getWorkerName());
workerBlacklist.setIdCard(worker.getIdCard());
workerBlacklist.setAddReason("超过" + config.getExitIfAbsenceDay() + "天自动退场");
workerBlacklist.setReason(workerBlacklist.getAddReason());
workerBlacklist.setAddTime(DateUtil.now());
workerBlacklist.setCreateTime(new Date());
workerBlacklist.setIsExit(1);
workerBlacklistService.addWorkerBlacklist(workerBlacklist);
}
} else {
workerInfoService.updateWorkerExit(new MapBuilder<String, Object>()
.put("workerIdStr", exitWorkers.stream().map(w -> w.getId() + "").collect(Collectors.joining(",")))
.build());
}
} catch (Exception e) {
log.error("更新人员自动退场错误", e);
}
}
}
}
}

View File

@ -367,6 +367,8 @@ public class EasyPoiUtil {
image.setHeight(100);
image.setWidth(250);
image.setUrl(PathUtil.getBasePath() + "/" + fileName);
image.setType(ImageEntity.URL);
image.setRowspan(ImageEntity.EMBED);
return image;
}