更新工作汇报相关代码
This commit is contained in:
parent
d7ce59ce52
commit
78acb061cc
@ -9,7 +9,9 @@ import cn.iocoder.yudao.module.workReport.vo.WorkReportSaveReqVO;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
@ -26,11 +28,13 @@ import java.util.stream.Collectors;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||
|
||||
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
||||
|
||||
|
||||
@ -96,7 +100,7 @@ public class WorkReportController {
|
||||
@PreAuthorize("@ss.hasPermission('work:report:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportReportExcel(@Valid WorkReportPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
HttpServletResponse response) throws IOException {
|
||||
Page<WorkReport> page = new Page<>(pageReqVO.getPageNo(), pageReqVO.getPageSize());
|
||||
IPage<WorkReportRespVO> pageResult = reportService.getReportPage(page, pageReqVO);
|
||||
List<WorkReportRespVO> list = pageResult.getRecords();
|
||||
@ -106,6 +110,7 @@ public class WorkReportController {
|
||||
|
||||
/**
|
||||
* 查询汇报对象
|
||||
*
|
||||
* @param dictType 字典类型
|
||||
* @return
|
||||
*/
|
||||
@ -114,4 +119,15 @@ public class WorkReportController {
|
||||
return success(reportService.queryReportTo(dictType));
|
||||
}
|
||||
|
||||
/**
|
||||
* 工作汇报预览
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/workReportView")
|
||||
public CommonResult<?> workReportView(@RequestParam("id") Integer id) {
|
||||
return success(reportService.workReportView(id));
|
||||
}
|
||||
|
||||
}
|
@ -21,6 +21,7 @@ import org.apache.ibatis.annotations.Param;
|
||||
public interface WorkReportMapper extends BaseMapper<WorkReport> {
|
||||
|
||||
IPage<WorkReportRespVO> selectPage(@Param("page") Page page,@Param("pageReqVO") WorkReportPageReqVO pageReqVO);
|
||||
WorkReportRespVO selectByIdOne(@Param("pageReqVO") WorkReportPageReqVO pageReqVO);
|
||||
|
||||
Long queryReportCount(@Param("pageReqVO")WorkReportPageReqVO pageReqVO);
|
||||
}
|
@ -72,4 +72,12 @@ public interface WorkReportService extends IService<WorkReport> {
|
||||
* @return
|
||||
*/
|
||||
Long queryReportCount(WorkReportPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 工作汇报预览
|
||||
*
|
||||
* @param id 工作汇报id
|
||||
* @return 工作汇报详情
|
||||
*/
|
||||
String workReportView(Integer id);
|
||||
}
|
@ -1,12 +1,15 @@
|
||||
package cn.iocoder.yudao.module.workReport.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
||||
import cn.iocoder.yudao.module.system.api.dict.DictDataApi;
|
||||
import cn.iocoder.yudao.module.system.api.dict.dto.DictDataRespDTO;
|
||||
import cn.iocoder.yudao.module.system.api.permission.PermissionApi;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.UserDTO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
||||
import cn.iocoder.yudao.module.system.service.permission.RoleService;
|
||||
import cn.iocoder.yudao.module.system.service.user.AdminUserService;
|
||||
import cn.iocoder.yudao.module.workReport.entity.WorkReport;
|
||||
import cn.iocoder.yudao.module.workReport.mapper.WorkReportMapper;
|
||||
import cn.iocoder.yudao.module.workReport.service.WorkReportService;
|
||||
@ -23,6 +26,7 @@ import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -50,6 +54,9 @@ public class WorkReportServiceImpl extends ServiceImpl<WorkReportMapper, WorkRep
|
||||
@Resource
|
||||
private PermissionApi permissionApi;
|
||||
|
||||
@Resource
|
||||
private AdminUserService adminUserService;
|
||||
|
||||
@Override
|
||||
public Integer createReport(WorkReportSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
@ -138,4 +145,62 @@ public class WorkReportServiceImpl extends ServiceImpl<WorkReportMapper, WorkRep
|
||||
return reportMapper.queryReportCount(pageReqVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 工作汇报预览
|
||||
*
|
||||
* @param id 工作汇报id
|
||||
* @return 工作汇报详情
|
||||
*/
|
||||
@Override
|
||||
public String workReportView(Integer id) {
|
||||
|
||||
String html = "<div style=\"display: flex; justify-content: center; align-items: center; width: 100%;\">\n" +
|
||||
" <table style=\"width: 99.0769%; height: 240.594px; border-collapse: collapse; border: 1px solid black;\" data-sort=\"sortDisabled\">\n" +
|
||||
" <tbody>\n" +
|
||||
" <tr class=\"firstRow\" style=\"height: 19.5938px;\">\n" +
|
||||
" <td style=\"word-break: break-all; width: 99.9716%; text-align: center; height: 19.5938px; border: 1px solid black;\" colspan=\"2\" valign=\"top\" width=\"756.3333333333334\"> 工作汇报</td>\n" +
|
||||
" </tr>\n" +
|
||||
" <tr style=\"height: 45px;\">\n" +
|
||||
" <td style=\"word-break: break-all; width: 14.5491%; height: 45px; border: 1px solid black;\" valign=\"top\" width=\"105.33333333333333\" height=\"45\">汇报主题</td>\n" +
|
||||
" <td style=\"word-break: break-all; width: 85.4226%; height: 45px; border: 1px solid black;\" colspan=\"1\" valign=\"top\" width=\"630.3333333333334\" height=\"45\">reportTopic</td>\n" +
|
||||
" </tr>\n" +
|
||||
" <tr style=\"height: 47px;\">\n" +
|
||||
" <td style=\"word-break: break-all; width: 14.5491%; height: 47px; border: 1px solid black;\" valign=\"top\" width=\"105.33333333333333\" height=\"47\">汇报对象</td>\n" +
|
||||
" <td style=\"word-break: break-all; width: 85.4226%; height: 47px; border: 1px solid black;\" valign=\"top\" width=\"630.3333333333334\" height=\"47\">reportToStr</td>\n" +
|
||||
" </tr>\n" +
|
||||
" <tr style=\"height: 43px;\">\n" +
|
||||
" <td style=\"word-break: break-all; width: 14.5491%; height: 43px; border: 1px solid black;\" valign=\"top\" width=\"105.33333333333333\" height=\"43\">汇报内容</td>\n" +
|
||||
" <td style=\"word-break: break-all; width: 85.4226%; height: 43px; border: 1px solid black;\" valign=\"top\" width=\"630.3333333333334\" height=\"43\">reportContent</td>\n" +
|
||||
" </tr>\n" +
|
||||
" <tr style=\"height: 41px;\">\n" +
|
||||
" <td style=\"word-break: break-all; width: 14.5491%; height: 41px; border: 1px solid black;\" valign=\"top\" width=\"105.33333333333333\" height=\"41\">汇报人</td>\n" +
|
||||
" <td style=\"word-break: break-all; width: 85.4226%; height: 41px; border: 1px solid black;\" valign=\"top\" width=\"630.3333333333334\" height=\"41\">userName</td>\n" +
|
||||
" </tr>\n" +
|
||||
" <tr style=\"height: 45px;\">\n" +
|
||||
" <td style=\"word-break: break-all; width: 14.5491%; height: 45px; border: 1px solid black;\" colspan=\"1\" rowspan=\"1\" valign=\"top\" height=\"45\">汇报时间</td>\n" +
|
||||
" <td style=\"word-break: break-all; width: 85.4226%; height: 45px; border: 1px solid black;\" colspan=\"1\" rowspan=\"1\" valign=\"top\" width=\"630.3333333333334\" height=\"45\">reportTime</td>\n" +
|
||||
" </tr>\n" +
|
||||
" </tbody>\n" +
|
||||
" </table>\n" +
|
||||
"</div>\n" +
|
||||
"<p> </p>\n";
|
||||
|
||||
WorkReportPageReqVO pageReqVO = new WorkReportPageReqVO();
|
||||
pageReqVO.setId(id);
|
||||
WorkReportRespVO workReport = reportMapper.selectByIdOne(pageReqVO);
|
||||
List<Long> userIds = Arrays.stream(workReport.getReportTo().split(",")).map(Long::parseLong) // 转换为 Long 类型
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<AdminUserDO> userList = adminUserService.getUserList(userIds);
|
||||
List<String> userNames = userList.stream().map(item -> item.getNickname()).collect(Collectors.toList());
|
||||
String reportToStr = String.join(",", userNames);
|
||||
//替换字符串
|
||||
html = html.replace("reportTopic", workReport.getReportTopic());
|
||||
html = html.replace("reportToStr", reportToStr);
|
||||
html = html.replace("reportContent", workReport.getReportContent());
|
||||
html = html.replace("userName", workReport.getUserName());
|
||||
html = html.replace("reportTime", DateUtil.format(workReport.getReportTime(), "yyyy-MM-dd HH:mm"));
|
||||
return html;
|
||||
}
|
||||
|
||||
}
|
@ -16,6 +16,9 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
|
||||
@ToString(callSuper = true)
|
||||
public class WorkReportPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "id")
|
||||
private Integer id;
|
||||
|
||||
@Schema(description = "服务包id")
|
||||
private String servicePackageId;
|
||||
|
||||
|
@ -42,6 +42,9 @@ public class WorkReportRespVO {
|
||||
@ExcelProperty("汇报人姓名")
|
||||
private String userName;
|
||||
|
||||
@Schema(description = "汇报对象")
|
||||
private String reportTo;
|
||||
|
||||
@Schema(description = "汇报对象集合")
|
||||
private List<Long> reportTos;
|
||||
|
||||
|
@ -69,4 +69,13 @@
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectByIdOne" resultType="cn.iocoder.yudao.module.workReport.vo.WorkReportRespVO">
|
||||
SELECT wr.*, su.nickname as userName, su.avatar as avatar
|
||||
FROM work_report wr
|
||||
LEFT JOIN system_users su ON su.id = wr.user_id
|
||||
<where>
|
||||
wr.deleted = 0 and wr.id = #{pageReqVO.id}
|
||||
</where>
|
||||
</select>
|
||||
|
||||
</mapper>
|
@ -16,6 +16,8 @@ import cn.iocoder.yudao.module.inspection.query.InspectionStaffQuery;
|
||||
import cn.iocoder.yudao.module.inspection.service.InspectionStaffService;
|
||||
import cn.iocoder.yudao.module.inspection.vo.InspectionStaffExportVo;
|
||||
import cn.iocoder.yudao.module.inspection.vo.InspectionStaffSaveVo;
|
||||
import cn.iocoder.yudao.module.system.api.dict.DictDataApi;
|
||||
import cn.iocoder.yudao.module.system.api.dict.dto.DictDataRespDTO;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -41,6 +43,8 @@ import static cn.iocoder.yudao.framework.excel.core.util.ExcelUtils.exportBlankT
|
||||
public class InspectionStaffController extends BaseController {
|
||||
@Autowired
|
||||
private InspectionStaffService inspectionStaffService;
|
||||
@Autowired
|
||||
DictDataApi dictDataApi;
|
||||
|
||||
/**
|
||||
* 获取检测员工列表
|
||||
@ -131,8 +135,18 @@ public class InspectionStaffController extends BaseController {
|
||||
String[] array = ArrayUtil.toArray(allId, String.class);
|
||||
dropdownColumns.put(13, array); // 驾照类型
|
||||
|
||||
//查询学历
|
||||
List<DictDataRespDTO> education = dictDataApi.getDictDataList("company_staff_edu");
|
||||
String[] array1 = education.stream()
|
||||
.map(DictDataRespDTO::getLabel)
|
||||
.toArray(String[]::new);
|
||||
|
||||
|
||||
dropdownColumns.put(4, array1);
|
||||
int[] dateColumns = {8, 9,10};
|
||||
|
||||
// 导出空白模板到Excel
|
||||
exportBlankTemplate(response, "staff_template.xlsx", "员工信息", headerMap, dropdownColumns, true);
|
||||
exportBlankTemplate(response, "staff_template.xlsx", "员工信息", headerMap, dropdownColumns, dateColumns,true);
|
||||
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@ import org.apache.poi.hssf.usermodel.DVConstraint;
|
||||
import org.apache.poi.hssf.usermodel.HSSFDataValidation;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.ss.util.CellRangeAddressList;
|
||||
import org.apache.poi.ss.util.CellReference;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@ -88,17 +89,21 @@ public class ExcelUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出空白模板Excel,并为指定列添加下拉框
|
||||
* 导出空白模板Excel,并为指定列添加下拉框和日期时间格式验证
|
||||
*
|
||||
* @param response HttpServletResponse
|
||||
* @param fileName 文件名
|
||||
* @param sheetName 工作表名称
|
||||
* @param headerMap 表头字段映射(列索引 -> 列名称)
|
||||
* @param dropdownColumns 带下拉框的列及选项(列索引 -> 下拉框选项数组)
|
||||
* @param dateTimeColumns 需要验证日期时间格式的列(列索引)
|
||||
* @param isMultiSelect 是否允许多选
|
||||
* @throws IOException
|
||||
*/
|
||||
public static void exportBlankTemplate(HttpServletResponse response, String fileName, String sheetName,
|
||||
Map<Integer, String> headerMap,
|
||||
Map<Integer, String[]> dropdownColumns,
|
||||
int[] dateTimeColumns,
|
||||
boolean isMultiSelect) throws IOException {
|
||||
Workbook workbook = new XSSFWorkbook();
|
||||
Sheet sheet = workbook.createSheet(sheetName);
|
||||
@ -116,6 +121,13 @@ public class ExcelUtils {
|
||||
}
|
||||
}
|
||||
|
||||
// 添加日期时间格式验证到指定列
|
||||
if (dateTimeColumns != null) {
|
||||
for (int columnIndex : dateTimeColumns) {
|
||||
addDateTimeValidation(sheet, columnIndex);
|
||||
}
|
||||
}
|
||||
|
||||
// 设置响应头,指示浏览器下载文件
|
||||
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||
response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(fileName, StandardCharsets.UTF_8.name()) + ".xlsx");
|
||||
@ -129,6 +141,25 @@ public class ExcelUtils {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 为指定列添加日期时间格式验证
|
||||
*
|
||||
* @param sheet 工作表
|
||||
* @param columnIndex 需要验证日期时间格式的列索引
|
||||
*/
|
||||
private static void addDateTimeValidation(Sheet sheet, int columnIndex) {
|
||||
// 使用 Excel 的数据验证机制为指定列添加日期时间格式验证
|
||||
DataValidationHelper validationHelper = sheet.getDataValidationHelper();
|
||||
DataValidationConstraint constraint = validationHelper.createCustomConstraint(
|
||||
"AND(ISNUMBER(" + CellReference.convertNumToColString(columnIndex) + "1), TEXT(" + CellReference.convertNumToColString(columnIndex) + "1, \"yyyy-mm-dd hh:mm:ss\")= " +
|
||||
"\"yyyy-mm-dd\")");
|
||||
|
||||
CellRangeAddressList addressList = new CellRangeAddressList(1, sheet.getPhysicalNumberOfRows(), columnIndex, columnIndex);
|
||||
DataValidation validation = validationHelper.createValidation(constraint, addressList);
|
||||
|
||||
sheet.addValidationData(validation);
|
||||
}
|
||||
|
||||
|
||||
// 修改下拉框验证方法,支持多选功能
|
||||
private static void addDropdownValidation(Sheet sheet, int column, String[] options, boolean isMultiSelect) {
|
||||
|
Loading…
Reference in New Issue
Block a user