设备领用记录

This commit is contained in:
jjLv 2024-08-06 19:03:18 +08:00
parent 5a0084306a
commit 5db32861aa
8 changed files with 329 additions and 12 deletions

View File

@ -0,0 +1,49 @@
package com.bonus.common.entity.bracelet.exportVo;
import cn.afterturn.easypoi.excel.annotation.Excel;
import lombok.Data;
import java.util.Date;
/**
* @className:DeviceLyRecordExportVo
* @version:1.0
* @description:设备领用记录导出-vo
*/
@Data
public class DeviceLyRecordExportVo {
@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 deviceTypeName;
@Excel(name = "设备名称", width = 20.0,height = 15.0,orderNum = "5")
private String devName;
@Excel(name = "领用设备编码", width = 20.0,height = 15.0,orderNum = "6")
private String devCode;
@Excel(name = "班组负责人", width = 20.0,height = 15.0,orderNum = "7")
private String teamLeader;
@Excel(name = "领用时间", width = 20.0,height = 15.0,orderNum = "8")
private String lyTime;
@Excel(name = "归还时间", width = 20.0,height = 15.0,orderNum = "9")
private String ghTime;
@Excel(name = "备注", width = 20.0,height = 15.0,orderNum = "10")
private String remarks;
}

View File

@ -23,6 +23,10 @@ public class EquipmentReqVo {
private Long devId;
/**设备类型*/
private String devType;
/**
* 项目部id
*/
private Long departId;
/**
* 杆塔名称
*/
@ -31,6 +35,10 @@ public class EquipmentReqVo {
* 工程名称
*/
private String proName;
/**
* 项目部名称
*/
private String departName;
/**
* 领用班组
*/

View File

@ -0,0 +1,42 @@
package com.bonus.bracelet.controller;
import com.bonus.bracelet.mapper.DeviceLyRecordMapper;
import com.bonus.bracelet.service.IDeviceLyRecordService;
import com.bonus.bracelet.service.IEquipmentReqService;
import com.bonus.common.core.web.controller.BaseController;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.core.web.page.TableDataInfo;
import com.bonus.common.entity.bracelet.BraceletParamsDto;
import com.bonus.common.entity.bracelet.vo.EquipmentReqDataVo;
import com.bonus.common.entity.bracelet.vo.EquipmentReqVo;
import com.bonus.common.log.annotation.SysLog;
import com.bonus.common.log.enums.OperaType;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
/**
* @className:DeviceLyRecordController
* @description:设备领用记录-web层
*/
@RestController
@RequestMapping("/deviceLyRecord/")
@Slf4j
public class DeviceLyRecordController extends BaseController {
@Resource(name = "IDeviceLyRecordService")
private IDeviceLyRecordService service;
// @RequiresPermissions("basic:equipmentReq:list")
@GetMapping("list")
@SysLog(title = "综合查询", businessType = OperaType.QUERY,module = "综合查询->设备领用记录",details ="查询设备领用记录列表")
public TableDataInfo list(EquipmentReqVo dto) {
startPage();
List<EquipmentReqVo> list = service.getEquipmentReqLists(dto);
return getDataTable(list);
}
}

View File

@ -4,22 +4,14 @@ import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
import com.bonus.bracelet.mapper.BraceletMapper;
import com.bonus.bracelet.mapper.DeviceLyRecordMapper;
import com.bonus.bracelet.mapper.DeviceMapper;
import com.bonus.bracelet.service.IBraceletService;
import com.bonus.bracelet.service.IDeviceService;
import com.bonus.bracelet.service.IPersonMgeService;
import com.bonus.bracelet.service.ITeamMgeService;
import com.bonus.bracelet.service.*;
import com.bonus.common.core.constant.BusinessConstants;
import com.bonus.common.core.utils.ExcelStyleUtil;
import com.bonus.common.entity.bracelet.BraceletParamsDto;
import com.bonus.common.entity.bracelet.exportVo.DeviceExportVo;
import com.bonus.common.entity.bracelet.exportVo.PersonExportVo;
import com.bonus.common.entity.bracelet.exportVo.ShExportVo;
import com.bonus.common.entity.bracelet.exportVo.TeamExportVo;
import com.bonus.common.entity.bracelet.vo.BraceletVo;
import com.bonus.common.entity.bracelet.vo.DeviceVo;
import com.bonus.common.entity.bracelet.vo.PersonVo;
import com.bonus.common.entity.bracelet.vo.TeamVo;
import com.bonus.common.entity.bracelet.exportVo.*;
import com.bonus.common.entity.bracelet.vo.*;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.BeanUtils;
@ -37,6 +29,8 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import static com.bonus.common.core.text.Convert.str;
/**
* @authorcwchen
@ -62,11 +56,18 @@ public class ExportFileController {
@Resource(name = "IBraceletService")
private IBraceletService iBraceletService;
@Resource(name = "IDeviceLyRecordService")
private IDeviceLyRecordService iDeviceLyRecordService;
@Resource(name = "DeviceMapper")
private DeviceMapper deviceMapper;
@Resource(name = "BraceletMapper")
private BraceletMapper braceletMapper;
@Resource(name = "DeviceLyRecordMapper")
private DeviceLyRecordMapper deviceLyRecordMapper;
/**
* 导出人员
*
@ -211,4 +212,34 @@ public class ExportFileController {
log.error(e.toString(), e);
}
}
@GetMapping("exportDeviceLyRecord")
public void exportDeviceLyRecord(HttpServletRequest request, HttpServletResponse response, EquipmentReqVo dto) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
try {
List<DeviceLyRecordExportVo> deviceLyRecordExportVoList = new ArrayList<>();
List<EquipmentReqVo> deviceLists = iDeviceLyRecordService.getEquipmentReqLists(dto);
for (int i = 0; i < deviceLists.size(); i++) {
DeviceLyRecordExportVo exportVo = new DeviceLyRecordExportVo();
EquipmentReqVo vo = deviceLists.get(i);
BeanUtils.copyProperties(vo, exportVo);
exportVo.setId((i + 1) + "");
exportVo.setTeamLeader(vo.getTeamLeader()+ "\\" +vo.getLeaderPhone());
exportVo.setLyTime(sdf.format(vo.getLyTime()));
exportVo.setGhTime(vo.getGhTime() == null ? "在用" : sdf.format(vo.getGhTime()));
deviceLyRecordExportVoList.add(exportVo);
}
ExportParams exportParams = new ExportParams("设备领用记录", "设备领用记录", ExcelType.XSSF);
exportParams.setStyle(ExcelStyleUtil.class);
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, DeviceLyRecordExportVo.class, deviceLyRecordExportVoList);
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

@ -0,0 +1,30 @@
package com.bonus.bracelet.mapper;
import com.bonus.common.entity.bracelet.BraceletParamsDto;
import com.bonus.common.entity.bracelet.vo.EquipmentReqDataVo;
import com.bonus.common.entity.bracelet.vo.EquipmentReqVo;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Map;
/**
* @className:DeviceLyRecordMapper
* @description:设备领用记录-mapper
*/
@Repository(value = "DeviceLyRecordMapper")
public interface DeviceLyRecordMapper {
/**
* 设备领用列表
*
* @param dto
* @return List<EquipmentReqVo>
* @author cwchen
* @date 2024/8/5 13:53
*/
List<EquipmentReqVo> getEquipmentReqLists(EquipmentReqVo dto);
}

View File

@ -0,0 +1,26 @@
package com.bonus.bracelet.service;
import com.bonus.bracelet.mapper.DeviceLyRecordMapper;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.entity.bracelet.BraceletParamsDto;
import com.bonus.common.entity.bracelet.vo.EquipmentReqDataVo;
import com.bonus.common.entity.bracelet.vo.EquipmentReqVo;
import java.util.List;
/**
* @className:IDeviceLyRecordService
* @description:设备领用记录-serivice
*/
public interface IDeviceLyRecordService {
/**
* 设备领用列表
*
* @param dto
* @return List<EquipmentReqVo>
* @author cwchen
* @date 2024/8/5 13:51
*/
List<EquipmentReqVo> getEquipmentReqLists(EquipmentReqVo dto);
}

View File

@ -0,0 +1,47 @@
package com.bonus.bracelet.service.impl;
import com.bonus.bracelet.mapper.DeviceLyRecordMapper;
import com.bonus.bracelet.mapper.EquipmentReqMapper;
import com.bonus.bracelet.service.IDeviceLyRecordService;
import com.bonus.bracelet.service.IEquipmentReqService;
import com.bonus.common.core.constant.BusinessConstants;
import com.bonus.common.core.utils.encryption.Sm4Utils;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.entity.bracelet.BraceletParamsDto;
import com.bonus.common.entity.bracelet.vo.EquipmentReqDataVo;
import com.bonus.common.entity.bracelet.vo.EquipmentReqVo;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import javax.annotation.Resource;
import java.util.*;
/**
* @className:DeviceLyRecordServiceImpl
* @description:设备领用记录-serviceImpl
*/
@Slf4j
@Service(value = "IDeviceLyRecordService")
public class DeviceLyRecordServiceImpl implements IDeviceLyRecordService {
@Resource(name = "DeviceLyRecordMapper")
private DeviceLyRecordMapper mapper;
@Override
public List<EquipmentReqVo> getEquipmentReqLists(EquipmentReqVo dto) {
List<EquipmentReqVo> list = new ArrayList<>();
try {
list = mapper.getEquipmentReqLists(dto);
for (EquipmentReqVo vo : list) {
vo.setLeaderPhone(Sm4Utils.decode(vo.getLeaderPhone()));
}
} catch (Exception e) {
log.error(e.toString(), e);
}
return list;
}
}

View File

@ -0,0 +1,84 @@
<?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.DeviceLyRecordMapper">
<!--设备领用列表-->
<select id="getEquipmentReqLists" resultType="com.bonus.common.entity.bracelet.vo.EquipmentReqVo">
SELECT * FROM (
SELECT tdub.id,
tdub.dev_id AS devId,
tdub.dev_type AS devType,
tdu.remarks,
td.dev_code AS devCode,
td.dev_name AS devName,
tdub.ly_time AS lyTime,
tdub.gh_time AS ghTime,
sdd.dict_label AS deviceTypeName,
twt.team_name AS teamName,
twt.team_leader AS teamLeader,
twt.leader_phone AS leaderPhone,
tpd.depart_name AS departName,
tp.pro_name AS proName
FROM tb_dev_use tdu
LEFT JOIN t_work_team twt ON tdu.team_id = twt.team_id AND twt.del_flag = 0
LEFT JOIN tb_project tp ON tp.id = tdu.pro_id AND tp.del_flag = 0
LEFT JOIN tb_project_depart tpd ON tpd.id = tp.depart_id AND tpd.del_flag = 0
LEFT JOIN tb_dev_use_bid tdub ON tdu.id = tdub.id
LEFT JOIN tb_device td ON tdub.dev_id = td.id AND td.del_flag = 0
LEFT JOIN sys_dict_data sdd ON td.dev_type = sdd.dict_value AND sdd.dict_type = 'sys_device_type'
WHERE tdu.del_flag = 0 AND tdub.dev_type NOT IN ('shx')
<if test="devType!=null and devType!=''">
AND td.dev_type = #{devType}
</if>
UNION ALL
SELECT tdub.id,
tdub.dev_id AS devId,
tdub.dev_type AS devType,
tdu.remarks,
tsb.box_code AS devCode,
tsb.box_name AS devName,
tdub.ly_time AS lyTime,
tdub.gh_time AS ghTime,
'手环箱' AS deviceTypeName,
twt.team_name AS teamName,
twt.team_leader AS teamLeader,
twt.leader_phone AS leaderPhone,
tpd.depart_name AS departName,
tp.pro_name AS proName
FROM tb_dev_use tdu
LEFT JOIN t_work_team twt ON tdu.team_id = twt.team_id AND twt.del_flag = 0
LEFT JOIN tb_project tp ON tp.id = tdu.pro_id AND tp.del_flag = 0
LEFT JOIN tb_project_depart tpd ON tpd.id = tp.depart_id AND tpd.del_flag = 0
LEFT JOIN tb_dev_use_bid tdub ON tdu.id = tdub.id
LEFT JOIN tb_sh_box tsb ON tdub.dev_id = tsb.id AND tsb.del_flag = 0
WHERE tdu.del_flag = 0 AND tdub.dev_type = 'shx'
<if test="devType!=null and devType!='' and devType != 'shx'">
AND tsb.id = -1
</if>
) a
<where>
<if test="proName!=null and proName!=''">
AND INSTR(a.proName,#{proName}) > 0
</if>
<if test="departName!=null and departName!=''">
AND INSTR(a.departName,#{departName}) > 0
</if>
<if test="teamName!=null and teamName!=''">
AND INSTR(a.teamName,#{teamName}) > 0
</if>
<if test="devName!=null and devName!=''">
AND INSTR(a.devName,#{devName}) > 0
</if>
<if test="devCode!=null and devCode!=''">
AND INSTR(a.devCode,#{devCode}) > 0
</if>
<if test="lyTime!=null ">
AND date_format(a.lyTime,'%y%m%d') = date_format(#{lyTime},'%y%m%d')
</if>
<if test="ghTime!=null ">
AND date_format(a.ghTime,'%y%m%d') = date_format(#{ghTime},'%y%m%d')
</if>
</where>
</select>
</mapper>