项目部管理bug修复,预警历史记录功能

This commit is contained in:
jjLv 2024-08-09 14:59:03 +08:00
parent 693c1c2114
commit 8a9c176c68
18 changed files with 442 additions and 10 deletions

View File

@ -18,6 +18,9 @@ public class BusinessConstants {
/** 资源类型 1-人员*/
public static final String RESOURCE_TYPE_USER = "1";
/** 资源类型 6-临时人员*/
public static final String RESOURCE_TYPE_USERTEMP = "6";
public final static String XLSX = ".xlsx";
public final static String XLS = ".xls";

View File

@ -0,0 +1,41 @@
package com.bonus.common.entity.bracelet.exportVo;
import cn.afterturn.easypoi.excel.annotation.Excel;
import lombok.Data;
/**
* @className:QueryConstructionExportVo
* @version:1.0
* @description:施工记录导出-vo
*/
@Data
public class QueryConstructionExportVo {
@Excel(name = "序号", width = 10.0,height = 20.0, orderNum = "0")
private String id;
@Excel(name = "工程名称", width = 20.0,height = 15.0,orderNum = "1")
private String proName;
@Excel(name = "项目部名称", width = 20.0,height = 15.0,orderNum = "2")
private String departName;
@Excel(name = "施工班组", width = 20.0,height = 15.0,orderNum = "3")
private String teamName;
@Excel(name = "班组负责人", width = 20.0,height = 15.0,orderNum = "4")
private String teamLeader;
@Excel(name = "班组施工人数", width = 20.0,height = 15.0,orderNum = "5")
private int teamNum;
@Excel(name = "临时人数", width = 20.0,height = 15.0,orderNum = "6")
private int tempNum;
@Excel(name = "施工时间", width = 20.0,height = 15.0,orderNum = "7")
private String lyTime;
@Excel(name = "施工预警次数", width = 20.0,height = 15.0,orderNum = "8")
private int warnNum;
}

View File

@ -0,0 +1,29 @@
package com.bonus.common.entity.bracelet.exportVo;
import cn.afterturn.easypoi.excel.annotation.Excel;
import lombok.Data;
/**
* @className:WarnHistoryExportVo
* @version:1.0
* @description:预警历史记录导出-vo
*/
@Data
public class WarnHistoryExportVo {
@Excel(name = "序号", width = 10.0,height = 20.0, orderNum = "0")
private String id;
@Excel(name = "设备类型", width = 20.0,height = 15.0,orderNum = "1")
private String devTypeName;
@Excel(name = "设备名称", width = 20.0,height = 15.0,orderNum = "2")
private String devName;
@Excel(name = "预警时间", width = 20.0,height = 15.0,orderNum = "3")
private String warnTime;
@Excel(name = "预警内容", width = 20.0,height = 15.0,orderNum = "4")
private String warnContent;
}

View File

@ -106,6 +106,11 @@ public class PersonVo implements Serializable {
*/
private Integer certificateNum;
/**
* 资源类型
*/
private String sourceType;
/**
* 删除的文件ID
*/

View File

@ -37,8 +37,8 @@ public class QueryConstruction extends BaseEntity
@Excel(name = "班组负责人")
private String teamLeader;
/** 班组负责人 */
@Excel(name = "班组负责人")
/** 班组负责人电话 */
@Excel(name = "班组负责人电话")
private String teamPhone;
/** 班组施工人数 */

View File

@ -1,9 +1,13 @@
package com.bonus.common.entity.bracelet.vo;
import com.bonus.common.core.annotation.Excel;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
* @className:BallWarnVo
@ -27,4 +31,26 @@ public class WarnInfoVo {
private String base64Url;
/**人员姓名*/
private String name;
/** 班组id */
@Excel(name = "班组id")
private Long teamId;
/** 请求参数 */
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private Map<String, Object> params;
public Map<String, Object> getParams()
{
if (params == null)
{
params = new HashMap<>();
}
return params;
}
public void setParams(Map<String, Object> params)
{
this.params = params;
}
}

View File

@ -61,6 +61,12 @@ public class ExportFileController {
@Resource(name = "IDeviceLyRecordService")
private IDeviceLyRecordService iDeviceLyRecordService;
@Autowired
private IQueryConstructionService iQueryConstructionService;
@Resource(name = "IWarnHistoryService")
private IWarnHistoryService iWarnHistoryService;
@Autowired
private IBaseProjectService iBaseProjectService;
@ -276,4 +282,61 @@ public class ExportFileController {
log.error(e.toString(), e);
}
}
@GetMapping("exportConstructionRecord")
public void exportConstructionRecord(HttpServletRequest request, HttpServletResponse response, QueryConstruction dto) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
List<QueryConstructionExportVo> queryConstructionExportVoList = new ArrayList<>();
List<QueryConstruction> queryConstructionLists = iQueryConstructionService.selectConstructionList(dto);
for (int i = 0; i < queryConstructionLists.size(); i++) {
QueryConstructionExportVo exportVo = new QueryConstructionExportVo();
QueryConstruction vo = queryConstructionLists.get(i);
BeanUtils.copyProperties(vo, exportVo);
exportVo.setId((i + 1) + "");
exportVo.setTeamLeader(vo.getTeamLeader()+ "\\" +vo.getTeamPhone());
exportVo.setLyTime(sdf.format(vo.getLyTime()));
queryConstructionExportVoList.add(exportVo);
}
ExportParams exportParams = new ExportParams("施工记录", "施工记录", ExcelType.XSSF);
exportParams.setStyle(ExcelStyleUtil.class);
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, QueryConstructionExportVo.class, queryConstructionExportVoList);
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setHeader("content-disposition", "attachment;fileName=" + URLEncoder.encode("施工记录" + ".xlsx", "UTF-8"));
ServletOutputStream outputStream = response.getOutputStream();
workbook.write(outputStream);
outputStream.close();
workbook.close();
} catch (Exception e) {
log.error(e.toString(), e);
}
}
@GetMapping("exportWarnHistory")
public void exportWarnHistory(HttpServletRequest request, HttpServletResponse response, WarnInfoVo dto) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
List<WarnHistoryExportVo> warnHistoryExportVoList = new ArrayList<>();
List<WarnInfoVo> warnHistoryLists = iWarnHistoryService.getWarnLists(dto);
for (int i = 0; i < warnHistoryLists.size(); i++) {
WarnHistoryExportVo exportVo = new WarnHistoryExportVo();
WarnInfoVo vo = warnHistoryLists.get(i);
BeanUtils.copyProperties(vo, exportVo);
exportVo.setId((i + 1) + "");
exportVo.setWarnTime(sdf.format(vo.getWarnTime()));
warnHistoryExportVoList.add(exportVo);
}
ExportParams exportParams = new ExportParams("预警历史记录", "预警历史记录", ExcelType.XSSF);
exportParams.setStyle(ExcelStyleUtil.class);
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, WarnHistoryExportVo.class, warnHistoryExportVoList);
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setHeader("content-disposition", "attachment;fileName=" + URLEncoder.encode("预警历史记录" + ".xlsx", "UTF-8"));
ServletOutputStream outputStream = response.getOutputStream();
workbook.write(outputStream);
outputStream.close();
workbook.close();
} catch (Exception e) {
log.error(e.toString(), e);
}
}
}

