Pārlūkot izejas kodu

绩效导出(未完)

LLL 1 gadu atpakaļ
vecāks
revīzija
d49866958d

+ 26 - 7
itdmServer/module-iTDM/src/main/java/org/jeecg/modules/jixiaoPersonPrice/controller/JixiaoPersonPriceController.java

@@ -12,16 +12,17 @@ import org.jeecg.common.system.base.controller.JeecgController;
 import org.jeecg.common.system.query.QueryGenerator;
 import org.jeecg.modules.jixiaoPersonPrice.convert.JixiaoPersonPriceConvert;
 import org.jeecg.modules.jixiaoPersonPrice.dto.JixiaoPersonPriceAddDTO;
+import org.jeecg.modules.jixiaoPersonPrice.dto.JixiaoPersonPriceExportDTO;
 import org.jeecg.modules.jixiaoPersonPrice.entity.JixiaoPersonPrice;
 import org.jeecg.modules.jixiaoPersonPrice.service.IJixiaoPersonPriceService;
+import org.jeecg.modules.jixiaoPersonPrice.vo.JixiaoPersonPriceExportVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.servlet.ModelAndView;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
-import java.util.Arrays;
-import java.util.List;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -30,7 +31,7 @@ import java.util.stream.Collectors;
  * @Date:   2023-09-04
  * @Version: V1.0
  */
-@Api(tags="人员绩效提成")
+@Api(tags="..人员绩效提成")
 @RestController
 @RequestMapping("/jixiaoPersonPrice/jixiaoPersonPrice")
 @Slf4j
@@ -38,16 +39,34 @@ public class JixiaoPersonPriceController extends JeecgController<JixiaoPersonPri
 	@Autowired
 	private IJixiaoPersonPriceService jixiaoPersonPriceService;
 
+	/**查询导出的人员绩效*/
+	@ApiOperation("查询导出的人员绩效——查询数据")
+	@GetMapping(value = "/exportPersonJX")
+	public List<Map> exportPersonJX(JixiaoPersonPriceExportDTO dto){
+		return jixiaoPersonPriceService.exportPersonJX(dto);
+	}
+
+	/**
+	 * 人员绩效——按时间导出excel
+	 */
+	@ApiOperation("人员绩效——按时间导出excel")
+	@RequestMapping(value = "/exportXlsByTime")
+	public void exportXlsByTime(HttpServletResponse response, String beginDate,String endDate) {
+		JixiaoPersonPriceExportDTO dto = new JixiaoPersonPriceExportDTO();
+		dto.setBeginDate(beginDate);
+		dto.setEndDate(endDate);
+		List<Map> list = jixiaoPersonPriceService.exportPersonJX(dto);
+		jixiaoPersonPriceService.exportXlsByTime(response, list, "人员绩效提成");
+	}
 
 	 /**
-	  * 批量新增人员绩效
+	  * 人员绩效——批量新增
 	  */
-	 @AutoLog(value = "批量新增人员绩效")
-	 @ApiOperation(value="批量新增人员绩效", notes="批量新增人员绩效")
+	 @AutoLog(value = "人员绩效——批量新增")
+	 @ApiOperation(value="人员绩效——批量新增", notes="人员绩效——批量新增")
 	 @PostMapping(value = "/addAllJX")
 	 public Result<String> addAllJX(@RequestBody List<JixiaoPersonPriceAddDTO> list) {
 	 	List<JixiaoPersonPrice> list1 = list.stream().map(i-> JixiaoPersonPriceConvert.INSTANCE.convert(i)).collect(Collectors.toList());
-	 	//字符串转化成对象集合
 	 	jixiaoPersonPriceService.saveBatch(list1);
 	 	return Result.OK("添加成功!");
 	 }

+ 23 - 0
itdmServer/module-iTDM/src/main/java/org/jeecg/modules/jixiaoPersonPrice/dto/JixiaoPersonPriceExportDTO.java

@@ -0,0 +1,23 @@
+package org.jeecg.modules.jixiaoPersonPrice.dto;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
+
+@Data
+public class JixiaoPersonPriceExportDTO {
+
+    /**开始日期*/
+//    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
+//    @DateTimeFormat(pattern="yyyy-MM-dd")
+    @ApiModelProperty(value = "开始日期")
+    private String beginDate;
+
+    /**结束日期*/
+//    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
+//    @DateTimeFormat(pattern="yyyy-MM-dd")
+    @ApiModelProperty(value = "结束日期")
+    private String endDate;
+
+}

