Commit 387fa00f authored by 李秀明's avatar 李秀明

消防员出勤接口

parent f632bbad
......@@ -30,5 +30,23 @@ public interface SignMapper extends BaseMapper<Sign> {
int queryPersonNum(String bizOgrCode);
// Map<String, Object> getSignStatistic(@Param("bizOrgCode") String bizOgrCode, @Param("userId") String userId);
List<Map<String, Object>> selectCenterSignStats(
@Param("bizOrgCode") String bizOrgCode,
@Param("date") String date,
@Param("targetPassNum") Integer targetPassNum,
@Param("stationType") String stationType
);
List<Map<String, Object>> selectStationSignStats(@Param("bizOrgCode") String bizOrgCode);
IPage<Map<String, Object>> selectStationAttendanceStatsPage(
@Param("page") IPage<?> page,
@Param("date") String date,
@Param("stationType") String stationType,
@Param("bizOrgCode") String bizOrgCode,
@Param("attendanceStatus") String attendanceStatus,
@Param("targetPassNum") Integer targetPassNum,
@Param("sortField") String sortField,
@Param("sortOrder") String sortOrder
);
}
package com.yeejoin.amos.boot.module.jcs.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
public interface StationInfoMapper extends BaseMapper {
Long count(@Param("stationType") String stationType);
}
......@@ -148,7 +148,93 @@
GROUP BY biz_org_code
</select>
<!-- <select id="getSignStatistic" resultType="Map">-->
<select id="selectCenterSignStats" resultType="Map">
SELECT
t.BIZ_ORG_CODE AS bizOrgCode,
t.BIZ_ORG_NAME AS bizOrgName,
COUNT(DISTINCT t.user_id) AS num,
IF(COUNT(DISTINCT t.user_id) >= #{targetPassNum}, 'pass', 'fail') AS status
FROM
cb_sign t
RIGHT JOIN idx_biz_station_info s ON s.biz_ORG_CODE = t.biz_ORG_CODE
<where>
<if test="bizOrgCode != null and bizOrgCode != ''">
AND t.BIZ_ORG_CODE LIKE CONCAT(#{bizOrgCode}, '%')
</if>
<if test="date != null and date != ''">
AND t.DATE = #{date}
</if>
<if test="stationType != null and stationType != ''">
AND s.STATION_TYPE = #{stationType}
</if>
</where>
GROUP BY
t.BIZ_ORG_CODE
</select>
<select id="selectStationSignStats" resultType="Map">
SELECT
t.DATE AS date,
IFNULL(COUNT(DISTINCT t.user_id), 0) AS num
FROM
cb_sign t
WHERE
t.BIZ_ORG_CODE LIKE CONCAT(#{bizOrgCode}, '%')
AND t.DATE &gt;= DATE_SUB(CURDATE(), INTERVAL 7 DAY)
GROUP BY
t.DATE
</select>
<!-- </select>-->
<select id="selectStationAttendanceStatsPage" resultType="Map">
SELECT
t2.BIZ_ORG_CODE AS bizOrgCode,
t2.NAME AS bizOrgName,
CONCAT(t2.STATION_TYPE, '换流站') AS stationType,
#{date} AS date,
IFNULL(t1.num, 0) AS signNum,
(SELECT COUNT(1) FROM cb_firefighters t WHERE t.BIZ_ORG_CODE LIKE CONCAT(t2.BIZ_ORG_CODE, '%') AND t.PEOPLE_TYPE = 1601 AND t.IS_DELETE = false) AS firefighterNum,
ROUND(ROUND(IFNULL(t1.num, 0) / (SELECT COUNT(1) FROM cb_firefighters t WHERE t.BIZ_ORG_CODE LIKE CONCAT(t2.BIZ_ORG_CODE, '%') AND t.PEOPLE_TYPE = 1601 AND t.IS_DELETE = false), 4) * 100, 2) AS attendanceRate,
IF(IFNULL(t1.num, 0) >= #{targetPassNum}, '合格', '不合格') AS attendanceStatus
FROM (
SELECT
t.BIZ_ORG_CODE AS bizOrgCode,
COUNT( DISTINCT t.user_id ) AS num
FROM
cb_sign t
<where>
t.DATE = #{date}
<if test="bizOrgCode != null and bizOrgCode != ''">
AND t.BIZ_ORG_CODE LIKE CONCAT(#{bizOrgCode}, '%')
</if>
</where>
GROUP BY
t.BIZ_ORG_CODE
) t1
RIGHT JOIN idx_biz_station_info t2 ON t2.BIZ_ORG_CODE = t1.bizOrgCode
<where>
<if test="bizOrgCode != null and bizOrgCode != ''">
AND t2.BIZ_ORG_CODE LIKE CONCAT(#{bizOrgCode}, '%')
</if>
<if test="stationType != null and stationType != ''">
AND t2.STATION_TYPE = #{stationType}
</if>
<if test="attendanceStatus != null and attendanceStatus != ''">
AND IF(IFNULL(t1.num, 0) >= #{targetPassNum}, 'pass', 'fail') = #{attendanceStatus}
</if>
</where>
ORDER BY
<if test="sortField != null and sortField != ''">
<choose>
<when test="sortOrder == 'ascend'">
${sortField} ASC
</when>
<otherwise>
${sortField} DESC
</otherwise>
</choose>
</if>
<if test="sortField == null or sortField == ''">
signNum DESC
</if>
</select>
</mapper>
<?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.yeejoin.amos.boot.module.jcs.api.mapper.StationInfoMapper">
<select id="count" resultType="long">
SELECT
COUNT(1)
FROM idx_biz_station_info t
<where>
<if test="stationType != null and stationType != ''">
AND t.STATION_TYPE = #{stationType}
</if>
</where>
</select>
</mapper>
......@@ -3,42 +3,39 @@ package com.yeejoin.amos.boot.module.jcs.biz.controller;
import com.alibaba.fastjson.JSON;
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.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.common.api.core.framework.PersonIdentify;
import com.yeejoin.amos.boot.module.common.api.dto.FormValue;
import com.yeejoin.amos.boot.module.common.api.dto.OrgPersonFormDto;
import com.yeejoin.amos.boot.module.common.api.entity.OrgUsr;
import com.yeejoin.amos.boot.module.common.biz.service.impl.OrgUsrServiceImpl;
import com.yeejoin.amos.boot.module.jcs.api.dto.SignDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.SinStaticDto;
import com.yeejoin.amos.boot.module.jcs.api.entity.Sign;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import io.swagger.annotations.ApiOperation;
import com.yeejoin.amos.boot.module.jcs.biz.service.impl.SignServiceImpl;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RestController;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.servlet.http.HttpServletRequest;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import com.yeejoin.amos.boot.module.jcs.biz.service.impl.SignServiceImpl;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import org.springframework.beans.factory.annotation.Autowired;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.jcs.api.dto.SignDto;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
/**
* 打卡记录
*
......@@ -81,7 +78,7 @@ public class SignController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PutMapping(value = "/{sequenceNbr}")
@ApiOperation(httpMethod = "PUT", value = "根据sequenceNbr更新打卡记录", notes = "根据sequenceNbr更新打卡记录")
public ResponseModel<SignDto> updateBySequenceNbrSign(@RequestBody SignDto model,@PathVariable(value = "sequenceNbr") Long sequenceNbr) {
public ResponseModel<SignDto> updateBySequenceNbrSign(@RequestBody SignDto model, @PathVariable(value = "sequenceNbr") Long sequenceNbr) {
model.setSequenceNbr(sequenceNbr);
return ResponseHelper.buildResponse(signServiceImpl.updateWithModel(model));
}
......@@ -95,7 +92,7 @@ public class SignController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@DeleteMapping(value = "/{sequenceNbr}")
@ApiOperation(httpMethod = "DELETE", value = "根据sequenceNbr删除打卡记录", notes = "根据sequenceNbr删除打卡记录")
public ResponseModel<Boolean> deleteBySequenceNbr(HttpServletRequest request, @PathVariable(value = "sequenceNbr") Long sequenceNbr){
public ResponseModel<Boolean> deleteBySequenceNbr(HttpServletRequest request, @PathVariable(value = "sequenceNbr") Long sequenceNbr) {
return ResponseHelper.buildResponse(signServiceImpl.removeById(sequenceNbr));
}
......@@ -108,12 +105,12 @@ public class SignController extends BaseController {
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/{sequenceNbr}")
@ApiOperation(httpMethod = "GET",value = "根据sequenceNbr查询单个打卡记录", notes = "根据sequenceNbr查询单个打卡记录")
@ApiOperation(httpMethod = "GET", value = "根据sequenceNbr查询单个打卡记录", notes = "根据sequenceNbr查询单个打卡记录")
public ResponseModel<SignDto> selectOne(@PathVariable Long sequenceNbr) {
SignDto signDto = signServiceImpl.queryBySeq(sequenceNbr);
QueryWrapper<OrgUsr> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("sequence_nbr",signDto.getSignUserId());
queryWrapper.eq("is_delete",0);
queryWrapper.eq("sequence_nbr", signDto.getSignUserId());
queryWrapper.eq("is_delete", 0);
OrgUsr orgUsr = iOrgUsrService.getOne(queryWrapper);
try {
OrgPersonFormDto orgPersonFormDto = iOrgUsrService.selectPersonById(orgUsr.getSequenceNbr());
......@@ -133,17 +130,17 @@ public class SignController extends BaseController {
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/page")
@ApiOperation(httpMethod = "POST",value = "打卡记录分页查询", notes = "打卡记录分页查询")
@ApiOperation(httpMethod = "POST", value = "打卡记录分页查询", notes = "打卡记录分页查询")
public ResponseModel<IPage<SignDto>> queryForPage(@RequestBody SignDto dto) {
Page<SignDto> page = new Page<SignDto>();
page.setCurrent(dto.getCurrent());
page.setSize(dto.getSize());
IPage<SignDto> page1 = signServiceImpl.queryForSignPageByMapper(page, dto);
if (0 < page1.getRecords().size()) {
for(SignDto d : page1.getRecords()){
for (SignDto d : page1.getRecords()) {
QueryWrapper<OrgUsr> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("sequence_nbr",d.getSignUserId());
queryWrapper.eq("is_delete",0);
queryWrapper.eq("sequence_nbr", d.getSignUserId());
queryWrapper.eq("is_delete", 0);
OrgUsr orgUsr = iOrgUsrService.getOne(queryWrapper);
try {
OrgPersonFormDto orgPersonFormDto = iOrgUsrService.selectPersonById(orgUsr.getSequenceNbr());
......@@ -163,10 +160,10 @@ public class SignController extends BaseController {
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET",value = "人员信息卡统计打卡", notes = "人员信息卡统计打卡")
@ApiOperation(httpMethod = "GET", value = "人员信息卡统计打卡", notes = "人员信息卡统计打卡")
@GetMapping(value = "/statistic")
public ResponseModel<Map<String, Object>> getSignStatistic(@RequestParam(value = "userId" , required = false) String userId,
@RequestParam(value = "bizOrgCode" , required = false) String bizOrgCode) {
public ResponseModel<Map<String, Object>> getSignStatistic(@RequestParam(value = "userId", required = false) String userId,
@RequestParam(value = "bizOrgCode", required = false) String bizOrgCode) {
return ResponseHelper.buildResponse(signServiceImpl.getSignStatistic(userId, bizOrgCode));
}
......@@ -177,7 +174,7 @@ public class SignController extends BaseController {
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/static/page")
@ApiOperation(httpMethod = "POST",value = "打卡记录分页查询", notes = "打卡记录分页查询")
@ApiOperation(httpMethod = "POST", value = "打卡记录分页查询", notes = "打卡记录分页查询")
public ResponseModel<IPage<SinStaticDto>> queryStaticForPage(@RequestBody SinStaticDto dto) {
Page<SinStaticDto> page = new Page<>();
page.setCurrent(dto.getCurrent());
......@@ -192,12 +189,12 @@ public class SignController extends BaseController {
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/center/static/page")
@ApiOperation(httpMethod = "POST",value = "中心级卡片驻站消防员出勤柱状图", notes = "中心级卡片驻站消防员出勤柱状图")
@ApiOperation(httpMethod = "POST", value = "中心级卡片驻站消防员出勤柱状图", notes = "中心级卡片驻站消防员出勤柱状图")
public ResponseModel<Map<String, Object>> queryPeopleInfoForPage(@RequestBody SinStaticDto dto) {
String bizOrgCode = dto.getBizOrgCode();
if (StringUtils.isBlank(bizOrgCode)) {
ReginParams reginParam = JSON.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
if(null != reginParam) {
if (null != reginParam) {
bizOrgCode = reginParam.getPersonIdentity().getCompanyBizOrgCode();
}
}
......@@ -216,7 +213,7 @@ public class SignController extends BaseController {
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET",value = "打卡记录列表全部数据查询", notes = "打卡记录列表全部数据查询")
@ApiOperation(httpMethod = "GET", value = "打卡记录列表全部数据查询", notes = "打卡记录列表全部数据查询")
@GetMapping(value = "/list")
public ResponseModel<List<SignDto>> selectForList() {
return ResponseHelper.buildResponse(signServiceImpl.queryForSignList());
......@@ -229,12 +226,12 @@ public class SignController extends BaseController {
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET",value = "打卡记录列表全部数据查询", notes = "打卡记录列表全部数据查询")
@ApiOperation(httpMethod = "GET", value = "打卡记录列表全部数据查询", notes = "打卡记录列表全部数据查询")
@GetMapping(value = "/hasSign")
public ResponseModel<Boolean> hasSign(@RequestParam(value = "type" , required = false) String type,
@RequestParam(value = "userId" , required = false) String userId) {
String date = DateUtils.stampToDate(new Date().getTime(),DateUtils.DATE_PATTERN);
return ResponseHelper.buildResponse(signServiceImpl.hasSign(type,date,userId));
public ResponseModel<Boolean> hasSign(@RequestParam(value = "type", required = false) String type,
@RequestParam(value = "userId", required = false) String userId) {
String date = DateUtils.stampToDate(new Date().getTime(), DateUtils.DATE_PATTERN);
return ResponseHelper.buildResponse(signServiceImpl.hasSign(type, date, userId));
}
/**
......@@ -243,9 +240,51 @@ public class SignController extends BaseController {
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "POST",value = "保存打卡记录", notes = "保存打卡记录")
@ApiOperation(httpMethod = "POST", value = "保存打卡记录", notes = "保存打卡记录")
@PostMapping(value = "/saveSign")
public ResponseModel<Boolean> hasSign(@RequestBody SignDto dto) {
return ResponseHelper.buildResponse(signServiceImpl.saveSign(dto));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "今日出勤合格换流站(座)", notes = "今日出勤合格换流站(座)")
@GetMapping(value = "/center/sign-stats")
public ResponseModel<Map<String, Object>> getCenterSignStats(
@RequestParam(value = "bizOrgCode",required = false) String bizOrgCode,
@RequestParam(value = "date", required = false) String date,
@RequestParam(value = "targetPassNum", defaultValue = "8") Integer targetPassNum, // 出勤合格人数
@RequestParam(value = "stationType", required = false) String stationType
) {
if (StringUtils.isBlank(date)) {
date = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
}
return ResponseHelper.buildResponse(signServiceImpl.getCenterSignStats(bizOrgCode, date, targetPassNum, stationType));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "消防员出勤状态统计(近一周)", notes = "消防员出勤状态统计(近一周)")
@GetMapping(value = "/station/sign-stats")
public ResponseModel<Map<String, Object>> getStationSignStats(@RequestParam("bizOrgCode") String bizOrgCode) {
return ResponseHelper.buildResponse(signServiceImpl.getStationSignStats(bizOrgCode));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "换流站出勤情况", notes = "换流站出勤情况")
@GetMapping(value = "/station-attendance-stats/page")
public ResponseModel<IPage<Map<String, Object>>> getStationAttendanceStatsPage(
@RequestParam("pageNumber") Integer pageNumber,
@RequestParam("pageSize") Integer pageSize,
@RequestParam(value = "bizOrgCode", required = false) String bizOrgCode,
@RequestParam(value = "stationType", required = false) String stationType,
@RequestParam(value = "date", required = false) String date,
@RequestParam(value = "attendanceStatus", required = false) String attendanceStatus,
@RequestParam(value = "targetPassNum", defaultValue = "8") Integer targetPassNum, // 出勤合格人数
@RequestParam(value = "sorter", required = false) String sorter
) {
if (StringUtils.isBlank(date)) {
date = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
}
Page page = new Page(pageNumber, pageSize);
return ResponseHelper.buildResponse(signServiceImpl.getStationAttendanceStatsPage(page, date, stationType, bizOrgCode, attendanceStatus, targetPassNum, sorter));
}
}
......@@ -5,34 +5,32 @@ import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
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.yeejoin.amos.boot.module.common.biz.service.impl.FirefightersServiceImpl;
import com.yeejoin.amos.boot.module.jcs.api.dto.SignDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.SinStaticDto;
import com.yeejoin.amos.boot.module.jcs.api.entity.Sign;
import com.yeejoin.amos.boot.module.jcs.api.mapper.SignMapper;
import com.yeejoin.amos.boot.module.jcs.api.mapper.StationInfoMapper;
import com.yeejoin.amos.boot.module.jcs.api.service.ISignService;
import com.yeejoin.amos.boot.module.jcs.api.dto.SignDto;
import com.yeejoin.amos.component.rule.config.RuleConfig;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.typroject.tyboot.component.emq.EmqKeeper;
import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.time.LocalDate;
import java.util.*;
/**
* 打卡记录服务实现类
......@@ -43,19 +41,19 @@ import java.util.Map;
@Slf4j
@Service
@EnableScheduling
public class SignServiceImpl extends BaseService<SignDto,Sign,SignMapper> implements ISignService {
public class SignServiceImpl extends BaseService<SignDto, Sign, SignMapper> implements ISignService {
@Autowired
FirefightersServiceImpl iFirefightersService;
@Autowired
private EmqKeeper emqKeeper;
@Value("${mqtt.topic.person.sign}")
private String personSign;
@Value("${mqtt.topic.person.sign.zxj:sign/data/synZxj}")
private String personSignZxj;
@Autowired
FirefightersServiceImpl iFirefightersService;
private StationInfoMapper stationInfoMapper;
/**
* 分页查询
*/
......@@ -67,7 +65,7 @@ public class SignServiceImpl extends BaseService<SignDto,Sign,SignMapper> implem
* 分页查询
*/
public IPage<SignDto> queryForSignPageByMapper(IPage<SignDto> page, SignDto dto) {
return this.baseMapper.queryForPage(page,dto);
return this.baseMapper.queryForPage(page, dto);
}
/**
......@@ -78,7 +76,7 @@ public class SignServiceImpl extends BaseService<SignDto,Sign,SignMapper> implem
NumberFormat numberFormat = NumberFormat.getNumberInstance();
numberFormat.setMaximumFractionDigits(2);
sinStaticDtoIPage.getRecords().stream().forEach(e->{
sinStaticDtoIPage.getRecords().stream().forEach(e -> {
e.setAttendance(e.getSignNum() + "/" + e.getPersonOfDay());
});
......@@ -95,25 +93,25 @@ public class SignServiceImpl extends BaseService<SignDto,Sign,SignMapper> implem
* 列表查询 示例
*/
public List<SignDto> queryForSignList() {
return this.queryForList("" , false);
return this.queryForList("", false);
}
@Override
public Boolean hasSign(String type, String date,String userId) {
public Boolean hasSign(String type, String date, String userId) {
QueryWrapper<Sign> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("date",date);
if(StringUtils.isNotEmpty(type)) {
queryWrapper.eq("type",type);
queryWrapper.eq("date", date);
if (StringUtils.isNotEmpty(type)) {
queryWrapper.eq("type", type);
}
if(StringUtils.isNotEmpty(userId)) {
queryWrapper.eq("user_id",userId);
if (StringUtils.isNotEmpty(userId)) {
queryWrapper.eq("user_id", userId);
}
List<Sign> signs = this.baseMapper.selectList(queryWrapper);
if (StringUtils.isEmpty(type) && signs.size() != 2) {
return true;
} else {
if(StringUtils.isNotEmpty(type) && signs.size() == 1) {
if (StringUtils.isNotEmpty(type) && signs.size() == 1) {
return true;
}
return false;
......@@ -133,49 +131,49 @@ public class SignServiceImpl extends BaseService<SignDto,Sign,SignMapper> implem
@Override
public Boolean saveSign(SignDto dot) {
Sign sign = new Sign();
Map<String,Object> bizOrgCodeAndBizOrgName = iFirefightersService.getCompanyName(dot.getBizOrgCode());
Map<String, Object> bizOrgCodeAndBizOrgName = iFirefightersService.getCompanyName(dot.getBizOrgCode());
int num = this.baseMapper.queryPersonNum(bizOrgCodeAndBizOrgName.get("bizOrgCode").toString());
Bean.copyExistPropertis(dot,sign);
Bean.copyExistPropertis(dot, sign);
sign.setPersonOfDay(String.valueOf(num));
boolean save = this.save(sign);
// 发送mqtt 消息 同步人员打卡数据
if (save){
if (save) {
HashMap<String, Object> map = new HashMap<>();
map.put("bizOrgName", ObjectUtils.isEmpty(sign.getBizOrgName())?"":sign.getBizOrgName());
map.put("bizOrgCode", ObjectUtils.isEmpty(sign.getBizOrgCode())?"":sign.getBizOrgCode());
map.put("orgCode", ObjectUtils.isEmpty(sign.getOrgCode())?"":sign.getOrgCode());
map.put("signUserName", ObjectUtils.isEmpty(sign.getName())?"":sign.getName());
map.put("jobTitle", ObjectUtils.isEmpty(sign.getJobTitle())?"":sign.getJobTitle());
map.put("userId", ObjectUtils.isEmpty(sign.getSignUserId())?"":sign.getSignUserId());
map.put("signDate", ObjectUtils.isEmpty(sign.getSignTime())?"":sign.getSignTime());
map.put("recUserId", ObjectUtils.isEmpty(sign.getRecUserId())?"":sign.getRecUserId());
map.put("recUserName", ObjectUtils.isEmpty(sign.getRecUserName())?"":sign.getRecUserName());
map.put("sequenceNbr", ObjectUtils.isEmpty(sign.getRecUserName())?"":sign.getSequenceNbr());
String json=JSON.toJSONString(map, SerializerFeature.PrettyFormat,
map.put("bizOrgName", ObjectUtils.isEmpty(sign.getBizOrgName()) ? "" : sign.getBizOrgName());
map.put("bizOrgCode", ObjectUtils.isEmpty(sign.getBizOrgCode()) ? "" : sign.getBizOrgCode());
map.put("orgCode", ObjectUtils.isEmpty(sign.getOrgCode()) ? "" : sign.getOrgCode());
map.put("signUserName", ObjectUtils.isEmpty(sign.getName()) ? "" : sign.getName());
map.put("jobTitle", ObjectUtils.isEmpty(sign.getJobTitle()) ? "" : sign.getJobTitle());
map.put("userId", ObjectUtils.isEmpty(sign.getSignUserId()) ? "" : sign.getSignUserId());
map.put("signDate", ObjectUtils.isEmpty(sign.getSignTime()) ? "" : sign.getSignTime());
map.put("recUserId", ObjectUtils.isEmpty(sign.getRecUserId()) ? "" : sign.getRecUserId());
map.put("recUserName", ObjectUtils.isEmpty(sign.getRecUserName()) ? "" : sign.getRecUserName());
map.put("sequenceNbr", ObjectUtils.isEmpty(sign.getRecUserName()) ? "" : sign.getSequenceNbr());
String json = JSON.toJSONString(map, SerializerFeature.PrettyFormat,
SerializerFeature.WriteMapNullValue);
try {
emqKeeper.getMqttClient().publish(personSign, json.getBytes(), RuleConfig.DEFAULT_QOS, false);
map.put("personOfDay", ObjectUtils.isEmpty(sign.getPersonOfDay())?"":sign.getPersonOfDay());
map.put("type", ObjectUtils.isEmpty(sign.getType())?"":sign.getType());
map.put("photos", ObjectUtils.isEmpty(sign.getPhotos())?"":sign.getPhotos());
map.put("remarks", ObjectUtils.isEmpty(sign.getRemarks())?"":sign.getRemarks());
map.put("date", ObjectUtils.isEmpty(sign.getDate())?"":sign.getDate());
map.put("recDate", ObjectUtils.isEmpty(sign.getRecDate())?"":sign.getRecDate());
map.put("isDelete", ObjectUtils.isEmpty(sign.getIsDelete())?"":sign.getIsDelete());
map.put("source", ObjectUtils.isEmpty(sign.getSource())?"":sign.getSource());
String json1= JSON.toJSONString(map, SerializerFeature.PrettyFormat,
map.put("personOfDay", ObjectUtils.isEmpty(sign.getPersonOfDay()) ? "" : sign.getPersonOfDay());
map.put("type", ObjectUtils.isEmpty(sign.getType()) ? "" : sign.getType());
map.put("photos", ObjectUtils.isEmpty(sign.getPhotos()) ? "" : sign.getPhotos());
map.put("remarks", ObjectUtils.isEmpty(sign.getRemarks()) ? "" : sign.getRemarks());
map.put("date", ObjectUtils.isEmpty(sign.getDate()) ? "" : sign.getDate());
map.put("recDate", ObjectUtils.isEmpty(sign.getRecDate()) ? "" : sign.getRecDate());
map.put("isDelete", ObjectUtils.isEmpty(sign.getIsDelete()) ? "" : sign.getIsDelete());
map.put("source", ObjectUtils.isEmpty(sign.getSource()) ? "" : sign.getSource());
String json1 = JSON.toJSONString(map, SerializerFeature.PrettyFormat,
SerializerFeature.WriteMapNullValue);
// 发送emq消息转kafka
JSONObject jsonObject = new JSONObject();
jsonObject.put("topic", personSign);
jsonObject.put("data",json);
emqKeeper.getMqttClient().publish("emq.sign.created",jsonObject.toString().getBytes(),1,false);
jsonObject.put("data", json);
emqKeeper.getMqttClient().publish("emq.sign.created", jsonObject.toString().getBytes(), 1, false);
// 发送emq消息转kafka 同步业务库打卡表
JSONObject jsonObject1 = new JSONObject();
jsonObject1.put("topic", personSignZxj);
jsonObject1.put("data",json1);
emqKeeper.getMqttClient().publish("emq.bussSign.created",jsonObject1.toString().getBytes(),1,false);
jsonObject1.put("data", json1);
emqKeeper.getMqttClient().publish("emq.bussSign.created", jsonObject1.toString().getBytes(), 1, false);
} catch (MqttException e) {
log.info(String.format("发送eqm打卡消息失败:%s", e.getMessage()));
......@@ -197,21 +195,21 @@ public class SignServiceImpl extends BaseService<SignDto,Sign,SignMapper> implem
for (Map<String, Object> m : mapSign
) {
// 判断至少8人出勤
if(Integer.parseInt(m.get("num").toString()) < 8) {
if (Integer.parseInt(m.get("num").toString()) < 8) {
Map<String, Object> map = new HashMap<>();
map.put("bizOrgCode", m.get("bizOrgCode"));
map.put("bizOrgName", m.get("bizOrgName"));
mapList.add(map);
}
}
if(mapList.size() > 0) {
if (mapList.size() > 0) {
try {
emqKeeper.getMqttClient().publish("jcs/sign/put", JSONObject.toJSONString(mapList).getBytes(), 1, false);
} catch (MqttException exp) {
log.info(String.format("发送eqm转kafka消息失败:%s", exp.getMessage()));
}
}
if(mapSign.size() == 0) {
if (mapSign.size() == 0) {
Map<String, Object> map = new HashMap<>();
map.put("bizOrgCode", "");
mapList.add(map);
......@@ -222,4 +220,71 @@ public class SignServiceImpl extends BaseService<SignDto,Sign,SignMapper> implem
}
}
}
public Map<String, Object> getCenterSignStats(String bizOrgCode, String date, Integer targetPassNum, String stationType) {
List<Map<String, Object>> queryMaps = baseMapper.selectCenterSignStats(bizOrgCode, date, targetPassNum, stationType);
int passedStationNum = 0;
long allStationNum = stationInfoMapper.count(stationType);
for (Map<String, Object> queryMap : queryMaps) {
String status = queryMap.get("status").toString();
if (Objects.equals("pass", status)) {
passedStationNum++;
}
}
final int finalPassedStationNum = passedStationNum;
final int finalPassedStationNum1 = passedStationNum;
return new HashMap<String, Object>() {{
this.put("pass", finalPassedStationNum);
this.put("fail", allStationNum - finalPassedStationNum1);
}};
}
public Map<String, Object> getStationSignStats(String bizOrgCode) {
List<Map<String, Object>> maps = baseMapper.selectStationSignStats(bizOrgCode);
List<String> xAxis = new ArrayList<>();
List<Long> yAxis = new ArrayList<>();
LocalDate today = LocalDate.now();
for (int i = 0; i < 7; i++) {
String date = today.minusDays(i).toString();
xAxis.add(date);
yAxis.add(0L);
}
if (!maps.isEmpty()) {
for (Map<String, Object> map : maps) {
String date = map.get("date").toString();
long num = Long.parseLong(map.getOrDefault("num", "0").toString());
if (xAxis.contains(date)) {
int index = xAxis.indexOf(date);
yAxis.set(index, num);
}
}
}
return new HashMap<String, Object>() {{
this.put("xAxis", xAxis);
this.put("yAxis", yAxis);
}};
}
public IPage<Map<String, Object>> getStationAttendanceStatsPage(
IPage<?> page,
String date,
String stationType,
String bizOrgCode,
String attendanceStatus,
Integer targetPassNum,
String sorter
) {
String sortField = "", sortOrder = "";
if (org.springframework.util.StringUtils.hasText(sorter)) {
sortField = sorter.split("@")[0];
sortOrder = sorter.split("@")[1];
}
return baseMapper.selectStationAttendanceStatsPage(page, date, stationType, bizOrgCode, attendanceStatus, targetPassNum, sortField, sortOrder);
}
}
......@@ -3971,15 +3971,27 @@
</sql>
</changeSet>
<changeSet author="tw" id="20240801">
<changeSet author="ky" id="20240801">
<preConditions onFail="MARK_RAN">
<not>
<columnExists tableName="idx_biz_station_info" columnName="warehouse_id"/>
<columnExists tableName="idx_biz_station_info" columnName="station_type"/>
</not>
</preConditions>
<comment>新增属性字段 warehouse_id</comment>
<comment>新增属性字段 station_type</comment>
<sql>
alter table `idx_biz_station_info` add column `station_type` varchar(20) DEFAULT NULL COMMENT '换流站类型';
</sql>
</changeSet>
<changeSet author="lixm" id="20240801">
<preConditions onFail="MARK_RAN">
<not>
<columnExists tableName="idx_biz_station_info" columnName="biz_org_code"/>
</not>
</preConditions>
<comment>新增属性字段 biz_org_code</comment>
<sql>
alter table `idx_biz_station_info` add column `biz_org_code` varchar(50) DEFAULT NULL COMMENT 'BIZ_ORG_CODE';
</sql>
</changeSet>
</databaseChangeLog>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment