jiangping
2023-08-14 b51035f9b991bb08f8afd6fa60e04e548da9a74e
新增员工绩效\工资报表导出接口
已添加1个文件
已修改9个文件
118 ■■■■ 文件已修改
log/eva.log 补丁 | 查看 | 原始文档 | blame | 历史
server/src/main/java/doumeemes/api/ext/WorkorderRecordExtController.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/src/main/java/doumeemes/core/annotation/excel/ExcelExporter.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/src/main/java/doumeemes/dao/ext/dto/QuerySalaryStatisticDTO.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/src/main/java/doumeemes/dao/ext/dto/QueryUserSalaryListDTO.java 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/src/main/java/doumeemes/dao/ext/vo/SalaryStatisticsListVO.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/src/main/java/doumeemes/dao/ext/vo/UserSalaryListVO.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/src/main/java/doumeemes/service/ext/WorkorderRecordExtService.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/src/main/java/doumeemes/service/ext/impl/WorkorderRecordExtServiceImpl.java 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/src/main/resources/mappers/WorkorderRecordExtMapper.xml 38 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
log/eva.log
server/src/main/java/doumeemes/api/ext/WorkorderRecordExtController.java
@@ -175,6 +175,16 @@
    public void exportExcel (@RequestBody PageWrap<QueryWorkorderRecordExtDTO> pageWrap, HttpServletResponse response) {
        workorderRecordExtService.exportExcel(pageWrap,response);
    }
    @ApiOperation("导出员工绩效明细")
    @PostMapping("/exportUserSalary")
    public void exportUserSalary (@RequestBody PageWrap<QueryUserSalaryListDTO> pageWrap, HttpServletResponse response) {
        workorderRecordExtService.exportUserSalary(pageWrap,response);
    }
    @ApiOperation("导出工资报表")
    @PostMapping("/exportSalaryStatistics")
    public void exportSalaryStatistics (@RequestBody PageWrap<QuerySalaryStatisticDTO> pageWrap, HttpServletResponse response) {
        workorderRecordExtService.exportSalaryStatistics(pageWrap,response);
    }
    @ApiOperation("根据ID查询")
    @GetMapping("/{id}")
server/src/main/java/doumeemes/core/annotation/excel/ExcelExporter.java
@@ -2,6 +2,8 @@
import doumeemes.core.constants.ResponseStatus;
import doumeemes.core.exception.BusinessException;
import doumeemes.dao.ext.vo.UserBaseInfoVO;
import doumeemes.dao.ext.vo.UserSalaryListVO;
import lombok.AllArgsConstructor;
import lombok.Data;
import org.apache.commons.lang3.BooleanUtils;
@@ -170,6 +172,10 @@
        return new ArrayList<>(sortedFields.values());
    }
    public static void main(String[] args) {
        ExcelExporter m = new ExcelExporter();
        ExcelExporter.build(UserSalaryListVO.class).getColumns();
    }
    /**
     * 配置数据单元格
     */
server/src/main/java/doumeemes/dao/ext/dto/QuerySalaryStatisticDTO.java
@@ -22,7 +22,7 @@
    private Integer rootDepartId;
    @ApiModelProperty(value = "开始时间")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date stateDate;
    private Date startDate;
    @ApiModelProperty(value = "结束时间")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date endDate;
server/src/main/java/doumeemes/dao/ext/dto/QueryUserSalaryListDTO.java
@@ -1,6 +1,7 @@
package doumeemes.dao.ext.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import doumeemes.core.annotation.excel.ExcelColumn;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@@ -21,11 +22,13 @@
    private Integer procedureId;
    @ApiModelProperty(value = "物料编码", example = "1")
    private Integer materialId;
    @ApiModelProperty(value = "物料名称或物料code编码" )
    private String materialName;
    @ApiModelProperty(value = "根组织编码", example = "1",hidden = true)
    private Integer rootDepartId;
    @ApiModelProperty(value = "开始时间")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date stateDate;
    private Date startDate;
    @ApiModelProperty(value = "结束时间")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date endDate;