View File

@ -8,6 +8,7 @@ import com.bonus.common.core.web.page.TableDataInfo;
import com.bonus.common.entity.bracelet.vo.PersonVo;
import com.bonus.common.entity.bracelet.vo.QueryConstruction;
import com.bonus.common.entity.bracelet.vo.SidebandDeviceVo;
import com.bonus.common.entity.bracelet.vo.WarnInfoVo;
import com.bonus.common.log.annotation.SysLog;
import com.bonus.common.log.enums.OperaType;
import com.bonus.common.security.annotation.RequiresPermissions;
@ -91,4 +92,17 @@ public class QueryConstructionController extends BaseController
}
}
/**
* 施工预警信息列表
* @param data
* @return
*/
@GetMapping("listWarn")
@SysLog(title = "综合查询", businessType = OperaType.QUERY, module = "综合查询->施工记录管理", details = "查询施工预警信息列表")
public TableDataInfo listWarn(QueryConstruction data) {
startPage();
List<WarnInfoVo> list = constructionService.getWarnLists(data);
return getDataTable(list);
}
}

View File

@ -0,0 +1,39 @@
package com.bonus.bracelet.controller;
import com.bonus.bracelet.service.IDeviceLyRecordService;
import com.bonus.bracelet.service.IWarnHistoryService;
import com.bonus.common.core.web.controller.BaseController;
import com.bonus.common.core.web.page.TableDataInfo;
import com.bonus.common.entity.bracelet.vo.EquipmentReqVo;
import com.bonus.common.entity.bracelet.vo.WarnInfoVo;
import com.bonus.common.log.annotation.SysLog;
import com.bonus.common.log.enums.OperaType;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;
/**
* @className:WarnHistoryController
* @description:预警历史记录-web层
*/
@RestController
@RequestMapping("/warnHistory/")
@Slf4j
public class WarnHistoryController extends BaseController {
@Resource(name = "IWarnHistoryService")
private IWarnHistoryService service;
@GetMapping("listWarn")
@SysLog(title = "综合查询", businessType = OperaType.QUERY,module = "综合查询->预警历史记录",details ="查询预警历史列表")
public TableDataInfo listWarn(WarnInfoVo dto) {
startPage();
List<WarnInfoVo> list = service.getWarnLists(dto);
return getDataTable(list);
}
}

