|
@@ -11953,7 +11953,9 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
@Override
|
|
|
public HttpRespMsg getEffectiveLaborHourRate(String startDate, String endDate) {
|
|
|
LambdaQueryWrapper<Department> lqw = new LambdaQueryWrapper<>();
|
|
|
- lqw.in(Department::getDepartmentId,7526,7560,7539,7643,7645,7536,7547,7388,7578);
|
|
|
+ NumberFormat numberFormat=NumberFormat.getPercentInstance();
|
|
|
+ numberFormat.setMaximumFractionDigits(2);
|
|
|
+ lqw.in(Department::getDepartmentId,7526,7560,7539,7643,7645,7536,7547,7388,7578,7558,7608,7611,7613,7631,7894,7896);
|
|
|
List<Department> departments = departmentMapper.selectList(lqw);
|
|
|
|
|
|
ArrayList<LaborHourRateVo> laborHourRateVos = new ArrayList<>();
|
|
@@ -12027,18 +12029,15 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
int v = 8 * inActiveDays + idStrings.size() * 8 * dayCount;
|
|
|
if (v== 0) {
|
|
|
laborHourRateVo.setTotal_time(0L);
|
|
|
- laborHourRateVo.setRate(0.0);
|
|
|
+ laborHourRateVo.setRate(numberFormat.format(0));
|
|
|
laborHourRateVos.add(laborHourRateVo);
|
|
|
} else {
|
|
|
laborHourRateVo.setTotal_time((long) (v));//应报工时还少了在职的加上可能辞职的
|
|
|
- BigDecimal bd = new BigDecimal(timeSum/(v)*100);
|
|
|
- bd = bd.setScale(2, RoundingMode.HALF_UP);
|
|
|
- laborHourRateVo.setRate(bd.doubleValue());
|
|
|
+ BigDecimal bd = new BigDecimal(timeSum/(v));
|
|
|
+ bd = bd.setScale(4, RoundingMode.HALF_UP);
|
|
|
+ laborHourRateVo.setRate(numberFormat.format(bd.doubleValue()));
|
|
|
laborHourRateVos.add(laborHourRateVo);
|
|
|
}
|
|
|
-
|
|
|
-// System.out.println("============="+inActiveDays);
|
|
|
-// System.out.println("============="+isActiveCount);
|
|
|
laborHourRateVo.setDay_time(8);
|
|
|
|
|
|
|
|
@@ -12056,11 +12055,11 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
laborHourRateVo.setDate_count(dayCount);
|
|
|
|
|
|
if (sumTotalTime > 0) {
|
|
|
- BigDecimal bd = new BigDecimal(totalWorkTime/sumTotalTime*100);
|
|
|
- bd = bd.setScale(2, RoundingMode.HALF_UP);
|
|
|
- laborHourRateVo.setRate(bd.doubleValue());
|
|
|
+ BigDecimal bd = new BigDecimal(totalWorkTime/sumTotalTime);
|
|
|
+ bd = bd.setScale(4, RoundingMode.HALF_UP);
|
|
|
+ laborHourRateVo.setRate(numberFormat.format(bd.doubleValue()));
|
|
|
} else {
|
|
|
- laborHourRateVo.setRate(0.0);
|
|
|
+ laborHourRateVo.setRate(numberFormat.format(0));
|
|
|
}
|
|
|
|
|
|
laborHourRateVos.add(laborHourRateVo);
|
|
@@ -12070,6 +12069,184 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
return msg;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public HttpRespMsg exportEffectiveLaborHourRate(String startDate, String endDate) {
|
|
|
+ HttpRespMsg httpRespMsg=new HttpRespMsg();
|
|
|
+ HttpRespMsg msgData = getEffectiveLaborHourRate(startDate, endDate);
|
|
|
+ List<LaborHourRateVo> resultList= (List<LaborHourRateVo>) msgData.getData();
|
|
|
+ Integer companyId = userMapper.selectById(request.getHeader("token")).getCompanyId();
|
|
|
+ WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new LambdaQueryWrapper<WxCorpInfo>().eq(WxCorpInfo::getCompanyId, companyId));
|
|
|
+ Company company = companyMapper.selectById(companyId);
|
|
|
+ //1.创建一个workbook,对应一个excel文件
|
|
|
+ SXSSFWorkbook workBook = new SXSSFWorkbook();
|
|
|
+ //2.在workbook中添加一个sheet,对应Excel中的sheet
|
|
|
+ SXSSFSheet sheet = workBook.createSheet("有效工时率报表");
|
|
|
+ //设置每一列的列宽
|
|
|
+ sheet.setColumnWidth(0,256*15);
|
|
|
+ sheet.setColumnWidth(1,256*15);
|
|
|
+ //3.设置样式以及字体样式
|
|
|
+ //设置冻结
|
|
|
+ sheet.createFreezePane(0, 2);
|
|
|
+ sheet.setDefaultColumnWidth(16);
|
|
|
+ //设置字体样式
|
|
|
+ Font headFont = workBook.createFont();
|
|
|
+ headFont.setBold(true);
|
|
|
+ headFont.setFontHeightInPoints((short) 10);
|
|
|
+ headFont.setFontName("黑体");
|
|
|
+
|
|
|
+ Font titleFont = workBook.createFont();
|
|
|
+ titleFont.setBold(true);
|
|
|
+ titleFont.setFontHeightInPoints((short) 10);
|
|
|
+ titleFont.setFontName("黑体");
|
|
|
+
|
|
|
+ Font font = workBook.createFont();
|
|
|
+ font.setFontHeightInPoints((short) 10);
|
|
|
+ font.setFontName("宋体");
|
|
|
+
|
|
|
+ //设置单元格样式
|
|
|
+ XSSFCellStyle headStyle = (XSSFCellStyle) workBook.createCellStyle();
|
|
|
+ headStyle.setFont(headFont);
|
|
|
+ headStyle.setAlignment(HorizontalAlignment.CENTER);
|
|
|
+ headStyle.setVerticalAlignment(org.apache.poi.ss.usermodel.VerticalAlignment.CENTER);
|
|
|
+ headStyle.setWrapText(true);
|
|
|
+ headStyle.setBorderBottom(BorderStyle.THIN); //下边框
|
|
|
+ headStyle.setBorderLeft(BorderStyle.THIN);//左边框
|
|
|
+ headStyle.setBorderTop(BorderStyle.THIN);//上边框
|
|
|
+ headStyle.setBorderRight(BorderStyle.THIN);//右边框
|
|
|
+
|
|
|
+ String color = "c0c0c0"; //此处得到的color为16进制的字符串
|
|
|
+ //转为RGB码
|
|
|
+ int r = Integer.parseInt((color.substring(0,2)),16); //转为16进制
|
|
|
+ int g = Integer.parseInt((color.substring(2,4)),16);
|
|
|
+ int b = Integer.parseInt((color.substring(4,6)),16);
|
|
|
+
|
|
|
+ //设置自定义颜色
|
|
|
+ XSSFColor xssfColor = new XSSFColor();
|
|
|
+ byte[] colorRgb = { (short)9, (byte) r, (byte) g, (byte) b };
|
|
|
+ xssfColor.setRGB(colorRgb);
|
|
|
+
|
|
|
+ headStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.index);
|
|
|
+ headStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);// 填充模式(和背景颜色成对使用)
|
|
|
+ /*headStyle.setFillForegroundColor(IndexedColors.AQUA.getIndex());*/ //设置自带的颜色
|
|
|
+
|
|
|
+ CellStyle titleStyle = workBook.createCellStyle();
|
|
|
+ titleStyle.setFont(titleFont);
|
|
|
+ titleStyle.setAlignment(HorizontalAlignment.CENTER);
|
|
|
+ titleStyle.setVerticalAlignment(org.apache.poi.ss.usermodel.VerticalAlignment.CENTER);
|
|
|
+ titleStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); //填充单元格
|
|
|
+ titleStyle.setFillForegroundColor((short)9); //填色
|
|
|
+ titleStyle.setWrapText(true);
|
|
|
+ titleStyle.setBorderBottom(BorderStyle.THIN); //下边框
|
|
|
+ titleStyle.setBorderLeft(BorderStyle.THIN);//左边框
|
|
|
+ titleStyle.setBorderTop(BorderStyle.THIN);//上边框
|
|
|
+ titleStyle.setBorderRight(BorderStyle.THIN);//右边框
|
|
|
+
|
|
|
+ CellStyle cellStyle = workBook.createCellStyle();
|
|
|
+ cellStyle.setFont(font);
|
|
|
+ cellStyle.setAlignment(HorizontalAlignment.CENTER);
|
|
|
+ cellStyle.setVerticalAlignment(org.apache.poi.ss.usermodel.VerticalAlignment.CENTER);
|
|
|
+ cellStyle.setWrapText(true);
|
|
|
+ cellStyle.setBorderBottom(BorderStyle.THIN); //下边框
|
|
|
+ cellStyle.setBorderLeft(BorderStyle.THIN);//左边框
|
|
|
+ cellStyle.setBorderTop(BorderStyle.THIN);//上边框
|
|
|
+ cellStyle.setBorderRight(BorderStyle.THIN);//右边框
|
|
|
+ //行号
|
|
|
+ int rowNum = 0;
|
|
|
+ //第一行
|
|
|
+ SXSSFRow row0 = sheet.createRow(rowNum++);
|
|
|
+ row0.setHeight((short)500);
|
|
|
+ List<String> row_first =new ArrayList<>();
|
|
|
+ row_first.add("所属部门");
|
|
|
+ row_first.add("实报工时(小时)");
|
|
|
+ row_first.add("应工时(小时)");
|
|
|
+ row_first.add("");
|
|
|
+ row_first.add("");
|
|
|
+ row_first.add("");
|
|
|
+ row_first.add("有效工时率");
|
|
|
+ for (int i = 0; i < row_first.size(); i++) {
|
|
|
+ SXSSFCell tempCell = row0.createCell(i);
|
|
|
+ tempCell.setCellValue(row_first.get(i));
|
|
|
+ tempCell.setCellStyle(headStyle);
|
|
|
+ }
|
|
|
+ sheet.addMergedRegion(new CellRangeAddress(0,1,0,0));
|
|
|
+ sheet.addMergedRegion(new CellRangeAddress(0,1,1,1));
|
|
|
+ sheet.addMergedRegion(new CellRangeAddress(0,1,6,6));
|
|
|
+ sheet.addMergedRegion(new CellRangeAddress(0,0,2,5));
|
|
|
+ //第二行
|
|
|
+ SXSSFRow row1 = sheet.createRow(rowNum++);
|
|
|
+ row1.setHeight((short)500);
|
|
|
+ List<String> row_second =new ArrayList<>();
|
|
|
+ row_second.add("");
|
|
|
+ row_second.add("");
|
|
|
+ row_second.add("在职人数");
|
|
|
+ row_second.add("应报工时天数");
|
|
|
+ row_second.add("日标准工时");
|
|
|
+ row_second.add("应报工时");
|
|
|
+ row_second.add("");
|
|
|
+ for (int i = 0; i < row_second.size(); i++) {
|
|
|
+ SXSSFCell tempCell = row1.createCell(i);
|
|
|
+ tempCell.setCellValue(row_second.get(i));
|
|
|
+ tempCell.setCellStyle(headStyle);
|
|
|
+ }
|
|
|
+ List<String> list=new ArrayList<>();
|
|
|
+ for (LaborHourRateVo laborHourRateVo : resultList) {
|
|
|
+ if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
|
|
|
+ list.add(laborHourRateVo.getDepartment_name());
|
|
|
+ }else {
|
|
|
+ list.add("$departmentName="+laborHourRateVo.getDepartment_name()+"$");
|
|
|
+ }
|
|
|
+ list.add(String.valueOf(laborHourRateVo.getWorking_time()));
|
|
|
+ list.add(String.valueOf(laborHourRateVo.getCount()));
|
|
|
+ list.add(String.valueOf(laborHourRateVo.getDate_count()));
|
|
|
+ list.add(String.valueOf(laborHourRateVo.getDay_time()));
|
|
|
+ list.add(String.valueOf(laborHourRateVo.getTotal_time()));
|
|
|
+ list.add(String.valueOf(laborHourRateVo.getRate()));
|
|
|
+ }
|
|
|
+ int k=0;
|
|
|
+ for(int i = 0;i<resultList.size();i++){
|
|
|
+ SXSSFRow tempRow = sheet.createRow(rowNum++);
|
|
|
+ tempRow.setHeight((short)500);
|
|
|
+ for(int j=0;j<7;j++){
|
|
|
+ SXSSFCell tempCell = tempRow.createCell(j);
|
|
|
+ String cellValue = "";
|
|
|
+ tempCell.setCellStyle(cellStyle);
|
|
|
+ if(k>=list.size()){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ cellValue=list.get(k);
|
|
|
+ tempCell.setCellValue(cellValue);
|
|
|
+ k++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //导出excel
|
|
|
+ String result="系统提示:Excel文件导出成功!";
|
|
|
+ String title= "有效工时率报表_"+company.getCompanyName()+System.currentTimeMillis();
|
|
|
+ String fileName= title+".xlsx";
|
|
|
+ try {
|
|
|
+ File dir = null;
|
|
|
+ dir = new File(path);
|
|
|
+ if (!dir.exists()) {
|
|
|
+ dir.mkdirs();
|
|
|
+ }
|
|
|
+ FileOutputStream os = new FileOutputStream(path+fileName);//保存到本地
|
|
|
+ workBook.write(os);
|
|
|
+ os.flush();
|
|
|
+ os.close();
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ if(wxCorpInfo != null && wxCorpInfo.getSaasSyncContact() == 1){
|
|
|
+ try {
|
|
|
+ return excelExportService.exportTranForwx(wxCorpInfo, title);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ httpRespMsg.data ="/upload/"+fileName;
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public HttpRespMsg getProjectFillTime(HttpServletRequest request, Integer projectId) {
|
|
|
//待审核和已通过的总工时
|