+ 5 - 0
itdmServer/module-iTDM/src/main/java/org/jeecg/modules/jixiaoPersonPrice/mapper/JixiaoPersonPriceMapper.java

@@ -1,8 +1,10 @@
 package org.jeecg.modules.jixiaoPersonPrice.mapper;
 
 import java.util.List;
+import java.util.Map;
 
 import org.apache.ibatis.annotations.Param;
+import org.jeecg.modules.jixiaoPersonPrice.dto.JixiaoPersonPriceExportDTO;
 import org.jeecg.modules.jixiaoPersonPrice.entity.JixiaoPersonPrice;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 
@@ -14,4 +16,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  */
 public interface JixiaoPersonPriceMapper extends BaseMapper<JixiaoPersonPrice> {
 
+    /**查询导出的人员绩效*/
+    public List<List<Map>> exportPersonJX(JixiaoPersonPriceExportDTO dto);
+
 }

+ 13 - 1
itdmServer/module-iTDM/src/main/java/org/jeecg/modules/jixiaoPersonPrice/mapper/xml/JixiaoPersonPriceMapper.xml

@@ -2,4 +2,16 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="org.jeecg.modules.jixiaoPersonPrice.mapper.JixiaoPersonPriceMapper">
 
-</mapper>
+    <resultMap type="java.util.Map" id="BaseOneMap">
+        <result column="result1" jdbcType="VARCHAR" property="result1" />
+    </resultMap>
+
+    <resultMap type="java.util.Map" id="BaseTwoMap">
+        <result column="result2" jdbcType="VARCHAR" property="result2" />
+    </resultMap>
+
+    <select id="exportPersonJX" resultMap="BaseOneMap,BaseTwoMap" statementType="CALLABLE">
+        call exportPersonJX(#{beginDate,mode=IN},#{endDate,mode=IN})
+    </select>
+
+</mapper>

+ 27 - 0
itdmServer/module-iTDM/src/main/java/org/jeecg/modules/jixiaoPersonPrice/service/IJixiaoPersonPriceService.java

@@ -1,7 +1,25 @@
 package org.jeecg.modules.jixiaoPersonPrice.service;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import org.apache.shiro.SecurityUtils;
+import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.system.vo.LoginUser;
+import org.jeecg.common.util.oConvertUtils;
+import org.jeecg.modules.jixiaoPersonPrice.dto.JixiaoPersonPriceExportDTO;
 import org.jeecg.modules.jixiaoPersonPrice.entity.JixiaoPersonPrice;
 import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.modules.jixiaoPersonPrice.vo.JixiaoPersonPriceExportVO;
+import org.jeecgframework.poi.excel.def.NormalExcelConstants;
+import org.jeecgframework.poi.excel.entity.ExportParams;
+import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
 
 /**
  * @Description: 人员绩效提成
@@ -11,4 +29,13 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface IJixiaoPersonPriceService extends IService<JixiaoPersonPrice> {
 
+    /**查询导出的人员绩效*/
+    public List<Map> exportPersonJX(JixiaoPersonPriceExportDTO dto);
+
+    /**
+     * 人员绩效——按时间导出excel
+     *
+     */
+    public ModelAndView exportXlsByTime(HttpServletResponse response, List<Map> exportList, String title);
+
 }

+ 75 - 1
itdmServer/module-iTDM/src/main/java/org/jeecg/modules/jixiaoPersonPrice/service/impl/JixiaoPersonPriceServiceImpl.java

@@ -1,11 +1,26 @@
 package org.jeecg.modules.jixiaoPersonPrice.service.impl;
 
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.jeecg.modules.jixiaoPersonPrice.dto.JixiaoPersonPriceExportDTO;
 import org.jeecg.modules.jixiaoPersonPrice.entity.JixiaoPersonPrice;
 import org.jeecg.modules.jixiaoPersonPrice.mapper.JixiaoPersonPriceMapper;
 import org.jeecg.modules.jixiaoPersonPrice.service.IJixiaoPersonPriceService;
