Commit 69520eee authored by 竹天卫's avatar 竹天卫
parents 469d8fda a9af5ea7
...@@ -26,6 +26,7 @@ import org.springframework.web.bind.annotation.RequestBody; ...@@ -26,6 +26,7 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletResponse;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -134,6 +135,7 @@ public class NormProductionController { ...@@ -134,6 +135,7 @@ public class NormProductionController {
} }
@GetMapping("/total/production") @GetMapping("/total/production")
@ApiOperation("总产值统计")
public BaseResponse production(PageQuery pageQuery, String name, String start, String end) { public BaseResponse production(PageQuery pageQuery, String name, String start, String end) {
Long startTime = null; Long startTime = null;
...@@ -148,5 +150,44 @@ public class NormProductionController { ...@@ -148,5 +150,44 @@ public class NormProductionController {
return BaseResponse.okData(PageUtil.listConvertToPage(rts, pageQuery)); return BaseResponse.okData(PageUtil.listConvertToPage(rts, pageQuery));
} }
@GetMapping("/export/statistics")
@ApiOperation("导出标准产值列表")
public void exportNormProductionStatistics(String start, String end, String name, HttpServletResponse response) {
Long startTime = null;
Long endTime = null;
if (StrUtil.isNotBlank(start) && StrUtil.isNotBlank(end)) {
startTime = DateUtil.parseDate(start).getTime();
endTime = DateUtil.parseDate(end).getTime();
}
iNormProductionService.exportNormProductionStatistics(startTime, endTime, name, response);
}
@GetMapping("/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).getTime();
}
iNormProductionService.exportNormProductionDetail(userId, startTime, endTime, response);
}
@GetMapping("/export/total/production")
@ApiOperation("导出总产值")
public void exportProduction(String name, 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).getTime();
}
iNormProductionService.exportProduction(name, startTime, endTime, response);
}
} }
...@@ -3,6 +3,7 @@ package cn.wise.sc.cement.business.controller; ...@@ -3,6 +3,7 @@ package cn.wise.sc.cement.business.controller;
import cn.wise.sc.cement.business.entity.EntrustReport; import cn.wise.sc.cement.business.entity.EntrustReport;
import cn.wise.sc.cement.business.model.BaseResponse; import cn.wise.sc.cement.business.model.BaseResponse;
import cn.wise.sc.cement.business.model.PageQuery; import cn.wise.sc.cement.business.model.PageQuery;
import cn.wise.sc.cement.business.model.ReportDetailVo;
import cn.wise.sc.cement.business.model.vo.EntrustVo; import cn.wise.sc.cement.business.model.vo.EntrustVo;
import cn.wise.sc.cement.business.service.IEntrustService; import cn.wise.sc.cement.business.service.IEntrustService;
import cn.wise.sc.cement.business.util.PageUtil; import cn.wise.sc.cement.business.util.PageUtil;
...@@ -73,19 +74,14 @@ public class ReportController { ...@@ -73,19 +74,14 @@ public class ReportController {
@GetMapping("/{entrustId}") @GetMapping("/{entrustId}")
@ApiOperation("获取报告详情") @ApiOperation("获取报告详情")
public BaseResponse<Page<EntrustReport>> getReportDetail(@PathVariable("entrustId") Integer entrustId, PageQuery pageQuery) { public BaseResponse<ReportDetailVo> getReportDetail(@PathVariable("entrustId") Integer entrustId, PageQuery pageQuery) {
List<EntrustReport> entrustReports = iEntrustService.getReportDetail(entrustId); ReportDetailVo rts = iEntrustService.getReportDetail(entrustId);
if (rts ==null) {
if (entrustReports.size() != 0) { return BaseResponse.errorMsg("没找到相关数据!");
//过滤 id==null 和 projectType != '常规项目' }else {
List<EntrustReport> list = entrustReports.stream()
.filter(arg -> arg.getId() != null && "常规项目".equals(arg.getProjectType()))
.collect(Collectors.toList());
Page<EntrustReport> rts = PageUtil.listConvertToPage(list, pageQuery);
return BaseResponse.okData(rts); return BaseResponse.okData(rts);
} }
return BaseResponse.errorMsg("没找到相关数据!");
} }
} }
...@@ -2,6 +2,8 @@ package cn.wise.sc.cement.business.entity; ...@@ -2,6 +2,8 @@ package cn.wise.sc.cement.business.entity;
import lombok.Data; import lombok.Data;
import java.util.Date;
/** /**
* @description: 委托报告 * @description: 委托报告
* @author: qh * @author: qh
...@@ -25,7 +27,7 @@ public class EntrustReport { ...@@ -25,7 +27,7 @@ public class EntrustReport {
/** /**
* 委托方id * 委托方id
*/ */
private Integer clintId; private Integer clientId;
/** /**
* 样品id * 样品id
...@@ -86,4 +88,9 @@ public class EntrustReport { ...@@ -86,4 +88,9 @@ public class EntrustReport {
* 项目类型 * 项目类型
*/ */
private String projectType; private String projectType;
/**
* 样品创建时间
*/
private Date sendTime;
} }
...@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; ...@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
...@@ -22,4 +23,10 @@ public interface EquipmentUseMapper extends BaseMapper<EquipmentUse> { ...@@ -22,4 +23,10 @@ public interface EquipmentUseMapper extends BaseMapper<EquipmentUse> {
IPage<EquipmentUseVo> getPage(@Param("page") Page page, @Param("params") Map<String, Object> params); IPage<EquipmentUseVo> getPage(@Param("page") Page page, @Param("params") Map<String, Object> params);
/**
* 根据项目id获取使用到的设备名字
* @param entrustId 项目id
* @return list
*/
List<String> getEquipmentNamesByProjectId(@Param("param") Integer entrustId);
} }
...@@ -242,7 +242,7 @@ ...@@ -242,7 +242,7 @@
SELECT e.id,e.project_name,e.send_name,e.client_id,e.entrust_code,e.project_type,sscct.* FROM entrust e SELECT e.id,e.project_name,e.send_name,e.client_id,e.entrust_code,e.project_type,sscct.* FROM entrust e
RIGHT JOIN RIGHT JOIN
(SELECT id as sample_id,entrust_id,team_ids,method_numbers,name,scct.check_id, (SELECT id as sample_id,entrust_id,team_ids,method_numbers,name,scct.check_id,
scct.equipment_name,scct.user_id FROM sample s scct.equipment_name,scct.user_id,create_time as send_time FROM sample s
RIGHT JOIN RIGHT JOIN
(SELECT check_id,equipment_name,sample_id,user_id FROM sample_check_team sct (SELECT check_id,equipment_name,sample_id,user_id FROM sample_check_team sct
LEFT JOIN LEFT JOIN
...@@ -250,6 +250,7 @@ ...@@ -250,6 +250,7 @@
ON sct.check_id = sc.id) scct ON sct.check_id = sc.id) scct
ON s.sample_id = scct.sample_id) sscct ON s.sample_id = scct.sample_id) sscct
ON sscct.entrust_id = e.id AND e.id = #{entrustId} ON sscct.entrust_id = e.id AND e.id = #{entrustId}
WHERE id IS NOT NULL
</select> </select>
<select id="getQualityDetail" resultType="cn.wise.sc.cement.business.entity.QualityDetail"> <select id="getQualityDetail" resultType="cn.wise.sc.cement.business.entity.QualityDetail">
......
...@@ -24,6 +24,13 @@ ...@@ -24,6 +24,13 @@
<include refid="where" /> <include refid="where" />
ORDER BY et.create_time ASC ORDER BY et.create_time ASC
</select> </select>
<select id="getEquipmentNamesByProjectId" resultType="java.lang.String">
SELECT CONCAT(e.`name`,' (',e.`code`,')') FROM equipment_use eu
RIGHT JOIN
(SELECT `name`,id,`code` FROM equipment) e
ON eu.equipment_id = e.id AND eu.project_id = #{param}
WHERE eu.id IS NOT NULL
</select>
</mapper> </mapper>
package cn.wise.sc.cement.business.model;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Set;
/**
* @description: 报告详情Vo
* @author: qh
* @create: 2020-10-10 09:38
**/
@Data
@ApiModel("报告首页信息")
public class ReportDetailVo implements Serializable {
private static final long serialVersionUID = 42L;
@ApiModelProperty("报告编号")
private String reportNo;
@ApiModelProperty("送样单位")
private String sendName;
@ApiModelProperty("送样人")
private String sender;
@ApiModelProperty("送样日期")
private String sendDate;
@ApiModelProperty("样品数量")
private Integer sampleNum;
@ApiModelProperty("样品名称")
private Set<String> sampleNames;
@ApiModelProperty("检测类别")
private String type="委托";
@ApiModelProperty("检测项目")
private Set<String> teamNames;
@ApiModelProperty("检测依据")
private Set<String> methodNames;
@ApiModelProperty("主要仪器设备(编号)")
private Set<String> equipmentNames;
@ApiModelProperty("项目名称")
private String projectName;
@ApiModelProperty("签发日期")
private String printDate;
}
...@@ -6,6 +6,7 @@ import cn.wise.sc.cement.business.entity.SampleDistribution; ...@@ -6,6 +6,7 @@ import cn.wise.sc.cement.business.entity.SampleDistribution;
import cn.wise.sc.cement.business.entity.SampleHandleEnclosure; import cn.wise.sc.cement.business.entity.SampleHandleEnclosure;
import cn.wise.sc.cement.business.model.BaseResponse; import cn.wise.sc.cement.business.model.BaseResponse;
import cn.wise.sc.cement.business.model.PageQuery; import cn.wise.sc.cement.business.model.PageQuery;
import cn.wise.sc.cement.business.model.ReportDetailVo;
import cn.wise.sc.cement.business.model.query.*; import cn.wise.sc.cement.business.model.query.*;
import cn.wise.sc.cement.business.model.vo.*; import cn.wise.sc.cement.business.model.vo.*;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
...@@ -86,7 +87,7 @@ public interface IEntrustService extends IService<Entrust> { ...@@ -86,7 +87,7 @@ public interface IEntrustService extends IService<Entrust> {
BaseResponse<Boolean> deleteById(Integer id); BaseResponse<Boolean> deleteById(Integer id);
List<EntrustReport> getReportDetail(Integer entrustId); ReportDetailVo getReportDetail(Integer entrustId);
BaseResponse<IPage<EntrustVo>> getQualityPage(PageQuery pageQuery, BaseResponse<IPage<EntrustVo>> getQualityPage(PageQuery pageQuery,
String startDate, String endDate, String startDate, String endDate,
......
...@@ -9,6 +9,7 @@ import cn.wise.sc.cement.business.model.vo.ProductionVo; ...@@ -9,6 +9,7 @@ import cn.wise.sc.cement.business.model.vo.ProductionVo;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import javax.servlet.http.HttpServletResponse;
import java.util.List; import java.util.List;
/** /**
...@@ -74,4 +75,31 @@ public interface INormProductionService extends IService<NormProduction> { ...@@ -74,4 +75,31 @@ public interface INormProductionService extends IService<NormProduction> {
Long start, Long end); Long start, Long end);
List<ProductionVo> production(String name,Long start,Long end); List<ProductionVo> production(String name,Long start,Long end);
/**
* 导出标准统计
* @param start 开始时间
* @param end 结束时间
* @param name 人员名字
* @param response 响应体
*/
void exportNormProductionStatistics(Long start, Long end, String name, HttpServletResponse response);
/**
* 导出标准统计详情
* @param userId 用户id
* @param startTime 开始时间
* @param endTime 结束时间
* @param response 响应体
*/
void exportNormProductionDetail(Integer userId, Long startTime, Long endTime, HttpServletResponse response);
/**
* 导出产值总统计列表
* @param name 名字检索
* @param startTime 开始时间
* @param endTime 结束时间
* @param response 响应体
*/
void exportProduction(String name, Long startTime, Long endTime,HttpServletResponse response);
} }
package cn.wise.sc.cement.business.service.impl; package cn.wise.sc.cement.business.service.impl;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
...@@ -29,14 +30,17 @@ import cn.wise.sc.cement.business.service.ISampleHandleService; ...@@ -29,14 +30,17 @@ import cn.wise.sc.cement.business.service.ISampleHandleService;
import cn.wise.sc.cement.business.service.ISysPostService; import cn.wise.sc.cement.business.service.ISysPostService;
import cn.wise.sc.cement.business.service.ISysUserService; import cn.wise.sc.cement.business.service.ISysUserService;
import cn.wise.sc.cement.business.service.ITeamGroupService; import cn.wise.sc.cement.business.service.ITeamGroupService;
import cn.wise.sc.cement.business.util.ExcelUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
...@@ -276,6 +280,7 @@ public class NormProductionServiceImpl extends ServiceImpl<NormProductionMapper, ...@@ -276,6 +280,7 @@ public class NormProductionServiceImpl extends ServiceImpl<NormProductionMapper,
NormProductionStatistics productionStatistics = new NormProductionStatistics(); NormProductionStatistics productionStatistics = new NormProductionStatistics();
productionStatistics.setAccount(sysUser.getUsername()); productionStatistics.setAccount(sysUser.getUsername());
productionStatistics.setCoefficient(coefficientMap.get(userId).intValue()); productionStatistics.setCoefficient(coefficientMap.get(userId).intValue());
productionStatistics.setTime("/");
productionStatistics.setCount(normProductionDetails.stream() productionStatistics.setCount(normProductionDetails.stream()
.filter(arg -> arg.getUserId().intValue() == sysUser.getId()) .filter(arg -> arg.getUserId().intValue() == sysUser.getId())
.count()); .count());
...@@ -415,7 +420,7 @@ public class NormProductionServiceImpl extends ServiceImpl<NormProductionMapper, ...@@ -415,7 +420,7 @@ public class NormProductionServiceImpl extends ServiceImpl<NormProductionMapper,
Date finalStartDate = startDate; Date finalStartDate = startDate;
Date finalEndDate = endDate; Date finalEndDate = endDate;
rts.forEach(arg -> { rts.forEach(arg -> {
arg.setTime(finalStartDate == null ? "--" + finalEndDate.toString() : finalStartDate.toString() + "--" + finalEndDate.toString()); arg.setTime(finalStartDate == null ? "/" : DateUtil.format(finalStartDate, "yyyy-MM-dd") + "--" + DateUtil.format(finalEndDate, "yyyy-MM-dd"));
if (StrUtil.isBlank(arg.getUserName())) { if (StrUtil.isBlank(arg.getUserName())) {
//关联用户信息 //关联用户信息
users.stream().filter(opt -> arg.getUserId().equals(opt.getId() + "")).findFirst() users.stream().filter(opt -> arg.getUserId().equals(opt.getId() + "")).findFirst()
...@@ -440,6 +445,112 @@ public class NormProductionServiceImpl extends ServiceImpl<NormProductionMapper, ...@@ -440,6 +445,112 @@ public class NormProductionServiceImpl extends ServiceImpl<NormProductionMapper,
return rts; return rts;
} }
@Override
public void exportNormProductionStatistics(Long start, Long end, String name, HttpServletResponse response) {
BaseResponse<List<NormProductionStatistics>> listBaseResponse = normProductionStatistics(start, end, name);
if (listBaseResponse.getCode() == 200) {
List<NormProductionStatistics> data = listBaseResponse.getData();
if (CollectionUtil.isNotEmpty(data)) {
String[] headers = new String[8];
headers[0] = "用户编号";
headers[1] = "用户名";
headers[2] = "账号";
headers[3] = "性别";
headers[4] = "职务";
headers[5] = "统计时间";
headers[6] = "检测项目数";
headers[7] = "产值绩效";
List<Object[]> exportData = new ArrayList<>(data.size());
for (NormProductionStatistics productionStatistics : data) {
Object[] objs = new Object[8];
objs[0] = productionStatistics.getUserId();
objs[1] = productionStatistics.getUserName();
objs[2] = productionStatistics.getAccount();
objs[3] = productionStatistics.getSex();
objs[4] = productionStatistics.getPosition();
objs[5] = productionStatistics.getTime();
objs[6] = productionStatistics.getCount();
objs[7] = productionStatistics.getCoefficient();
exportData.add(objs);
}
ExcelUtil.excelExport(
"标准产值统计", headers,
exportData, response);
}
}
}
@Override
public void exportNormProductionDetail(Integer userId, Long startTime, Long endTime, HttpServletResponse response) {
List<NormProduction.NormProductionDetail> normProductionDetails = normProductionDetails(userId, startTime, endTime);
if (CollectionUtil.isNotEmpty(normProductionDetails)) {
String[] headers = new String[11];
headers[0] = "序号";
headers[1] = "名字";
headers[2] = "检测项目";
headers[3] = "所属项目";
headers[4] = "项目编号";
headers[5] = "检测时间";
headers[6] = "分析占比";
headers[7] = "分样占比";
headers[8] = "校核占比";
headers[9] = "报结果占比";
headers[10] = "合计";
List<Object[]> exportData = new ArrayList<>(normProductionDetails.size());
int count = 0;
DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("yyyy年MM月dd日 hh:mm:ss");
for (NormProduction.NormProductionDetail target : normProductionDetails) {
Object[] objs = new Object[11];
objs[0] = count++;
objs[1] = target.getUserName();
objs[2] = target.getGroupTeamName();
objs[3] = target.getProjectName();
objs[4] = target.getEntrustCode();
objs[5] = target.getCheckTime() == null ? "/" : target.getCheckTime().format(timeFormatter);
objs[6] = target.getAnalyseRate();
objs[7] = target.getSeparateRate();
objs[8] = target.getAssessRate();
objs[9] = target.getReportedResultRate();
objs[10] = target.getWorkTimeCoefficient();
exportData.add(objs);
}
ExcelUtil.excelExport("标准产值详情—" + normProductionDetails.get(0).getUserName(), headers, exportData, response);
}
}
@Override
public void exportProduction(String name, Long startTime, Long endTime, HttpServletResponse response) {
List<ProductionVo> data = production(name, startTime, endTime);
if (CollectionUtil.isNotEmpty(data)) {
String[] headers = new String[8];
headers[0] = "序号";
headers[1] = "姓名";
headers[2] = "账户";
headers[3] = "职务";
headers[4] = "统计时间";
headers[5] = "标准产值";
headers[6] = "非标准产值";
headers[7] = "产值统计";
List<Object[]> exportData = new ArrayList<>(data.size());
int count = 0;
for (ProductionVo target : data) {
Object[] objs = new Object[8];
objs[0] = count++;
objs[1] = target.getUserName();
objs[2] = target.getAccount();
objs[3] = target.getPosition();
objs[4] = target.getTime();
objs[5] = target.getProductionValue();
objs[6] = target.getNonProductionValue();
objs[7] = target.getProductionTotalValue();
exportData.add(objs);
}
ExcelUtil.excelExport("产值统计", headers, exportData, response);
}
}
/** /**
* 计算校核单每条数据的标准产值 * 计算校核单每条数据的标准产值
* *
......
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