View File

@ -3,6 +3,7 @@ package com.bonus.bracelet.mapper;
import com.bonus.common.entity.bracelet.vo.PersonVo;
import com.bonus.common.entity.bracelet.vo.QueryConstruction;
import com.bonus.common.entity.bracelet.vo.SidebandDeviceVo;
import com.bonus.common.entity.bracelet.vo.WarnInfoVo;
import java.util.List;
@ -35,4 +36,12 @@ public interface QueryConstructionMapper
*/
List<PersonVo> getTempLists(PersonVo data);
/**
* 施工预警信息列表
* @param data
* @return
*/
List<WarnInfoVo> getWarnLists(QueryConstruction data);
}

View File

@ -0,0 +1,23 @@
package com.bonus.bracelet.mapper;
import com.bonus.common.entity.bracelet.vo.EquipmentReqVo;
import com.bonus.common.entity.bracelet.vo.WarnInfoVo;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* @className:DeviceLyRecordMapper
* @description:设备领用记录-mapper
*/
@Repository(value = "WarnHistoryMapper")
public interface WarnHistoryMapper {
/**
* 预警历史记录列表
* @param dto
* @return
*/
List<WarnInfoVo> getWarnLists(WarnInfoVo dto);
}

View File

@ -3,6 +3,7 @@ package com.bonus.bracelet.service;
import com.bonus.common.entity.bracelet.vo.PersonVo;
import com.bonus.common.entity.bracelet.vo.QueryConstruction;
import com.bonus.common.entity.bracelet.vo.SidebandDeviceVo;
import com.bonus.common.entity.bracelet.vo.WarnInfoVo;
import java.util.List;
@ -33,4 +34,12 @@ public interface IQueryConstructionService
* @return
*/
List<PersonVo> getTempLists(PersonVo data);
/**
* 施工预警信息列表
* @param data
* @return
*/
List<WarnInfoVo> getWarnLists(QueryConstruction data);
}

View File

@ -0,0 +1,20 @@
package com.bonus.bracelet.service;
import com.bonus.common.entity.bracelet.vo.EquipmentReqVo;
import com.bonus.common.entity.bracelet.vo.WarnInfoVo;
import java.util.List;
/**
* @className:IWarnHistoryService
* @description:预警历史记录-serivice
*/
public interface IWarnHistoryService {
/**
* 预警历史记录列表
* @param dto
* @return
*/
List<WarnInfoVo> getWarnLists(WarnInfoVo dto);
}

View File

