正在显示
3 个修改的文件
包含
69 行增加
和
13 行删除
| @@ -34,6 +34,7 @@ import java.io.IOException; | @@ -34,6 +34,7 @@ import java.io.IOException; | ||
| 34 | import java.lang.annotation.Annotation; | 34 | import java.lang.annotation.Annotation; |
| 35 | import java.lang.reflect.Field; | 35 | import java.lang.reflect.Field; |
| 36 | import java.math.BigDecimal; | 36 | import java.math.BigDecimal; |
| 37 | +import java.text.SimpleDateFormat; | ||
| 37 | import java.util.*; | 38 | import java.util.*; |
| 38 | import java.util.stream.Collectors; | 39 | import java.util.stream.Collectors; |
| 39 | 40 | ||
| @@ -55,9 +56,62 @@ public class JeecgController<T, S extends IService<T>> { | @@ -55,9 +56,62 @@ public class JeecgController<T, S extends IService<T>> { | ||
| 55 | private String upLoadPath; | 56 | private String upLoadPath; |
| 56 | /** | 57 | /** |
| 57 | * 导出excel | 58 | * 导出excel |
| 58 | - * | 59 | + *月工时导出 |
| 59 | * @param request | 60 | * @param request |
| 60 | */ | 61 | */ |
| 62 | + protected ModelAndView exportXlsWorkTime(HttpServletRequest request, T object, Class<T> clazz, String title) { | ||
| 63 | + // Step.1 组装查询条件 | ||
| 64 | + QueryWrapper<T> queryWrapper = new QueryWrapper<>(); | ||
| 65 | + try { | ||
| 66 | + // 获取 undertaker 字段 | ||
| 67 | + Field name = clazz.getDeclaredField("undertaker"); | ||
| 68 | + name.setAccessible(true); | ||
| 69 | + String undertaker = (String) name.get(object); | ||
| 70 | + if(undertaker!=null && !undertaker.isEmpty()){ | ||
| 71 | + String undertaker2 = undertaker.replace("*", ""); // 移除通配符 * | ||
| 72 | + queryWrapper.like("undertaker", "%" + undertaker2 + "%"); | ||
| 73 | + } | ||
| 74 | + // 获取 yan_time 字段 | ||
| 75 | + Field yan_time = clazz.getDeclaredField("yanTime"); | ||
| 76 | + yan_time.setAccessible(true); | ||
| 77 | + Date yanTime = (Date) yan_time.get(object); | ||
| 78 | + if(yanTime!=null){ | ||
| 79 | + Date salaryMonth = yanTime; | ||
| 80 | + SimpleDateFormat outputFormat = new SimpleDateFormat("yyyy-MM"); | ||
| 81 | + String outputDateString = outputFormat.format(salaryMonth); | ||
| 82 | + queryWrapper.apply("DATE_FORMAT(yan_time, '%Y-%m') = '" + outputDateString + "'"); | ||
| 83 | + } | ||
| 84 | + } catch (Exception e) { | ||
| 85 | + throw new RuntimeException(e); | ||
| 86 | + } | ||
| 87 | + LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); | ||
| 88 | + | ||
| 89 | + // Step.2 获取导出数据 | ||
| 90 | + List<T> pageList = service.list(queryWrapper); | ||
| 91 | + List<T> exportList = null; | ||
| 92 | + | ||
| 93 | + // 过滤选中数据 | ||
| 94 | + String selections = request.getParameter("selections"); | ||
| 95 | + if (oConvertUtils.isNotEmpty(selections)) { | ||
| 96 | + List<String> selectionList = Arrays.asList(selections.split(",")); | ||
| 97 | + exportList = pageList.stream().filter(item -> selectionList.contains(getId(item))).collect(Collectors.toList()); | ||
| 98 | + } else { | ||
| 99 | + exportList = pageList; | ||
| 100 | + } | ||
| 101 | + | ||
| 102 | + // Step.3 AutoPoi 导出Excel | ||
| 103 | + ModelAndView mv = new ModelAndView(new JeecgEntityExcelView()); | ||
| 104 | + //此处设置的filename无效 ,前端会重更新设置一下 | ||
| 105 | + mv.addObject(NormalExcelConstants.FILE_NAME, title); | ||
| 106 | + mv.addObject(NormalExcelConstants.CLASS, clazz); | ||
| 107 | + //update-begin--Author:liusq Date:20210126 for:图片导出报错,ImageBasePath未设置-------------------- | ||
| 108 | + ExportParams exportParams=new ExportParams(title + "报表", "导出人:" + sysUser.getRealname(), title); | ||
| 109 | + exportParams.setImageBasePath(upLoadPath); | ||
| 110 | + //update-end--Author:liusq Date:20210126 for:图片导出报错,ImageBasePath未设置---------------------- | ||
| 111 | + mv.addObject(NormalExcelConstants.PARAMS,exportParams); | ||
| 112 | + mv.addObject(NormalExcelConstants.DATA_LIST, exportList); | ||
| 113 | + return mv; | ||
| 114 | + } | ||
| 61 | protected ModelAndView exportXls(HttpServletRequest request, T object, Class<T> clazz, String title) { | 115 | protected ModelAndView exportXls(HttpServletRequest request, T object, Class<T> clazz, String title) { |
| 62 | // Step.1 组装查询条件 | 116 | // Step.1 组装查询条件 |
| 63 | QueryWrapper<T> queryWrapper = QueryGenerator.initQueryWrapper(object, request.getParameterMap()); | 117 | QueryWrapper<T> queryWrapper = QueryGenerator.initQueryWrapper(object, request.getParameterMap()); |
jeecg-boot-erp/src/main/java/org/jeecg/modules/erp/order_form/controller/ViewWorkTimeController.java
| @@ -54,7 +54,8 @@ public class ViewWorkTimeController extends JeecgController<ViewWorkTime, IViewW | @@ -54,7 +54,8 @@ public class ViewWorkTimeController extends JeecgController<ViewWorkTime, IViewW | ||
| 54 | QueryWrapper<ViewWorkTime> queryWrapper = new QueryWrapper<>(); | 54 | QueryWrapper<ViewWorkTime> queryWrapper = new QueryWrapper<>(); |
| 55 | queryWrapper.orderByDesc("yan_time"); | 55 | queryWrapper.orderByDesc("yan_time"); |
| 56 | if(viewWorkTime.getUndertaker()!=null && !viewWorkTime.getUndertaker().isEmpty()){ | 56 | if(viewWorkTime.getUndertaker()!=null && !viewWorkTime.getUndertaker().isEmpty()){ |
| 57 | - queryWrapper.like("undertaker", "%" + viewWorkTime.getUndertaker() + "%"); | 57 | + String undertaker = viewWorkTime.getUndertaker().replace("*", ""); // 移除通配符 * |
| 58 | + queryWrapper.like("undertaker", "%" + undertaker + "%"); | ||
| 58 | } | 59 | } |
| 59 | if(viewWorkTime.getYanTime()!=null){ | 60 | if(viewWorkTime.getYanTime()!=null){ |
| 60 | Date salaryMonth = viewWorkTime.getYanTime(); | 61 | Date salaryMonth = viewWorkTime.getYanTime(); |
| @@ -148,7 +149,7 @@ public class ViewWorkTimeController extends JeecgController<ViewWorkTime, IViewW | @@ -148,7 +149,7 @@ public class ViewWorkTimeController extends JeecgController<ViewWorkTime, IViewW | ||
| 148 | */ | 149 | */ |
| 149 | @RequestMapping(value = "/exportXls") | 150 | @RequestMapping(value = "/exportXls") |
| 150 | public ModelAndView exportXls(HttpServletRequest request, ViewWorkTime viewWorkTime) { | 151 | public ModelAndView exportXls(HttpServletRequest request, ViewWorkTime viewWorkTime) { |
| 151 | - return super.exportXls(request, viewWorkTime, ViewWorkTime.class, "月工时信息"); | 152 | + return super.exportXlsWorkTime(request, viewWorkTime, ViewWorkTime.class, "月工时信息"); |
| 152 | } | 153 | } |
| 153 | 154 | ||
| 154 | /** | 155 | /** |
| @@ -45,13 +45,19 @@ public class ViewWorkTime implements Serializable { | @@ -45,13 +45,19 @@ public class ViewWorkTime implements Serializable { | ||
| 45 | // @Excel(name = "工序", width = 15) | 45 | // @Excel(name = "工序", width = 15) |
| 46 | @ApiModelProperty(value = "工序") | 46 | @ApiModelProperty(value = "工序") |
| 47 | private java.lang.String workingProcedure; | 47 | private java.lang.String workingProcedure; |
| 48 | + /**验收时间*/ | ||
| 49 | + @Excel(name = "月份", width = 15, format = "yyyy-MM") | ||
| 50 | + @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM") | ||
| 51 | + @DateTimeFormat(pattern="yyyy-MM") | ||
| 52 | + @ApiModelProperty(value = "月份") | ||
| 53 | + private java.util.Date yanTime; | ||
| 48 | /**承接人*/ | 54 | /**承接人*/ |
| 49 | - @Excel(name = "承接人", width = 15) | ||
| 50 | - @ApiModelProperty(value = "承接人") | 55 | + @Excel(name = "姓名", width = 15) |
| 56 | + @ApiModelProperty(value = "姓名") | ||
| 51 | private java.lang.String undertaker; | 57 | private java.lang.String undertaker; |
| 52 | /**工时*/ | 58 | /**工时*/ |
| 53 | - @Excel(name = "工时", width = 15) | ||
| 54 | - @ApiModelProperty(value = "工时") | 59 | + @Excel(name = "月总工时", width = 15) |
| 60 | + @ApiModelProperty(value = "月总工时") | ||
| 55 | private java.math.BigDecimal workHours; | 61 | private java.math.BigDecimal workHours; |
| 56 | /**派发时间*/ | 62 | /**派发时间*/ |
| 57 | // @Excel(name = "派发时间", width = 15, format = "yyyy-MM-dd") | 63 | // @Excel(name = "派发时间", width = 15, format = "yyyy-MM-dd") |
| @@ -63,12 +69,7 @@ public class ViewWorkTime implements Serializable { | @@ -63,12 +69,7 @@ public class ViewWorkTime implements Serializable { | ||
| 63 | // @Excel(name = "派发人", width = 15) | 69 | // @Excel(name = "派发人", width = 15) |
| 64 | @ApiModelProperty(value = "派发人") | 70 | @ApiModelProperty(value = "派发人") |
| 65 | private java.lang.String dispatchRen; | 71 | private java.lang.String dispatchRen; |
| 66 | - /**验收时间*/ | ||
| 67 | - @Excel(name = "验收时间", width = 15, format = "yyyy-MM") | ||
| 68 | - @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM") | ||
| 69 | - @DateTimeFormat(pattern="yyyy-MM") | ||
| 70 | - @ApiModelProperty(value = "验收时间") | ||
| 71 | - private java.util.Date yanTime; | 72 | + |
| 72 | /**验收人*/ | 73 | /**验收人*/ |
| 73 | // @Excel(name = "验收人", width = 15) | 74 | // @Excel(name = "验收人", width = 15) |
| 74 | @ApiModelProperty(value = "验收人") | 75 | @ApiModelProperty(value = "验收人") |
-
请 注册 或 登录 后发表评论