diff --git a/bonus-modules/bonus-system/src/main/java/com/bonus/system/dept/controller/ProDeptRoleController.java b/bonus-modules/bonus-system/src/main/java/com/bonus/system/dept/controller/ProDeptRoleController.java index 6e62eb3..81b781e 100644 --- a/bonus-modules/bonus-system/src/main/java/com/bonus/system/dept/controller/ProDeptRoleController.java +++ b/bonus-modules/bonus-system/src/main/java/com/bonus/system/dept/controller/ProDeptRoleController.java @@ -1,6 +1,8 @@ package com.bonus.system.dept.controller; +import com.alibaba.nacos.common.utils.CollectionUtils; import com.bonus.common.core.utils.StringHelper; +import com.bonus.common.core.utils.poi.MultiSheetExcelExporter; import com.bonus.common.core.web.controller.BaseController; import com.bonus.common.core.web.domain.AjaxResult; import com.bonus.common.core.web.page.TableDataInfo; @@ -10,6 +12,8 @@ import com.bonus.common.security.annotation.RequiresPermissions; import com.bonus.common.security.utils.SecurityUtils; import com.bonus.system.api.domain.MapVo; import com.bonus.system.api.domain.SysUser; +import com.bonus.system.att.entity.AttDataDetailsBean; +import com.bonus.system.att.entity.AttMonthReportBean; import com.bonus.system.basic.dao.SysOrgDao; import com.bonus.system.dept.dao.ProDeptRoleDao; import com.bonus.system.dept.entity.EightRoleBean; @@ -18,9 +22,11 @@ import com.bonus.system.dept.entity.ProDeptRoleBean; import com.bonus.system.dept.entity.ProDeptRoleDo; import com.bonus.system.dept.service.ProDeptRoleService; import lombok.extern.slf4j.Slf4j; +import org.apache.poi.ss.usermodel.*; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; import java.util.*; /** @@ -272,7 +278,7 @@ public class ProDeptRoleController extends BaseController { @Log(title = "项目部管理->项目部角色管理->查询八大员内部详情", businessType = BusinessType.QUERY) public TableDataInfo getOrgEightRoleDetail(EightRoleBean bean) { try{ - List orgEightRoleDetail = proDeptRoleService.getOrgEightRoleDetail(bean); + List orgEightRoleDetail = proDeptRoleService.getOrgEightRoleDetail(bean); return endPage(orgEightRoleDetail); }catch (Exception e){ log.error(e.toString(),e); @@ -295,4 +301,310 @@ public class ProDeptRoleController extends BaseController { return error(); } + @GetMapping("/exportEightMembers") + public void exportEightMembers(HttpServletResponse response, EightRoleBean bean) { + try { + MultiSheetExcelExporter exporter = new MultiSheetExcelExporter(); + //将表格时间区间取出来做标题 + String title = bean.getParentOrgName(); + List eightRoleVoList = proDeptRoleService.getOrgEightRoleList(bean); + Sheet departmentSheet1 = exporter.createSheet(" 八大员统计报表详情"); + List departmentHeaders1 = Arrays.asList("序号", "分公司名称", "缺员情况", "兼职情况"); + exporter.addHeaderRowAndTitle(departmentSheet1, departmentHeaders1, title); + List> departmentData1 = new ArrayList<>(); + + List lackOrgIds = new ArrayList<>(); + List moreOrgIds = new ArrayList<>(); + + for (int i = 0; i < eightRoleVoList.size(); i++){ + Map map = new LinkedHashMap<>(); + map.put("序号", i + 1); + map.put("分公司名称", eightRoleVoList.get(i).getParentOrgName()); + map.put("缺员情况", eightRoleVoList.get(i).getLackOrgName()); + map.put("兼职情况", eightRoleVoList.get(i).getMoreOrgName()); + departmentData1.add(map); + + // 将当前项的LackOrgId加入到列表中 + String currentLackOrgId = eightRoleVoList.get(i).getLackOrgId(); + lackOrgIds.add(currentLackOrgId); + + // 将当前项的moreOrgId加入到列表中 + String currentMoreOrgId = eightRoleVoList.get(i).getMoreOrgId(); + moreOrgIds.add(currentMoreOrgId); + + } + exporter.addDataRows(departmentSheet1, departmentData1, departmentHeaders1); + + //缺员情况详情的数据导出 + if (CollectionUtils.isNotEmpty(lackOrgIds)){ + EightRoleBean dayTable = new EightRoleBean(); + Sheet departmentSheet2 = exporter.createSheet("缺员情况详情"); + List departmentHeaders2 = Arrays.asList("序号", "项目部名称", "项目经理", + "安全员", "质检员", "项目总工", "机械员", "资料员", "施工员", "材料员", "其他"); + exporter.addHeaderRowAndTitle(departmentSheet2, departmentHeaders2, title); + List> departmentData2 = new ArrayList<>(); + for (String lackOrgId : lackOrgIds){ + if (lackOrgId == null){ + continue; + } + dayTable.setLackOrgId(lackOrgId); + List lackOrgNameList = proDeptRoleService.getOrgEightRoleDetail(dayTable); + for (int i = 0; i < lackOrgNameList.size(); i++){ + Map map = new LinkedHashMap<>(); + map.put("序号", i + 1); + map.put("项目部名称", lackOrgNameList.get(i).getOrgName()); + map.put("项目经理", lackOrgNameList.get(i).getProjectManager()); + map.put("安全员", lackOrgNameList.get(i).getSafetyOfficer()); + map.put("质检员", lackOrgNameList.get(i).getQualityInspector()); + map.put("项目总工", lackOrgNameList.get(i).getChiefEngineer()); + map.put("机械员", lackOrgNameList.get(i).getMechanicalStaff()); + map.put("资料员", lackOrgNameList.get(i).getDocumentStaff()); + map.put("施工员", lackOrgNameList.get(i).getConstructionStaff()); + map.put("材料员", lackOrgNameList.get(i).getMaterialStaff()); + map.put("其他", lackOrgNameList.get(i).getOther()); + departmentData2.add(map); + } + } + exporter.addDataRows(departmentSheet2, departmentData2, departmentHeaders2); + } + + if(CollectionUtils.isNotEmpty(moreOrgIds)){ + //兼职情况详情的数据导出 + Sheet departmentSheet3 = exporter.createSheet("兼职情况详情"); + List departmentHeaders3 = Arrays.asList("序号", "项目部名称", "项目经理", + "安全员", "质检员", "项目总工", "机械员", "资料员", "施工员", "材料员", "其他"); + exporter.addHeaderRowAndTitle(departmentSheet3, departmentHeaders3, title); + List> departmentData3 = new ArrayList<>(); + for (String moreOrgId : moreOrgIds) { + if(moreOrgId == null){ + continue; + } + EightRoleBean dayTable = new EightRoleBean(); + dayTable.setMoreOrgId(moreOrgId); + List moreOrgNameList = proDeptRoleService.getOrgEightRoleDetail(dayTable); + for (int i = 0; i < moreOrgNameList.size(); i++){ + Map map = new LinkedHashMap<>(); + map.put("序号", i + 1); + + map.put("项目部名称", moreOrgNameList.get(i).getOrgName()); + if(moreOrgNameList.get(i).getProjectManager().equals("兼职")){ + ProDeptRoleBean beans = new ProDeptRoleBean(); + beans.setOrgId(moreOrgNameList.get(i).getOrgId()); + beans.setDeptRoleId(1L); + List projectList = proDeptRoleService.getMoreOrgData(beans); + String project = ""; + if(!projectList.isEmpty()){ + for (int j = 0; j < projectList.size(); j++){ + project = project + "," + projectList.get(j).getUserName(); + } + } + map.put("项目经理", project); + map.put("项目经理_isPartTime", true); // 添加一个标志位表示该字段为兼职 + }else{ + map.put("项目经理", moreOrgNameList.get(i).getProjectManager()); + map.put("项目经理_isPartTime", false); // 标志位表示该字段不是兼职 + } + + if(moreOrgNameList.get(i).getSafetyOfficer().equals("兼职")){ + ProDeptRoleBean beans = new ProDeptRoleBean(); + beans.setOrgId(moreOrgNameList.get(i).getOrgId()); + beans.setDeptRoleId(2L); + List safetyOfficerList = proDeptRoleService.getMoreOrgData(beans); + String safetyOfficer = ""; + if(!safetyOfficerList.isEmpty()){ + for (int j = 0; j < safetyOfficerList.size(); j++){ + safetyOfficer = safetyOfficer + "," + safetyOfficerList.get(j).getUserName(); + } + } + map.put("安全员", safetyOfficer); + map.put("安全员_isPartTime", true); + }else{ + map.put("安全员", moreOrgNameList.get(i).getSafetyOfficer()); + map.put("安全员_isPartTime", false); + } + + if(moreOrgNameList.get(i).getQualityInspector().equals("兼职")){ + ProDeptRoleBean beans = new ProDeptRoleBean(); + beans.setOrgId(moreOrgNameList.get(i).getOrgId()); + beans.setDeptRoleId(3L); + List qualityInspectorList = proDeptRoleService.getMoreOrgData(beans); + String qualityInspector = ""; + if(!qualityInspectorList.isEmpty()){ + for (int j = 0; j < qualityInspectorList.size(); j++){ + qualityInspector = qualityInspector + "," + qualityInspectorList.get(j).getUserName(); + } + } + map.put("质检员", qualityInspector); + map.put("质检员_isPartTime", true); + }else{ + map.put("质检员", moreOrgNameList.get(i).getQualityInspector()); + map.put("质检员_isPartTime", false); + } + + + if(moreOrgNameList.get(i).getChiefEngineer().equals("兼职")){ + ProDeptRoleBean beans = new ProDeptRoleBean(); + beans.setOrgId(moreOrgNameList.get(i).getOrgId()); + beans.setDeptRoleId(4L); + List chiefEngineerList = proDeptRoleService.getMoreOrgData(beans); + String chiefEngineer = ""; + if(!chiefEngineerList.isEmpty()){ + for (int j = 0; j < chiefEngineerList.size(); j++){ + chiefEngineer = chiefEngineer + "," + chiefEngineerList.get(j).getUserName(); + } + } + map.put("项目总工", chiefEngineer); + map.put("项目总工_isPartTime", true); + }else{ + map.put("项目总工", moreOrgNameList.get(i).getChiefEngineer()); + map.put("项目总工_isPartTime", false); + } + + if(moreOrgNameList.get(i).getMechanicalStaff().equals("兼职")){ + ProDeptRoleBean beans = new ProDeptRoleBean(); + beans.setOrgId(moreOrgNameList.get(i).getOrgId()); + beans.setDeptRoleId(5L); + List mechanicalStaffList = proDeptRoleService.getMoreOrgData(beans); + String mechanicalStaff = ""; + if(!mechanicalStaffList.isEmpty()){ + for (int j = 0; j < mechanicalStaffList.size(); j++){ + mechanicalStaff = mechanicalStaff + "," + mechanicalStaffList.get(j).getUserName(); + } + } + map.put("机械员", mechanicalStaff); + map.put("机械员_isPartTime", true); + }else{ + map.put("机械员", moreOrgNameList.get(i).getMechanicalStaff()); + map.put("机械员_isPartTime", false); + } +// map.put("项目总工", moreOrgNameList.get(i).getChiefEngineer()); +// map.put("机械员", moreOrgNameList.get(i).getMechanicalStaff()); + if(moreOrgNameList.get(i).getDocumentStaff().equals("兼职")){ + ProDeptRoleBean beans = new ProDeptRoleBean(); + beans.setOrgId(moreOrgNameList.get(i).getOrgId()); + beans.setDeptRoleId(6L); + List documentStaffList = proDeptRoleService.getMoreOrgData(beans); + String documentStaff = ""; + if(!documentStaffList.isEmpty()){ + for (int j = 0; j < documentStaffList.size(); j++){ + documentStaff = documentStaff + "," + documentStaffList.get(j).getUserName(); + } + } + map.put("资料员", documentStaff); + map.put("资料员_isPartTime", true); + }else { + map.put("资料员", moreOrgNameList.get(i).getDocumentStaff()); + map.put("资料员_isPartTime", false); + } + +// map.put("资料员", moreOrgNameList.get(i).getDocumentStaff()); + if(moreOrgNameList.get(i).getConstructionStaff().equals("兼职")){ + ProDeptRoleBean beans = new ProDeptRoleBean(); + beans.setOrgId(moreOrgNameList.get(i).getOrgId()); + beans.setDeptRoleId(7L); + List constructionStaffList = proDeptRoleService.getMoreOrgData(beans); + String constructionStaff = ""; + if(!constructionStaffList.isEmpty()){ + for (int j = 0; j < constructionStaffList.size(); j++){ + constructionStaff = constructionStaff + "," + constructionStaffList.get(j).getUserName(); + } + } + map.put("施工员", constructionStaff); + map.put("施工员_isPartTime", true); + }else { + map.put("施工员", moreOrgNameList.get(i).getConstructionStaff()); + map.put("施工员_isPartTime", false); + } +// map.put("施工员", moreOrgNameList.get(i).getConstructionStaff()); + if(moreOrgNameList.get(i).getMaterialStaff().equals("兼职")){ + ProDeptRoleBean beans = new ProDeptRoleBean(); + beans.setOrgId(moreOrgNameList.get(i).getOrgId()); + beans.setDeptRoleId(8L); + List materialStaffList = proDeptRoleService.getMoreOrgData(beans); + String materialStaff = ""; + if(!materialStaffList.isEmpty()){ + for (int j = 0; j < materialStaffList.size(); j++){ + materialStaff = materialStaff + "," + materialStaffList.get(j).getUserName(); + } + } + map.put("材料员", materialStaff); + map.put("材料员_isPartTime", true); + }else { + map.put("材料员", moreOrgNameList.get(i).getMaterialStaff()); + map.put("材料员_isPartTime", false); + } + +// map.put("材料员", moreOrgNameList.get(i).getMaterialStaff()); + if(moreOrgNameList.get(i).getOther().equals("兼职")){ + ProDeptRoleBean beans = new ProDeptRoleBean(); + beans.setOrgId(moreOrgNameList.get(i).getOrgId()); + beans.setDeptRoleId(9L); + List otherList = proDeptRoleService.getMoreOrgData(beans); + String other = ""; + if(!otherList.isEmpty()){ + for (int j = 0; j < otherList.size(); j++){ + other = other + "," + otherList.get(j).getUserName(); + } + } + map.put("其他", other); + map.put("其他_isPartTime", true); + }else { + map.put("其他", moreOrgNameList.get(i).getOther()); + map.put("其他_isPartTime", false); + } + departmentData3.add(map); + } + } + exporter.addDataRows(departmentSheet3, departmentData3, departmentHeaders3); + + // 获取工作簿对象 + Workbook workbook = getWorkbookFromSheet(departmentSheet3); // 假设这里有一个方法可以获取Workbook对象 + // 设置单元格样式 + setCellStyle(workbook, departmentSheet3, departmentHeaders3, departmentData3); + } + exporter.exportToResponse(response, "八大员统计报表"); + }catch (Exception e){ + e.printStackTrace(); + } + } + + private Workbook getWorkbookFromSheet(Sheet sheet) { + // 这里假设 Sheet 对象有获取其所属 Workbook 的方法 + return sheet.getWorkbook(); + } + + private void setCellStyle(Workbook workbook, Sheet sheet, List headers, List> data) { + for (int i = 2; i <= data.size(); i++) { // 从1开始,跳过表头 + Row row = sheet.getRow(i); + if (row == null) { + continue; // 如果当前行为空,跳过 + } + for (int j = 0; j < headers.size(); j++) { + Cell cell = row.getCell(j); + if (cell != null) { + CellStyle style = workbook.createCellStyle(); + Font font = workbook.createFont(); + + // 启用文本自动换行 + style.setWrapText(true); + + // 检查是否需要设置为红色字体 + String headerName = headers.get(j); + Boolean isPartTime = (Boolean) data.get(i - 1).get(headerName + "_isPartTime"); + if (Boolean.TRUE.equals(isPartTime)) { + font.setColor(IndexedColors.RED.getIndex()); // 设置字体颜色为红色 + } else { + font.setColor(IndexedColors.BLACK.getIndex()); // 设置字体颜色为黑色 + } + + // 应用字体到样式 + style.setFont(font); + + // 应用样式到单元格 + cell.setCellStyle(style); + } + } + } + } + } diff --git a/bonus-modules/bonus-system/src/main/java/com/bonus/system/evection/entity/EvectionBean.java b/bonus-modules/bonus-system/src/main/java/com/bonus/system/evection/entity/EvectionBean.java index 4904bdf..87c47c6 100644 --- a/bonus-modules/bonus-system/src/main/java/com/bonus/system/evection/entity/EvectionBean.java +++ b/bonus-modules/bonus-system/src/main/java/com/bonus/system/evection/entity/EvectionBean.java @@ -198,4 +198,8 @@ public class EvectionBean extends BaseBean { private String hostUserName; + private String isPlateau; + + private String plateauSubsidy; + } diff --git a/bonus-modules/bonus-system/src/main/java/com/bonus/system/evection/service/EvectionServiceImpl.java b/bonus-modules/bonus-system/src/main/java/com/bonus/system/evection/service/EvectionServiceImpl.java index d19dd9d..3dcdfd5 100644 --- a/bonus-modules/bonus-system/src/main/java/com/bonus/system/evection/service/EvectionServiceImpl.java +++ b/bonus-modules/bonus-system/src/main/java/com/bonus/system/evection/service/EvectionServiceImpl.java @@ -86,9 +86,12 @@ public class EvectionServiceImpl implements EvectionService { evectionDao.insertEvection(o); //在循环加入出行人的 for (int j = 0; j < split.length; j++) { - o.setUserId(Long.valueOf(split[j])); - o.setUserName(splitName[j]); - evectionDao.insertEvection(o); + String userIdStr = split[j]; + if(!userIdStr.trim().isEmpty()){ + o.setUserId(Long.valueOf(split[j])); + o.setUserName(splitName[j]); + evectionDao.insertEvection(o); + } } k = 1; }catch (Exception e) { diff --git a/bonus-modules/bonus-system/src/main/resources/mapper/evection/EvectionMapper.xml b/bonus-modules/bonus-system/src/main/resources/mapper/evection/EvectionMapper.xml index 2ed5808..c14a759 100644 --- a/bonus-modules/bonus-system/src/main/resources/mapper/evection/EvectionMapper.xml +++ b/bonus-modules/bonus-system/src/main/resources/mapper/evection/EvectionMapper.xml @@ -15,7 +15,7 @@ leave_end_interval, leave_duration, source, create_user_id, is_agree, location, host_user_id,host_user_name, remark - , leave_form_id, submit_id,examine_status,is_outside,is_xizang) + , leave_form_id, submit_id,examine_status,is_outside,is_xizang,is_plateau,plateau_subsidy) VALUES (#{userId}, #{userName}, #{orgId}, #{orgName}, '出差','出差', #{leaveReason}, #{leaveStartDate}, @@ -26,7 +26,7 @@ #{leaveEndInterval}, #{leaveDuration}, #{source}, #{createUserId}, #{isAgree}, #{location}, #{hostUserId},#{hostUserName}, #{remark}, - #{uuid}, #{createUserId},'1',#{isOutside},#{isXizang}) + #{uuid}, #{createUserId},'1',#{isOutside},#{isXizang},#{isPlateau},#{plateauSubsidy}) @@ -184,7 +184,9 @@ l.location, l.remark, l.is_outside, - l.is_xizang + l.is_xizang, + l.is_plateau, + l.plateau_subsidy FROM leave_apply l LEFT JOIN sys_user_post p ON p.user_id = l.user_id LEFT JOIN sys_dict_data d on d.dict_code = p.post_id @@ -211,7 +213,9 @@ l.location, l.remark, l.is_outside, - l.is_xizang + l.is_xizang, + l.is_plateau, + l.plateau_subsidy ORDER BY l.update_time DESC) a LEFT JOIN sys_user su ON su.user_id = a.submit_id GROUP BY uuid