server/src/main/java/doumeemes/dao/ext/vo/SalaryStatisticsListVO.java
@@ -23,6 +23,17 @@
    private Integer userId;
    @ApiModelProperty(value = "生成人员信息")
    private UserBaseInfoVO userInfo;
    @ApiModelProperty(value = "生产人员姓名",hidden = true)
    @ExcelColumn(name="生产人员姓名")
    private String userName;
    @ApiModelProperty(value = "所属部门编码", example = "1",hidden = true)
    @ExcelColumn(name="所属部门编码")
    private Integer departId;
    @ApiModelProperty(value = "所属部门名称",hidden = true)
    @ExcelColumn(name="所属部门名称")
    private String departName;
    @ApiModelProperty(value = "计件工资(分)", example = "1")
    @ExcelColumn(name="计件工资(分)")
    private BigDecimal jijianSalary;
server/src/main/java/doumeemes/dao/ext/vo/UserSalaryListVO.java
@@ -22,9 +22,22 @@
    @ApiModelProperty(value = "生成人员信息")
    private UserBaseInfoVO userInfo;
    @ApiModelProperty(value = "生产人员姓名",hidden = true)
    @ExcelColumn(name="生产人员姓名")
    private String userName;
    @ApiModelProperty(value = "所属部门编码", example = "1",hidden = true)
    @ExcelColumn(name="所属部门编码")
    private Integer departId;
    @ApiModelProperty(value = "所属部门名称",hidden = true)
    @ExcelColumn(name="所属部门名称")
    private String departName;
    @ApiModelProperty(value = "物料编码", example = "1")
    @ExcelColumn(name="物料编码")
    private String materialCode;
    @ApiModelProperty(value = "物料名称", example = "1")
    @ExcelColumn(name="物料名称")
    private String materialName;
    @ApiModelProperty(value = "物料主键", example = "1")
    @ExcelColumn(name="物料主键")
    private Integer materialId;
server/src/main/java/doumeemes/service/ext/WorkorderRecordExtService.java
@@ -52,4 +52,8 @@
   PageData<SalaryStatisticsListVO> salaryStatistic(PageWrap<QuerySalaryStatisticDTO> pageWrap);
    PageData<UserSalaryListVO> userSalaryPage(PageWrap<QueryUserSalaryListDTO> pageWrap);
    void exportUserSalary(PageWrap<QueryUserSalaryListDTO> pageWrap, HttpServletResponse response);
    void exportSalaryStatistics(PageWrap<QuerySalaryStatisticDTO> pageWrap, HttpServletResponse response);
}
server/src/main/java/doumeemes/service/ext/impl/WorkorderRecordExtServiceImpl.java
@@ -173,13 +173,16 @@
        PageHelper.startPage(pageWrap.getPage(), pageWrap.getCapacity());
        //数据权限
        List<Integer> dataPermission = user.getDepartPermissionList();
//        List<Integer> dataPermission = user.getDepartPermissionList();
        List<UserSalaryListVO> result = workorderRecordExtMapper.userSalaryPage(pageWrap.getModel());
        if(result!=null){
            List<DepartmentExtListVO> allDepartList = RedisUtil.getObject(redisTemplate,Constants.RedisKeys.COM_DEPART_LIST_KEY+user.getCompany().getId(),ArrayList.class);
            for(UserSalaryListVO model : result){
                //查询生产人员姓名
                model.setUserInfo(initProUser(user,model.getUserId(),allDepartList));
                if(Constants.formatBigdecimal4Float(model.getNum()).compareTo(new BigDecimal(0))>1){
                    model.setRate(Constants.formatBigdecimal4Float(model.getQualifiedNum()).divide(model.getNum()).multiply(new BigDecimal(100)));
                }
            }
        }
        return PageData.from(new PageInfo<>(result));
@@ -1670,6 +1673,30 @@
    @Override
    public void exportUserSalary(PageWrap<QueryUserSalaryListDTO> pageWrap, HttpServletResponse response) {
        List<UserSalaryListVO> result=this.userSalaryPage(pageWrap).getRecords();
        for(UserSalaryListVO model : result) {
            if(model.getUserInfo()!=null){
                model.setUserName(model.getUserInfo().getUserName());
                model.setDepartName(model.getUserInfo().getDepartName());
            }
        }
        ExcelExporter.build(UserSalaryListVO.class).export(result, "员工绩效明细"+System.currentTimeMillis(), response);
    }
    @Override
    public void exportSalaryStatistics(PageWrap<QuerySalaryStatisticDTO> pageWrap, HttpServletResponse response){
        List<SalaryStatisticsListVO> result=this.salaryStatistic(pageWrap).getRecords();
        for(SalaryStatisticsListVO model : result) {
            if(model.getUserInfo()!=null){
                model.setUserName(model.getUserInfo().getUserName());
                model.setDepartName(model.getUserInfo().getDepartName());
            }
        }
        ExcelExporter.build(SalaryStatisticsListVO.class).export(result, "工资报表"+System.currentTimeMillis(), response);
    }
    @Override
    public void exportExcel(PageWrap<QueryWorkorderRecordExtDTO> pageWrap, HttpServletResponse response) {
        List<WorkorderRecordExtListVO> result=this.findPage(pageWrap).getRecords();
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
server/src/main/resources/mappers/WorkorderRecordExtMapper.xml
@@ -432,29 +432,41 @@
    limit 1
  </select>
  <select id="userSalaryPage" parameterType="doumeemes.dao.ext.dto.QueryUserSalaryListDTO" resultType="doumeemes.dao.ext.vo.UserSalaryListVO">
    select a.WORKORDER_ID,b.`CODE` as workorderCode,c.`NAME` as materialName,c.code as materialCode
    ,d.name as unitName,a.PROCEDURE_ID,f.`NAME` as procedureName
    ,sum(CASE  WHEN a.DONE_TYPE=0 THEN a.num ELSE 0 END ) as qualifiedNum
    ,sum(CASE  WHEN a.DONE_TYPE=0 THEN  0 ELSE a.num  END ) as unQualifiedNum
    ,d.name as unitName,a.PROCEDURE_ID,f.`NAME` as procedureName,a.CREATE_USER as userId
    ,sum(a.QUALIFIED_NUM) as qualifiedNum
    ,sum(a.UNQUALIFIED_NUM) as unQualifiedNum
    ,sum(a.num) as NUM
    from `workorder_record` a
    left join workorder b on a.WORKORDER_ID=b.id
    left join material c on b.MATERIAL_ID = c.ID
    left join unit_distribute d on a.UNIT_ID = d.ID
    left join material_distribute m on b.MATERIAL_ID = m.ID
    left join material c on m.MATERIAL_ID = c.ID
    left join unit d on a.UNIT_ID = d.ID
    left join procedures f on a.PROCEDURE_ID =f.ID
    where a.DELETED = 0
    <if test="rootDepartId != null">
      AND  `ROOT_DEPART_ID` = #{rootDepartId}
      AND  a.`ROOT_DEPART_ID` = #{rootDepartId}
    </if>
    <if test="procedureId != null">
      AND  a.`PROCEDURE_ID` = #{procedureId}
    </if>
    <if test="materialName != null and materialName !=''">
      AND  (c.`name` like concat('%', #{materialName},'%') or c.`code` like concat('%', #{materialName},'%'))
    </if>
    <if test="startDate != null">
      AND  a.`CREATE_TIME` >= #{startDate}
    </if>
    <if test="endDate != null">
      AND   #{endDate} >= a.`CREATE_TIME`
    </if>
    <if test="userId != null">
      AND  `CREATE_USER` = #{userId}
      AND  a.`CREATE_USER` = #{userId}
    </if>
    group by  a.`WORKORDER_ID`
    <!--order by a.`CREATE_TIME` desc-->
    order by a.CREATE_TIME desc
  </select>
  <select id="salaryStatistic" parameterType="doumeemes.dao.ext.dto.QuerySalaryStatisticDTO" resultType="doumeemes.dao.ext.vo.SalaryStatisticsListVO">
    select `CREATE_USER` ,sum(CASE  WHEN salary_type=0 THEN salary ELSE 0 END ) as jijiaSalry
    select `CREATE_USER` as userId ,sum(CASE  WHEN salary_type=0 THEN salary ELSE 0 END ) as jijianSalary
    ,sum(CASE  WHEN salary_type=0 THEN  0 ELSE salary  END ) as jishiSalary
    ,count(id) as num
    ,sum(salary) as totalSalary
@@ -466,6 +478,12 @@
    <if test="userId != null">
      AND  `CREATE_USER` = #{userId}
    </if>
    <if test="startDate != null">
      AND  a.`CREATE_TIME` >= #{startDate}
    </if>
    <if test="endDate != null">
      AND   #{endDate} >= a.`CREATE_TIME`
    </if>
    group by  `CREATE_USER`
   <!-- order by `CREATE_TIME` desc-->
  </select>