@ -1,15 +1,26 @@
package com.bonus.bracelet.service.impl;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.bonus.bracelet.mapper.QueryConstructionMapper;
import com.bonus.bracelet.service.IQueryConstructionService;
import com.bonus.common.core.constant.BusinessConstants;
import com.bonus.common.core.constant.HttpStatus;
import com.bonus.common.core.constant.SecurityConstants;
import com.bonus.common.core.domain.R;
import com.bonus.common.core.utils.encryption.Sm4Utils;
import com.bonus.common.entity.bracelet.vo.BaseProject;
import com.bonus.common.entity.bracelet.vo.PersonVo;
import com.bonus.common.entity.bracelet.vo.QueryConstruction;
import com.bonus.common.entity.bracelet.vo.WarnInfoVo;
import com.bonus.system.api.RemoteFileService;
import com.bonus.system.api.domain.SysFile;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
@ -26,6 +37,8 @@ public class QueryConstructionServiceImpl implements IQueryConstructionService
@Autowired
private QueryConstructionMapper constructionMapper;
@Resource
private RemoteFileService remoteFileService;
/**
*
@ -50,8 +63,12 @@ public class QueryConstructionServiceImpl implements IQueryConstructionService
@Override
public List<PersonVo> getTeamLists(PersonVo data) {
List<PersonVo> list = new ArrayList<>();
data.setSourceType(BusinessConstants.RESOURCE_TYPE_USER);
try {
list = constructionMapper.getTeamLists(data);
for (PersonVo vo : list) {
vo = handleData(vo);
}
} catch (Exception e) {
log.error(e.toString(), e);
@ -67,8 +84,42 @@ public class QueryConstructionServiceImpl implements IQueryConstructionService
@Override
public List<PersonVo> getTempLists(PersonVo data) {
List<PersonVo> list = new ArrayList<>();
data.setSourceType(BusinessConstants.RESOURCE_TYPE_USERTEMP);
try {
list = constructionMapper.getTempLists(data);
for (PersonVo vo : list) {
vo = handleData(vo);
}
} catch (Exception e) {
log.error(e.toString(), e);
}
return list;
}
public PersonVo handleData(PersonVo vo) {
vo.setIdCard(Sm4Utils.decode(vo.getIdCard()));
vo.setPhone(Sm4Utils.decode(vo.getPhone()));
R<SysFile> result = remoteFileService.getImgBase64(vo.getFilePath(), SecurityConstants.INNER);
if (result != null && result.getCode() == HttpStatus.SUCCESS && result.getData() != null) {
String jsonString = JSON.toJSONString(result.getData());
JSONObject item = JSON.parseObject(jsonString);
String base64 = item.getString("url");
vo.setBase64Url(base64);
}
return vo;
}
/**
* 施工预警信息
* @param data
* @return
*/
@Override
public List<WarnInfoVo> getWarnLists(QueryConstruction data) {
List<WarnInfoVo> list = new ArrayList<>();
try {
list = constructionMapper.getWarnLists(data);
} catch (Exception e) {
log.error(e.toString(), e);

View File

@ -0,0 +1,38 @@
package com.bonus.bracelet.service.impl;
import com.bonus.bracelet.mapper.DeviceLyRecordMapper;
import com.bonus.bracelet.mapper.WarnHistoryMapper;
import com.bonus.bracelet.service.IDeviceLyRecordService;
import com.bonus.bracelet.service.IWarnHistoryService;
import com.bonus.common.core.utils.encryption.Sm4Utils;
import com.bonus.common.entity.bracelet.vo.EquipmentReqVo;
import com.bonus.common.entity.bracelet.vo.WarnInfoVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
/**
* @className:DeviceLyRecordServiceImpl
* @description:设备领用记录-serviceImpl
*/
@Slf4j
@Service(value = "IWarnHistoryService")
public class WarnHistorympl implements IWarnHistoryService {
@Resource(name = "WarnHistoryMapper")
private WarnHistoryMapper mapper;
@Override
public List<WarnInfoVo> getWarnLists(WarnInfoVo dto) {
List<WarnInfoVo> list = new ArrayList<>();
try {
list = mapper.getWarnLists(dto);
} catch (Exception e) {
log.error(e.toString(), e);
}
return list;
}
}

View File

@ -21,7 +21,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectProjectList" parameterType="com.bonus.common.entity.bracelet.vo.BaseProject" resultMap="BaseProjectResult">
select a.id, depart_name, head_name, contact_information,count(b.source_id) as appnum, remarks,a.create_user,a.update_user
from tb_project_depart a
left join sys_file_source b on a.id = b.source_id and b.del_flag = 0
left join sys_file_source b on a.id = b.source_id and b.source_type = 5 and b.del_flag = 0
<where>
a.del_flag = 0
<if test="projectDepartName != null and projectDepartName != ''">

View File

@ -20,13 +20,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
left join tb_warn tw on tw.team_id = a.teamid and tw.del_flag = 0
<where>
<if test="proName != null and proName != ''">
and tp.pro_name = #{proName}
and INSTR(tp.pro_name,#{proName}) > 0
</if>
<if test="departName != null and departName != ''">
and tpd.depart_name = #{departName}
and INSTR(tpd.depart_name,#{departName}) > 0
</if>
<if test="teamName != null and teamName != ''">
and twt.team_name = #{teamName}
and INSTR(twt.team_name,#{teamName}) > 0
</if>
<if test="lyTime != null ">
and date_format(a.lytime,'%y%m%d') = date_format(#{lyTime},'%y%m%d')
@ -39,33 +39,51 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<!--班组人员设备列表-->
<select id="getTeamLists" resultType="com.bonus.common.entity.bracelet.vo.PersonVo">
select tp.id as id,tp.name as name,tp.sex as sex,tp.id_card as idCard,tp.phone as phone,tp.aqm_code as aqmCode,tp.mj_code as mjCode
select tp.id as id,tp.name as name,tp.sex as sex,tp.id_card as idCard,tp.phone as phone,
tp.aqm_code as aqmCode,tp.mj_code as mjCode,sfs.file_path AS filePath,sfs.id AS fileId
from t_work_team twt
left join tb_people tp on twt.team_id = tp.team_id and tp.del_flag = 0
left join sys_file_source sfs on tp.id = sfs.source_id AND sfs.source_type = #{sourceType} AND sfs.del_flag = 0
<where>
twt.team_id = #{teamId} and twt.del_flag = 0
<if test="name != null and name!=''">
AND INSTR(tp.name,#{name}) > 0
</if>
<if test="sex != null ">
AND INSTR(tp.sex,#{sex}) > 0
AND tp.sex = #{sex}
</if>
</where>
</select>
<!--临时人员设备列表-->
<select id="getTempLists" resultType="com.bonus.common.entity.bracelet.vo.PersonVo">
select tlu.id as id,tlu.name as name,tlu.sex as sex,tlu.id_card as idCard,tlu.phone as phone
select tlu.id as id,tlu.name as name,tlu.sex as sex,tlu.id_card as idCard,tlu.phone as phone,
sfs.file_path AS filePath,sfs.id AS fileId
from t_work_team twt
left join tb_ls_user tlu on twt.team_id = tlu.team_id
left join sys_file_source sfs on tlu.id = sfs.source_id AND sfs.source_type = #{sourceType} AND sfs.del_flag = 0
<where>
twt.team_id = #{teamId} and twt.del_flag = 0
<if test="name != null and name!=''">
AND INSTR(tlu.name,#{name}) > 0
</if>
<if test="sex != null ">
AND INSTR(tlu.sex,#{sex}) > 0
AND tlu.sex =#{sex}
</if>
</where>
</select>
<!--施工预警信息列表-->
<select id="getWarnLists" resultType="com.bonus.common.entity.bracelet.vo.WarnInfoVo">
select sdd.dict_label as devTypeName,tb.dev_name as devName,tw.warn_time as warnTime,tw.warn_content as warnContent
from tb_warn tw
left join tb_device tb on tw.dev_id = tb.id and tb.del_flag = 0
left join sys_dict_data sdd on sdd.dict_value = tb.dev_type and sdd.dict_type = 'sys_device_type'
where tw.team_id = #{teamId} and tw.dev_type = 1 and tw.del_flag = 0
union all
select '手环箱' as warnType,'——' as deviceName,tw.warn_time as warnTime,tw.warn_content as warnContent
from tb_warn tw
left join tb_bracelet tbb on tw.dev_id = tbb.id and tbb.del_flag = 0
where tw.team_id = #{teamId} and tw.dev_type = 0 and tw.del_flag = 0
</select>
</mapper>

View File

@ -0,0 +1,44 @@
<?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.bonus.bracelet.mapper.WarnHistoryMapper">
<!--设备领用列表-->
<select id="getWarnLists" resultType="com.bonus.common.entity.bracelet.vo.WarnInfoVo">
select * from(
select sdd.dict_label as devTypeName,tb.dev_name as devName,tw.warn_time as warnTime,tw.warn_content as warnContent
from tb_warn tw
left join tb_device tb on tw.dev_id = tb.id and tb.del_flag = 0
left join sys_dict_data sdd on sdd.dict_value = tb.dev_type and sdd.dict_type = 'sys_device_type'
where tw.dev_type = 1 and tw.del_flag = 0
<if test="devTypeName!=null and devTypeName!='' and devTypeName != 'shx'">
AND tb.dev_type = #{devTypeName}
</if>
<if test="devTypeName!=null and devTypeName!='' and devTypeName == 'shx'">
AND tb.id = -1
</if>
union all
select '手环箱' as warnType,'——' as deviceName,tw.warn_time as warnTime,tw.warn_content as warnContent
from tb_warn tw
left join tb_bracelet tbb on tw.dev_id = tbb.id and tbb.del_flag = 0
where tw.dev_type = 0 and tw.del_flag = 0
<if test="devTypeName!=null and devTypeName!='' and devTypeName != 'shx'">
AND tbb.id = -1
</if>
) a
<where>
<if test="devName!=null and devName!=''">
AND INSTR(a.devName,#{devName}) > 0
</if>
<if test="warnContent!=null and warnContent!=''">
AND INSTR(a.warnContent,#{warnContent}) > 0
</if>
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
and date_format(a.warnTime,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
</if>
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
and date_format(a.warnTime,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
</if>
</where>
</select>
</mapper>