+import org.jeecgframework.poi.excel.ExcelExportUtil;
+import org.jeecgframework.poi.excel.def.NormalExcelConstants;
+import org.jeecgframework.poi.excel.entity.ExportParams;
+import org.jeecgframework.poi.excel.entity.params.ExcelExportEntity;
+import org.jeecgframework.poi.excel.view.JeecgMapExcelView;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
+import org.springframework.web.servlet.ModelAndView;
 
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.net.URLEncoder;
+import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * @Description: 人员绩效提成
@@ -16,4 +31,63 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 @Service
 public class JixiaoPersonPriceServiceImpl extends ServiceImpl<JixiaoPersonPriceMapper, JixiaoPersonPrice> implements IJixiaoPersonPriceService {
 
+    @Autowired
+    @SuppressWarnings("all")
+    private JixiaoPersonPriceMapper jixiaoPersonPriceMapper;
+
+    @Value("${jeecg.path.upload}")
+    private String upLoadPath;
+
+    /**查询导出的人员绩效*/
+    public List<Map> exportPersonJX(JixiaoPersonPriceExportDTO dto){
+        List<List<Map>> list = jixiaoPersonPriceMapper.exportPersonJX(dto);
+        List<Map> mapList = list.get(1);
+        return mapList;
+    }
+
+    public void downloadExcel1(HttpServletResponse response, String outputName, HSSFWorkbook hssfWorkbook) throws IOException {
+        response.setContentType("application/octet-stream");
+        //attachment为以附件方式下载
+        response.setHeader("Content-Disposition", "attachment;filename=" +
+                URLEncoder.encode(outputName, "utf-8"));
+        response.setHeader("Cache-Control", "No-cache");
+        response.flushBuffer();
+
+        hssfWorkbook.write(response.getOutputStream());
+        hssfWorkbook.close();
+    }
+
+    /**
+     * 人员绩效——按时间导出excel
+     */
+    public ModelAndView exportXlsByTime(HttpServletResponse response,List<Map> exportList, String title) {
+//        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+
+        List<ExcelExportEntity> mapList = new ArrayList<>();//这部分可修改为按选择字段导出
+        if(exportList != null && !exportList.isEmpty()){
+            Map map = exportList.get(0);
+            // 打印键集合
+            for (Object key : map.keySet()) {
+                System.out.println((String) key);
+                mapList.add(new ExcelExportEntity((String) key, key));
+            }
+
+        }
+
+        // Step.3 AutoPoi 导出Excel
+        ModelAndView mv = new ModelAndView(new JeecgMapExcelView());
+        //此处设置的filename无效 ,前端会重更新设置一下
+        mv.addObject(NormalExcelConstants.FILE_NAME, title);
+//        mv.addObject(NormalExcelConstants.MAP_LIST, mapList);
+//        mv.addObject(NormalExcelConstants.CLASS, clazz);
+        //update-begin--Author:liusq  Date:20210126 for:图片导出报错,ImageBasePath未设置--------------------
+//        ExportParams exportParams=new ExportParams(title + "报表", "导出人:" + sysUser.getRealname(), title);
+        ExportParams exportParams=new ExportParams(title + "报表", "导出人:" + "LLL", title);
+        exportParams.setImageBasePath(upLoadPath);
+        //update-end--Author:liusq  Date:20210126 for:图片导出报错,ImageBasePath未设置----------------------
+        mv.addObject(NormalExcelConstants.PARAMS,exportParams);
+        mv.addObject(NormalExcelConstants.MAP_LIST, exportList);
+        return mv;
+    }
+
 }

+ 23 - 0
itdmServer/module-iTDM/src/main/java/org/jeecg/modules/jixiaoPersonPrice/vo/JixiaoPersonPriceExportVO.java

@@ -0,0 +1,23 @@
+package org.jeecg.modules.jixiaoPersonPrice.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.jeecgframework.poi.excel.annotation.Excel;
+
+@Data
+public class JixiaoPersonPriceExportVO {
+
+    /**委托编号*/
+    @Excel(name = "委托编号", width = 15)
+    @ApiModelProperty(value = "委托编号")
+    private java.lang.String weituoNo;
+    /**量化积分*/
+    @Excel(name = "量化积分", width = 15)
+    @ApiModelProperty(value = "量化积分")
+    private java.math.BigDecimal lhJifen;
+    /**绩效人员*/
+    @Excel(name = "绩效人员", width = 15)
+    @ApiModelProperty(value = "绩效人员")
+    private java.lang.String name;
+
+}