Commit d7c2d92f authored by 竹天卫's avatar 竹天卫

人员产值统计导出功能

parent da2fd0e2
......@@ -113,13 +113,13 @@ public class NonStandardApplyController {
return BaseResponse.errorMsg("失败!");
}
@ApiOperation("非标产值申请导出列表")
@ApiOperation("导出-非标产值申请列表")
@PostMapping("/exportList")
public void exportList(String filename, Integer userId, String name, HttpServletResponse response) {
try {
iNonStandardApplyService.exportList(filename, userId, name, response);
} catch (Exception e) {
log.debug("非标产值申请导出列表{}", e);
log.debug("导出-非标产值申请导出列表{}", e);
}
}
}
......@@ -132,13 +132,13 @@ public class NonStandardApprovalController {
return BaseResponse.errorMsg("失败!");
}
@ApiOperation("委托单位审批导出列表")
@ApiOperation("导出-委托单位审批列表")
@PostMapping("/exportList")
public void exportList(String filename, String userId, String name, HttpServletResponse response) {
try {
iNonStandardApprovalService.exportList(filename, userId, name, response);
} catch (Exception e) {
log.debug("非标产值申请导出列表{}", e);
log.debug("导出-非标产值申请导出列表{}", e);
}
}
}
package cn.wise.sc.cement.business.controller;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import cn.wise.sc.cement.business.entity.NonStandardValue;
import cn.wise.sc.cement.business.model.BaseResponse;
import cn.wise.sc.cement.business.model.PageQuery;
import cn.wise.sc.cement.business.model.vo.NonStandardApplyVo;
import cn.wise.sc.cement.business.model.vo.NonStandardValueVo;
import cn.wise.sc.cement.business.service.INonStandardValueService;
import cn.wise.sc.cement.business.util.PageUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
......@@ -19,7 +16,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import javax.xml.crypto.Data;
import java.util.Date;
import java.util.List;
......@@ -40,8 +36,8 @@ public class NonStandardValueController {
@Autowired
private INonStandardValueService inonStandardValueService;
@GetMapping("/user_id")
@ApiOperation("产值统计-非标产值")
@GetMapping("/user_id")
public BaseResponse nonValue(PageQuery pageQuery, String start, String end, Integer groups,String name) {
Date startParse = null;
if (StrUtil.isNotBlank(start)) {
......@@ -99,13 +95,26 @@ public class NonStandardValueController {
return BaseResponse.errorMsg("失败!");
}
@ApiOperation("非标产值信息导出列表")
@ApiOperation("导出-产值统计-非标产值信息列表")
@PostMapping("/exportList")
public void exportList(String filename, Integer userId, String name, HttpServletResponse response) {
try {
inonStandardValueService.exportList(filename, userId, name, response);
} catch (Exception e) {
log.debug("非标产值信息导出列表{}", e);
log.debug("导出-产值统计-非标产值信息列表{}", e);
}
}
@ApiOperation("导出-产值统计-非标产值信息列表")
@PostMapping("/exportDetailList")
public void exportDetailList(Date start, Date end, Integer userId, String name, String filename,HttpServletResponse response) {
try {
inonStandardValueService.exportDetailList(start, end, userId, name, filename, response);
} catch (Exception e) {
log.debug("导出-产值统计-非标产值信息列表{}", e);
}
}
}
......@@ -155,6 +155,11 @@ public class NormProductionController {
}
@GetMapping("/statistics/detail")
@ApiImplicitParams(value = {
@ApiImplicitParam(name = "startDate", value = "开始日期", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "endDate", value = "结束日期", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "userId", value = "用户id(必传)", paramType = "query", dataType = "Integer")
})
@ApiOperation("产值统计-标准产值-个人详情")
public BaseResponse normProductionDetails(PageQuery pageQuery, String startDate, String endDate, Integer userId) {
try {
......@@ -167,6 +172,13 @@ public class NormProductionController {
@GetMapping("/statistics/specificDetail")
@ApiImplicitParams(value = {
@ApiImplicitParam(name = "startDate", value = "开始日期", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "endDate", value = "结束日期", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "userId", value = "用户id(必传)", paramType = "query", dataType = "Integer"),
@ApiImplicitParam(name = "type", value = "类型 0:处理项 1:检测组 2:检测项", paramType = "query", dataType = "Integer"),
@ApiImplicitParam(name = "objId", value = "对象id(非必传)", paramType = "query", dataType = "Integer")
})
@ApiOperation("产值统计-标准产值-个人详情-检测项目详情")
public BaseResponse normProductionSpecificDetails(PageQuery pageQuery,
String startDate, String endDate, Integer userId, Integer type, Integer objId) {
......@@ -181,6 +193,12 @@ public class NormProductionController {
@GetMapping("/total/production")
@ApiImplicitParams(value = {
@ApiImplicitParam(name = "start", value = "开始日期", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "end", value = "结束日期", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "name", value = "姓名", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "groupId", value = "工作组id", paramType = "query", dataType = "Integer")
})
@ApiOperation("产值统计-总产值统计")
public BaseResponse<Page<ProductionVo>> production(PageQuery pageQuery, String name, String start, String end, Integer groupId) {
Long startTime = null;
......@@ -200,44 +218,60 @@ public class NormProductionController {
//****************************导出*****************************************************
@ApiOperation("导出-产值统计-标准产值-列表")
@ApiImplicitParams(value = {
@ApiImplicitParam(name = "startDate", value = "开始日期", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "endDate", value = "结束日期", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "userName", value = "姓名", paramType = "query", dataType = "String")
})
@PostMapping("/export/statistics")
public void exportStatisticsList(String startDate, String endDate, String userName, String fileName, HttpServletResponse response) {
/* @PostMapping("/export/statistics")
@ApiOperation("导出标准产值列表")
public void exportNormProductionStatistics(String start, String end, String name, Integer groupId, HttpServletResponse response) {
Long startTime = null;
Long endTime = null;
if (StrUtil.isNotBlank(start) && StrUtil.isNotBlank(end)) {
startTime = DateUtil.parseDate(start).getTime();
endTime = DateUtil.parseDate(end).offsetNew(DateField.DAY_OF_MONTH, 1).getTime();
try {
iPrecipriceService.exportStatisticsList(startDate, endDate, userName, fileName, response);
} catch (Exception e) {
log.debug("导出-产值统计-标准产值-列表{}", e);
}
}
iNormProductionService.exportNormProductionStatistics(startTime, endTime, name, groupId, response);
}*/
/* @PostMapping("/export/statistics/detail")
@ApiOperation("导出个人标准产值详情列表")
public void exportNormProductionDetails(Integer userId, String start,
String end, HttpServletResponse response) {
Long startTime = null;
Long endTime = null;
if (StrUtil.isNotBlank(start) && StrUtil.isNotBlank(end)) {
startTime = DateUtil.parseDate(start).getTime();
endTime = DateUtil.parseDate(end).offsetNew(DateField.DAY_OF_MONTH, 1).getTime();
@ApiOperation("导出-产值统计-标准产值-个人详情")
@ApiImplicitParams(value = {
@ApiImplicitParam(name = "startDate", value = "开始日期", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "endDate", value = "结束日期", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "userId", value = "用户id(必传)", paramType = "query", dataType = "Integer")
})
@PostMapping("/export/statisticsDetail")
public void exportStatisticsDetail(String startDate, String endDate, Integer userId, String fileName, HttpServletResponse response) {
try {
iPrecipriceService.exportStatisticsDetail(startDate, endDate, userId, fileName, response);
} catch (Exception e) {
log.debug("导出-产值统计-标准产值-个人详情{}", e);
}
}
iPrecipriceService.exportNormProductionDetail(userId, startTime, endTime, response);
}*/
/* @PostMapping("/export/total/production")
@ApiOperation("导出总产值")
public void exportProduction(String name, String start, String end, Integer groupId, HttpServletResponse response) {
@ApiOperation("导出-产值统计-产值统计-总产值统计")
@ApiImplicitParams(value = {
@ApiImplicitParam(name = "start", value = "开始日期", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "end", value = "结束日期", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "name", value = "姓名", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "groupId", value = "工作组id", paramType = "query", dataType = "Integer")
})
@PostMapping("/export/total/production")
public void exportProduction(String name, String start, String end, Integer groupId, String fileName, HttpServletResponse response) {
Long startTime = null;
Long endTime = null;
if (StrUtil.isNotBlank(start) && StrUtil.isNotBlank(end)) {
startTime = DateUtil.parseDate(start).getTime();
endTime = DateUtil.parseDate(end).offsetNew(DateField.DAY_OF_MONTH, 1).getTime();
}
iNormProductionService.exportProduction(name, startTime, endTime, groupId, response);
}*/
try {
iPrecipriceService.exportProduction(name, startTime, endTime, groupId, fileName, response);
} catch (Exception e) {
log.debug("导出-产值统计-产值统计-总产值统计{}", e);
}
}
}
......@@ -42,7 +42,7 @@
<select id="exportList" resultType="java.util.HashMap">
SELECT
IF(ISNULL(na.id),'',na.id) as 序号,
(@i:=@i+1) as 序号,
IF(ISNULL(su.name),'',su.name) as 姓名,
IF(ISNULL(su.username),'',su.username) as 账户,
IF(ISNULL(na.statistical),'',na.statistical) as 起止时间,
......@@ -58,6 +58,7 @@
)as 状态
FROM nonstandard_apply na
LEFT JOIN sys_user su ON su.id = na.user_id
,(select @i:=0)aa
<include refid="where"/>
order by na.start_time desc
</select>
......
......@@ -40,33 +40,22 @@
<include refid="where"/>
order by na.start_time desc
</select>
<!-- <select id="getByUserId" resultType="cn.wise.sc.cement.business.model.vo.NonStandardValueVo">-->
<!-- select na.*,su.name as name,su.username as account,na.start_time as startTime,su.group_id as groups,sg.name as-->
<!-- groupname-->
<!-- from nonstandard_apply na-->
<!-- LEFT JOIN sys_user su ON su.id = na.user_id-->
<!-- LEFT JOIN sys_group sg ON sg.id = su.group_id-->
<!-- <include refid="where"/>-->
<!-- order by na.id asc-->
<!-- </select>-->
<select id="exportList" resultType="java.util.HashMap">
SELECT
IF(ISNULL(na.id),'',na.id) as 序号,
IF(ISNULL(su.name),'',su.name) su.name as 姓名,
(@i:=@i+1) as 序号,
IF(ISNULL(su.name),'',su.name) as 姓名,
IF(ISNULL(su.username),'',su.username) as 账户,
IF(ISNULL(na.statistical),'',na.statistical) as 起止日期,
IF(ISNULL(na.reported_hours),'',na.reported_hours) as 上报工日,
IF(ISNULL(na.approval_hours),'',na.approval_hours) as 审批工日,
IF(ISNULL(na.final_value),'',na.final_value) as 最终产值,
IF(ISNULL(na.work_type),'',na.work_type) as 工作类别,
IF(ISNULL(na.work_description),'',na.work_description) as 工作描述,
IF(ISNULL(su.group_id),'',su.group_id) as 部门id,
IF(ISNULL(sg.name),'',sg.name) as 部门名
IF(ISNULL(na.final_value),'',na.final_value) as 最终产值
FROM nonstandard_apply na
left join sys_user su on na.user_id = su.id
LEFT JOIN sys_group sg ON sg.id = su.group_id
,(select @i:=0)aa
<include refid="where"/>
order by na.start_time desc
</select>
</mapper>
\ No newline at end of file
......@@ -39,13 +39,8 @@ public interface INonStandardValueService extends IService<NonStandardValue> {
*/
BaseResponse<List<NonStandardValueVo>> getList(Date start, Date end, Integer groups, String name);
/**
* 非标产值列表导出
*
* @param filename 文件名
* @param userId 用户id
* @param name 姓名
* @param response
*/
void exportList(String filename, Integer userId, String name, HttpServletResponse response);
void exportDetailList(Date start, Date end, Integer userId, String name, String filename,HttpServletResponse response);
}
......@@ -32,6 +32,8 @@ public interface INormProductionService extends IService<NormProduction> {
BaseResponse<IPage<NormProductionVo>> getPage(PageQuery pageQuery, Integer type);
List<NormProductionVo> getList();
BaseResponse<Integer> activeOrForbidden(Integer id);
......
......@@ -9,6 +9,8 @@ import cn.wise.sc.cement.business.model.vo.ProductionVo;
import cn.wise.sc.cement.business.model.vo.WorkloadStatisticsVo;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import javax.servlet.http.HttpServletResponse;
import java.util.Date;
import java.util.List;
......@@ -38,4 +40,16 @@ public interface IPrecipriceService extends IService<Preciprice> {
List<ProductionVo> production(String name, Long start, Long end, Integer groupId);
boolean updateStatusByEntrustId(Integer entrustId);
void exportStatisticsList(String startDate, String endDate, String userName, String fileName, HttpServletResponse response);
void exportStatisticsDetail(String startDate, String endDate, Integer userId, String fileName, HttpServletResponse response);
void exportProduction(String name, Long start, Long end, Integer groupId, String fileName, HttpServletResponse response);
}
package cn.wise.sc.cement.business.service.impl;
import cn.wise.sc.cement.business.entity.NonStandardValue;
import cn.wise.sc.cement.business.entity.SysUser;
import cn.wise.sc.cement.business.mapper.NonStandardValueMapper;
import cn.wise.sc.cement.business.model.BaseResponse;
import cn.wise.sc.cement.business.model.PageQuery;
import cn.wise.sc.cement.business.model.vo.NonStandardApplyVo;
import cn.wise.sc.cement.business.model.vo.NonStandardValueVo;
import cn.wise.sc.cement.business.service.INonStandardValueService;
import cn.wise.sc.cement.business.service.ISysUserService;
import cn.wise.sc.cement.business.util.ExcelUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
......@@ -33,6 +37,8 @@ public class NonStandardValueServiceImpl extends ServiceImpl<NonStandardValueMap
@Resource
private NonStandardValueMapper nonStandardValueMapper;
@Autowired
private ISysUserService userService;
@Override
public BaseResponse<IPage<NonStandardValueVo>> getPage(PageQuery pageQuery, Integer userId, String name,Date start, Date end) {
......@@ -47,18 +53,6 @@ public class NonStandardValueServiceImpl extends ServiceImpl<NonStandardValueMap
return BaseResponse.okData(pages);
}
// public BaseResponse<List<NonStandardValue>> userValue(Date start, Date end,Integer userId){
// List<NonStandardValueVo> data = getList(start, end, userId).getData();
// List<NonStandardValue> rts = new ArrayList<>();
// NonStandardValue finalNonStandardValue = new NonStandardValue();
// finalNonStandardValue.setFinalValue(0D);
// for (NonStandardValueVo nonStandardValueVo:data){
// Double newFinalValue = nonStandardValueVo.getFinalValue() + finalNonStandardValue.getFinalValue();
// finalNonStandardValue.setFinalValue(newFinalValue);
// }
// rts.add(finalNonStandardValue);
// return BaseResponse.okData(rts);
// }
@Override
//计算每个用户提交的非标产值
......@@ -139,13 +133,7 @@ public class NonStandardValueServiceImpl extends ServiceImpl<NonStandardValueMap
return BaseResponse.okData(rts);
}
// @Override
// public BaseResponse<List<NonStandardValueVo>> getByUserId(Integer userId) {
// Map<String, Object> params = new HashMap<>();
// params.put("userId", userId);
// List<NonStandardValueVo> list = nonStandardValueMapper.getByUserId(params);
// return BaseResponse.okData(list);
// }
@Override
public BaseResponse<List<NonStandardValueVo>> getList(Date start, Date end, Integer groups,String name) {
......@@ -159,8 +147,16 @@ public class NonStandardValueServiceImpl extends ServiceImpl<NonStandardValueMap
return BaseResponse.okData(list);
}
/**
* 导出-产值统计-非标产值-信息列表
* @param filename 文件名
* @param userId 用户id
* @param name 姓名
* @param response
*/
@Override
public void exportList(String filename, Integer userId, String name, HttpServletResponse response) {
Map<String, Object> params = new HashMap<>();
params.put("userId", userId);
params.put("name", name);
......@@ -168,19 +164,13 @@ public class NonStandardValueServiceImpl extends ServiceImpl<NonStandardValueMap
if (!CollectionUtils.isEmpty(list)) {
Map<String, Object> map = list.get(0);
String[] headers = new String[11];
String[] headers = new String[6];
headers[0] = "序号";
headers[1] = "姓名";
headers[2] = "账户";
headers[3] = "起止日期";
headers[4] = "上报工日";
headers[5] = "审批工日";
headers[6] = "最终产值";
headers[7] = "工作类别";
headers[8] = "工作描述";
headers[9] = "部门id";
headers[10] = "部门名";
headers[3] = "上报工日";
headers[4] = "审批工日";
headers[5] = "最终产值";
List<Object[]> datas = new ArrayList<>(list.size());
for (Map<String, Object> m : list) {
Object[] objects = new Object[headers.length];
......@@ -199,4 +189,55 @@ public class NonStandardValueServiceImpl extends ServiceImpl<NonStandardValueMap
datas, response);
}
}
/**
* 导出-产值统计-非标产值-详情信息列表
* @param start
* @param end
* @param userId
* @param name
* @param filename
* @param response
*/
@Override
public void exportDetailList(Date start, Date end, Integer userId, String name, String filename,HttpServletResponse response) {
Assert.notNull(userId, "用户id不能为空!");
SysUser sysUser = userService.getById(userId);
Map<String, Object> params = new HashMap<>();
params.put("start", start);
params.put("end", end);
params.put("userId", userId);
params.put("name", name);
params.put("status",2);
List<NonStandardValueVo> list = nonStandardValueMapper.getList(params);
if (!CollectionUtils.isEmpty(list)) {
String[] headers = new String[7];
headers[0] = "序号";
headers[1] = "姓名";
headers[2] = "工作类型";
headers[3] = "工作描述";
headers[4] = "上报工日";
headers[5] = "审批工日";
headers[6] = "最终产值";
List<Object[]> datas = new ArrayList<>(list.size());
int i = 0;
for (NonStandardValueVo target : list) {
Object[] objs = new Object[7];
objs[0] = i++;
objs[1] = target.getName();
objs[2] = target.getWorkType();
objs[3] = target.getWorkDescription();
objs[4] = target.getReportedHours();
objs[5] = target.getApprovalHours();
objs[6] = target.getFinalValue();
datas.add(objs);
}
ExcelUtil.excelExport(
filename == null || filename.trim().length() <= 0 ? "非标产值-"+sysUser.getName() : filename, headers,
datas, response);
}
}
}
......@@ -128,6 +128,7 @@ public class NormProductionServiceImpl extends ServiceImpl<NormProductionMapper,
}
//如果是处理项 只能添加一次
if(normProduction.getType() == 0){
normProduction.setAssessId(null);
//判断配置项目是否已存在
QueryWrapper<NormProduction> qw = new QueryWrapper<>();
qw.eq("type", normProduction.getType());
......@@ -225,6 +226,7 @@ public class NormProductionServiceImpl extends ServiceImpl<NormProductionMapper,
//如果是处理项 只能添加一次
if(normProduction.getType() == 0){
normProduction.setAssessId(null);
//判断配置项目是否已存在
QueryWrapper<NormProduction> qw = new QueryWrapper<>();
qw.eq("type", normProduction.getType());
......@@ -373,6 +375,69 @@ public class NormProductionServiceImpl extends ServiceImpl<NormProductionMapper,
return BaseResponse.okData(rts);
}
/**
* 产值配置列表
* @return
*/
@Override
public List<NormProductionVo> getList() {
QueryWrapper<NormProduction> qw = new QueryWrapper<>();
//关联名字
List<NormProduction> normProductions = this.list(qw);
List<Integer> npTeamGroupIds = new ArrayList<>(normProductions.size());
List<Integer> npTeamIds = new ArrayList<>(normProductions.size());
normProductions.forEach(arg -> {
if(arg.getType() == 1) {
npTeamGroupIds.add(arg.getAssessId());
}else if(arg.getType() == 2) {
npTeamIds.add(arg.getAssessId());
}
});
List<TeamGroup> teamGroups = new ArrayList<>();
if (npTeamGroupIds.size() != 0) {
teamGroups = iTeamGroupService.listByIds(npTeamGroupIds);
}
List<Team> teams = new ArrayList<>();
if (npTeamIds.size() != 0) {
teams = iTeamService.listByIds(npTeamIds);
}
List<NormProductionVo> records = new ArrayList<>();
List<TeamGroup> finalTeamGroups = teamGroups;
List<Team> finalTeams = teams;
normProductions.forEach(arg -> {
NormProductionVo normProductionVo = new NormProductionVo();
BeanUtil.copyProperties(arg, normProductionVo);
normProductionVo.setAssessName("/");
if (arg.getType() == 0) {
normProductionVo.setAssessName("处理项");
} else if(arg.getType() == 1) {
finalTeamGroups.stream()
.filter(opt -> opt.getId().intValue() == arg.getAssessId())
.findFirst()
.ifPresent(opt -> normProductionVo.setAssessName(opt.getName()));
} else if(arg.getType() == 2) {
finalTeams.stream()
.filter(opt -> opt.getId().intValue() == arg.getAssessId())
.findFirst()
.ifPresent(opt -> normProductionVo.setAssessName(opt.getName()));
}
if (arg.getType() == 0) {
normProductionVo.setType("处理项");
}else if(arg.getType() == 1) {
normProductionVo.setType("检测组");
}else if(arg.getType() == 2) {
normProductionVo.setType("检测项");
}
records.add(normProductionVo);
});
return records;
}
/**
* 启用禁用标准产值
* @param id id
......@@ -395,6 +460,4 @@ public class NormProductionServiceImpl extends ServiceImpl<NormProductionMapper,
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment