Commit 9e529091 authored by 竹天卫's avatar 竹天卫
parents f3030eff 554c846d
...@@ -57,7 +57,7 @@ public class PrecipriceController { ...@@ -57,7 +57,7 @@ public class PrecipriceController {
@GetMapping("/ddd") @GetMapping("/ddd")
@ApiOperation("aaa") @ApiOperation("aaa")
public void add(){ public void add(){
iNormProductionService.createPreciprice(1,1,1,1,1); iNormProductionService.createPreciprice(1,1,1,1,1,true);
} }
......
...@@ -24,6 +24,7 @@ import org.springframework.web.bind.annotation.*; ...@@ -24,6 +24,7 @@ import org.springframework.web.bind.annotation.*;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import javax.servlet.ServletOutputStream; import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
...@@ -211,5 +212,10 @@ public class SampleController { ...@@ -211,5 +212,10 @@ public class SampleController {
return BaseResponse.errorMsg("失败!"); return BaseResponse.errorMsg("失败!");
} }
@ApiOperation("下载样品处理记录")
@PostMapping("/uploadSampleSaveList")
public void upload(HttpServletResponse response){
sampleService.upload(response);
}
} }
...@@ -187,9 +187,9 @@ public class StandardController { ...@@ -187,9 +187,9 @@ public class StandardController {
@ApiOperation("按检测组获取标样信息") @ApiOperation("按检测组获取标样信息")
@GetMapping("/list/byGroup") @GetMapping("/list/byGroup")
public BaseResponse<List<GroupStandard>> getStandards() { public BaseResponse<List<GroupStandard>> getStandards(String name) {
return BaseResponse.okData(standardService.getStandards()); return BaseResponse.okData(standardService.getStandards(name));
} }
} }
...@@ -19,6 +19,11 @@ public class GroupStandard implements Serializable { ...@@ -19,6 +19,11 @@ public class GroupStandard implements Serializable {
*/ */
private String groupName; private String groupName;
/**
* 本所编号
*/
private String cementCode;
/** /**
* 标准样品key:value * 标准样品key:value
*/ */
......
...@@ -140,4 +140,8 @@ public class Preciprice implements Serializable { ...@@ -140,4 +140,8 @@ public class Preciprice implements Serializable {
* 检测组名 * 检测组名
*/ */
private String groupTeamName; private String groupTeamName;
/**
* 是否加急 0:不加急 1:加急
*/
private Integer isUrgent;
} }
package cn.wise.sc.cement.business.mapper; package cn.wise.sc.cement.business.mapper;
import cn.wise.sc.cement.business.entity.Sample; import cn.wise.sc.cement.business.entity.Sample;
import cn.wise.sc.cement.business.model.SampleSaveDto;
import cn.wise.sc.cement.business.model.vo.SampleManageVo; import cn.wise.sc.cement.business.model.vo.SampleManageVo;
import cn.wise.sc.cement.business.model.vo.SampleVo; import cn.wise.sc.cement.business.model.vo.SampleVo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
...@@ -55,4 +56,6 @@ public interface SampleMapper extends BaseMapper<Sample> { ...@@ -55,4 +56,6 @@ public interface SampleMapper extends BaseMapper<Sample> {
@Select("select * from sample where entrust_id = #{entrustId} order by id asc") @Select("select * from sample where entrust_id = #{entrustId} order by id asc")
List<Sample> getSampleCheckList(Integer entrustId); List<Sample> getSampleCheckList(Integer entrustId);
List<SampleSaveDto> getSampleSaveList();
} }
...@@ -61,4 +61,29 @@ ...@@ -61,4 +61,29 @@
</select> </select>
<select id="getSampleSaveList" resultType="cn.wise.sc.cement.business.model.SampleSaveDto">
SELECT
s.id,
s.entrust_id,
s.`name`,
s.`sample_form`,
s.cement_code,
s.sample_code,
s.little_position,
DATE_FORMAT(s.register_time,'%Y/%m/%d') as register_time,
DATE_FORMAT(s.destruction_time,'%Y/%m/%d') as destruction_time,
s.operator_id,
s.remark,
e.project_name,
e.project_code,
su.`name` as user_name
FROM
`sample` s
LEFT JOIN entrust e
ON s.entrust_id = e.id
LEFT JOIN sys_user su
ON su.id = s.operator_id
</select>
</mapper> </mapper>
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
select s.id as group_id,s.`name` as group_name,sv.element_name,sv.element_value FROM standard s select s.id as group_id,s.`name` as group_name,sv.element_name,sv.element_value FROM standard s
INNER JOIN INNER JOIN
(SELECT * FROM standard_value) sv (SELECT * FROM standard_value) sv
ON s.id = sv.standard_id AND s.`status` = 1 ON s.id = sv.standard_id
</select> </select>
......
package cn.wise.sc.cement.business.model;
import lombok.Data;
import java.io.Serializable;
/**
* @description:
* @author: qh
* @create: 2020-11-18 17:13
**/
@Data
public class SampleSaveDto implements Serializable {
private static final long serialVersionUID = 42L;
private String id;
private String entrustId;
private String name;
private String userName;
private String projectName;
private String sampleForm;
private String cementCode;
private String sampleCode;
private String littlePosition;
private String registerTime;
private String destructionTime;
private String operatorId;
private String remark;
private String projectCode;
}
...@@ -7,14 +7,13 @@ import cn.wise.sc.cement.business.model.BaseResponse; ...@@ -7,14 +7,13 @@ import cn.wise.sc.cement.business.model.BaseResponse;
import cn.wise.sc.cement.business.model.vo.ProductionVo; import cn.wise.sc.cement.business.model.vo.ProductionVo;
import cn.wise.sc.cement.business.model.vo.WorkloadStatisticsVo; import cn.wise.sc.cement.business.model.vo.WorkloadStatisticsVo;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
/** /**
* <p> * <p>
* 服务类 * 服务类
* </p> * </p>
* *
* @author ztw * @author ztw
...@@ -22,16 +21,16 @@ import java.util.List; ...@@ -22,16 +21,16 @@ import java.util.List;
*/ */
public interface IPrecipriceService extends IService<Preciprice> { public interface IPrecipriceService extends IService<Preciprice> {
boolean createPreciprice(final Integer userId, final Integer entrustId, boolean createPreciprice(final Integer userId, final Integer entrustId,
final Integer targetId, final Integer type, final Integer targetId, final Integer type,
final Integer sampleId); final Integer sampleId, boolean isUrgent);
/** /**
* 标准产值统计 * 标准产值统计
* *
* @param start 开始时间 * @param start 开始时间
* @param end 结束时间 * @param end 结束时间
* @param groupId 部门id * @param groupId 部门id
* @return BaseResponse * @return BaseResponse
*/ */
BaseResponse<List<NormProductionStatistics>> normProductionStatistics(Long start, Long end, String name, Integer groupId); BaseResponse<List<NormProductionStatistics>> normProductionStatistics(Long start, Long end, String name, Integer groupId);
...@@ -50,53 +49,58 @@ public interface IPrecipriceService extends IService<Preciprice> { ...@@ -50,53 +49,58 @@ public interface IPrecipriceService extends IService<Preciprice> {
/** /**
* 总产值统计 * 总产值统计
* *
* @param name 用户 * @param name 用户
* @param start 开始时间 * @param start 开始时间
* @param end 结束时间 * @param end 结束时间
* @return 详细信息 * @return 详细信息
*/ */
List<ProductionVo> production(String name, Long start, Long end, Integer groupId); List<ProductionVo> production(String name, Long start, Long end, Integer groupId);
/** /**
* 导出标准统计 * 导出标准统计
* @param start 开始时间 *
* @param end 结束时间 * @param start 开始时间
* @param name 人员名字 * @param end 结束时间
* @param name 人员名字
* @param groupId 部门id * @param groupId 部门id
* @param response 响应体 * @param response 响应体
*/ */
void exportNormProductionStatistics(Long start, Long end,String name,Integer groupId, HttpServletResponse response); void exportNormProductionStatistics(Long start, Long end, String name, Integer groupId, HttpServletResponse response);
/** /**
* 导出个人标准产值详情列表 * 导出个人标准产值详情列表
* @param userId 用户id *
* @param userId 用户id
* @param startTime 开始时间 * @param startTime 开始时间
* @param endTime 结束时间 * @param endTime 结束时间
* @param response 响应体 * @param response 响应体
*/ */
void exportNormProductionDetail(Integer userId, Long startTime, Long endTime, HttpServletResponse response); void exportNormProductionDetail(Integer userId, Long startTime, Long endTime, HttpServletResponse response);
/** /**
* 导出产值总统计列表 * 导出产值总统计列表
* @param name 名字检索 *
* @param name 名字检索
* @param startTime 开始时间 * @param startTime 开始时间
* @param endTime 结束时间 * @param endTime 结束时间
* @param response 响应体 * @param response 响应体
*/ */
void exportProduction(String name, Long startTime, Long endTime,Integer groupId,HttpServletResponse response); void exportProduction(String name, Long startTime, Long endTime, Integer groupId, HttpServletResponse response);
/** /**
* 统计工作量 * 统计工作量
*
* @param startTime 开始时间 * @param startTime 开始时间
* @param endTime 结束时间 * @param endTime 结束时间
* @return 统计对象 * @return 统计对象
*/ */
List<WorkloadStatisticsVo> workloadStatistics(Date startTime, Date endTime, Integer userId); List<WorkloadStatisticsVo> workloadStatistics(Date startTime, Date endTime, Integer userId);
/** /**
* 根据报告id更新 * 根据报告id更新
*
* @param entrustId * @param entrustId
* @return * @return
*/ */
boolean updateStatusByEntrustId(Integer entrustId); boolean updateStatusByEntrustId(Integer entrustId);
} }
...@@ -46,4 +46,10 @@ public interface ISampleService extends IService<Sample> { ...@@ -46,4 +46,10 @@ public interface ISampleService extends IService<Sample> {
* @return 复查成功与否 * @return 复查成功与否
*/ */
BaseResponse<Boolean> ampleReview(Integer id); BaseResponse<Boolean> ampleReview(Integer id);
/**
* 下载样品存储信息
* @param response 响应体
*/
void upload(HttpServletResponse response);
} }
...@@ -52,5 +52,5 @@ public interface IStandardService extends IService<Standard> { ...@@ -52,5 +52,5 @@ public interface IStandardService extends IService<Standard> {
* 按检测组获取标样信息 * 按检测组获取标样信息
* @return GroupStandard * @return GroupStandard
*/ */
List<GroupStandard> getStandards(); List<GroupStandard> getStandards(String name);
} }
...@@ -1356,7 +1356,7 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl ...@@ -1356,7 +1356,7 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
//计算产值 //计算产值
if (sampleHandle.getHandleId() != null) { if (sampleHandle.getHandleId() != null) {
try { try {
iPrecipriceService.createPreciprice(sampleHandle.getUserId(),entrust.getId(),sampleHandle.getHandleId(),0,sample.getId()); iPrecipriceService.createPreciprice(sampleHandle.getUserId(),entrust.getId(),sampleHandle.getHandleId(),0,sample.getId(),true);
}catch (Exception e){ }catch (Exception e){
System.out.println(e.getMessage()); System.out.println(e.getMessage());
return BaseResponse.errorMsg(e.getMessage()); return BaseResponse.errorMsg(e.getMessage());
...@@ -1727,7 +1727,7 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl ...@@ -1727,7 +1727,7 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
if (sampleDistributionTeamGroupVoList != null && sampleDistributionTeamGroupVoList.size() > 0) { if (sampleDistributionTeamGroupVoList != null && sampleDistributionTeamGroupVoList.size() > 0) {
for (SampleDistributionTeamVo sdVo : sampleDistributionTeamGroupVoList) { for (SampleDistributionTeamVo sdVo : sampleDistributionTeamGroupVoList) {
try { try {
iPrecipriceService.createPreciprice(sdVo.getUserId(),entrust.getId(),sdVo.getTeamGroupId(),1,sample.getId()); iPrecipriceService.createPreciprice(sdVo.getUserId(),entrust.getId(),sdVo.getTeamGroupId(),1,sample.getId(),true);
}catch (Exception e){ }catch (Exception e){
return BaseResponse.errorMsg(e.getMessage()); return BaseResponse.errorMsg(e.getMessage());
} }
......
...@@ -37,17 +37,14 @@ import cn.wise.sc.cement.business.service.ISysPostService; ...@@ -37,17 +37,14 @@ 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 cn.wise.sc.cement.business.util.ExcelUtil;
import cn.wise.sc.cement.business.wrapper.page.Query;
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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal; import java.math.BigDecimal;
...@@ -132,7 +129,7 @@ public class PrecipriceServiceImpl extends ServiceImpl<PrecipriceMapper, Precipr ...@@ -132,7 +129,7 @@ public class PrecipriceServiceImpl extends ServiceImpl<PrecipriceMapper, Precipr
@Transactional(rollbackFor = Exception.class, propagation = Propagation.NESTED) @Transactional(rollbackFor = Exception.class, propagation = Propagation.NESTED)
public boolean createPreciprice(final Integer userId, final Integer entrustId, public boolean createPreciprice(final Integer userId, final Integer entrustId,
final Integer targetId, final Integer type, final Integer targetId, final Integer type,
final Integer sampleId) { final Integer sampleId, boolean isUrgent) {
Assert.notNull(userId, "用户id不能为空!"); Assert.notNull(userId, "用户id不能为空!");
Assert.notNull(entrustId, "项目id不能为空!"); Assert.notNull(entrustId, "项目id不能为空!");
...@@ -146,11 +143,10 @@ public class PrecipriceServiceImpl extends ServiceImpl<PrecipriceMapper, Precipr ...@@ -146,11 +143,10 @@ public class PrecipriceServiceImpl extends ServiceImpl<PrecipriceMapper, Precipr
throw new IllegalArgumentException("无效的项目id!"); throw new IllegalArgumentException("无效的项目id!");
} }
Preciprice preciprice = new Preciprice(); Preciprice preciprice = new Preciprice();
preciprice.setEntrustId(entrust.getId()); preciprice.setEntrustId(entrust.getId());
preciprice.setEntrustCode(entrust.getEntrustCode()); preciprice.setEntrustCode(entrust.getEntrustCode());
preciprice.setEntrustName(entrust.getProjectName()); preciprice.setEntrustName(entrust.getProjectName());
preciprice.setIsUrgent(isUrgent ? 1 : 0);
//获取样品信息 //获取样品信息
Sample sample = iSampleService.getById(sampleId); Sample sample = iSampleService.getById(sampleId);
if (BeanUtil.isEmpty(sample)) { if (BeanUtil.isEmpty(sample)) {
...@@ -181,9 +177,17 @@ public class PrecipriceServiceImpl extends ServiceImpl<PrecipriceMapper, Precipr ...@@ -181,9 +177,17 @@ public class PrecipriceServiceImpl extends ServiceImpl<PrecipriceMapper, Precipr
preciprice.setSeparateRate(BigDecimal.valueOf(normProduction.getSeparateRate())); preciprice.setSeparateRate(BigDecimal.valueOf(normProduction.getSeparateRate()));
preciprice.setQuotaDay(BigDecimal.valueOf(normProduction.getQuotaDay())); preciprice.setQuotaDay(BigDecimal.valueOf(normProduction.getQuotaDay()));
if (type == 1) { if (type == 1) {
preciprice.setPreciprice(calculateWorkTimeCoefficient(normProduction, normProduction.getAnalyseRate())); if (isUrgent) {
preciprice.setPreciprice(new BigDecimal(3).subtract(calculateWorkTimeCoefficient(normProduction, normProduction.getAnalyseRate())));
} else {
preciprice.setPreciprice(calculateWorkTimeCoefficient(normProduction, normProduction.getAnalyseRate()));
}
} else { } else {
preciprice.setPreciprice(calculateWorkTimeCoefficient(normProduction, normProduction.getAnalyseRate())); if (isUrgent) {
preciprice.setPreciprice(new BigDecimal(3).subtract(calculateWorkTimeCoefficient(normProduction, normProduction.getAnalyseRate())));
} else {
preciprice.setPreciprice(calculateWorkTimeCoefficient(normProduction, normProduction.getAnalyseRate()));
}
} }
//获取用户职位和账号 //获取用户职位和账号
SysUser sysUser = iSysUserService.getById(userId); SysUser sysUser = iSysUserService.getById(userId);
...@@ -325,6 +329,7 @@ public class PrecipriceServiceImpl extends ServiceImpl<PrecipriceMapper, Precipr ...@@ -325,6 +329,7 @@ public class PrecipriceServiceImpl extends ServiceImpl<PrecipriceMapper, Precipr
qw.like("user_id", userId); qw.like("user_id", userId);
} }
qw.eq("status", 1); qw.eq("status", 1);
qw.orderByDesc("create_time");
List<Preciprice> list = this.list(qw); List<Preciprice> list = this.list(qw);
List<NormProduction.NormProductionDetail> rts = new ArrayList<>(list.size()); List<NormProduction.NormProductionDetail> rts = new ArrayList<>(list.size());
for (Preciprice preciprice : list) { for (Preciprice preciprice : list) {
...@@ -347,7 +352,7 @@ public class PrecipriceServiceImpl extends ServiceImpl<PrecipriceMapper, Precipr ...@@ -347,7 +352,7 @@ public class PrecipriceServiceImpl extends ServiceImpl<PrecipriceMapper, Precipr
} }
//非标准产值 //非标准产值
List<NonStandardValue> nonStandardValues = iNonStandardValueService.nonValue(startDate, endDate, groupId,name).getData(); List<NonStandardValue> nonStandardValues = iNonStandardValueService.nonValue(startDate, endDate, groupId, name).getData();
//标准产值 //标准产值
List<NormProductionStatistics> productionStatistics = this.normProductionStatistics(start, end, name, groupId).getData(); List<NormProductionStatistics> productionStatistics = this.normProductionStatistics(start, end, name, groupId).getData();
//以userId找关系 //以userId找关系
...@@ -588,12 +593,12 @@ public class PrecipriceServiceImpl extends ServiceImpl<PrecipriceMapper, Precipr ...@@ -588,12 +593,12 @@ public class PrecipriceServiceImpl extends ServiceImpl<PrecipriceMapper, Precipr
@Override @Override
public boolean updateStatusByEntrustId(Integer entrustId) { public boolean updateStatusByEntrustId(Integer entrustId) {
cn.hutool.core.lang.Assert.notNull(entrustId,"报告id不能为空!"); cn.hutool.core.lang.Assert.notNull(entrustId, "报告id不能为空!");
try { try {
precipriceMapper.updateStatusByEntrustId(entrustId); precipriceMapper.updateStatusByEntrustId(entrustId);
return true; return true;
}catch (Exception e){ } catch (Exception e) {
log.error("更新产值状态失败!"); log.error("更新产值状态失败!");
return false; return false;
} }
......
package cn.wise.sc.cement.business.service.impl; package cn.wise.sc.cement.business.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import cn.wise.sc.cement.business.entity.*; import cn.wise.sc.cement.business.entity.*;
import cn.wise.sc.cement.business.mapper.EntityEnclosureMapper; import cn.wise.sc.cement.business.mapper.EntityEnclosureMapper;
import cn.wise.sc.cement.business.mapper.StandardEnterMapper; import cn.wise.sc.cement.business.mapper.StandardEnterMapper;
...@@ -11,6 +13,7 @@ import cn.wise.sc.cement.business.model.PageQuery; ...@@ -11,6 +13,7 @@ import cn.wise.sc.cement.business.model.PageQuery;
import cn.wise.sc.cement.business.model.query.*; import cn.wise.sc.cement.business.model.query.*;
import cn.wise.sc.cement.business.model.vo.StandardValueVo; import cn.wise.sc.cement.business.model.vo.StandardValueVo;
import cn.wise.sc.cement.business.model.vo.StandardVo; import cn.wise.sc.cement.business.model.vo.StandardVo;
import cn.wise.sc.cement.business.service.ISampleCheckService;
import cn.wise.sc.cement.business.service.IStandardService; import cn.wise.sc.cement.business.service.IStandardService;
import cn.wise.sc.cement.business.service.IStandardValueService; import cn.wise.sc.cement.business.service.IStandardValueService;
import cn.wise.sc.cement.business.service.ISysUserService; import cn.wise.sc.cement.business.service.ISysUserService;
...@@ -27,8 +30,11 @@ import org.springframework.beans.BeanUtils; ...@@ -27,8 +30,11 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
...@@ -36,6 +42,8 @@ import java.util.HashSet; ...@@ -36,6 +42,8 @@ import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.function.BiFunction;
import java.util.stream.Collectors;
/** /**
* <p> * <p>
...@@ -60,6 +68,8 @@ public class StandardServiceImpl extends ServiceImpl<StandardMapper, Standard> i ...@@ -60,6 +68,8 @@ public class StandardServiceImpl extends ServiceImpl<StandardMapper, Standard> i
private IStandardValueService standardValueService; private IStandardValueService standardValueService;
@Autowired @Autowired
private CommonServiceImpl commonService; private CommonServiceImpl commonService;
@Autowired
private ISampleCheckService iSampleCheckService;
/** /**
* 分页查询 * 分页查询
...@@ -412,18 +422,22 @@ public class StandardServiceImpl extends ServiceImpl<StandardMapper, Standard> i ...@@ -412,18 +422,22 @@ public class StandardServiceImpl extends ServiceImpl<StandardMapper, Standard> i
} }
@Override @Override
public List<GroupStandard> getStandards() { public List<GroupStandard> getStandards(String name) {
//获取标样信息
List<StandardGroupDto> list = standardMapper.getStandardsByGroup(); List<StandardGroupDto> list = standardMapper.getStandardsByGroup();
List<GroupStandard> rts = new ArrayList<>(list.size()); List<GroupStandard> rts = new ArrayList<>(list.size());
Set<Integer> standardIds = new HashSet<>(); Set<Integer> standardIds = new HashSet<>();
for (StandardGroupDto tmp : list) { for (StandardGroupDto tmp : list) {
//将每个标准值根据GroupId(样品id)分组
if (!standardIds.contains(tmp.getGroupId())) { if (!standardIds.contains(tmp.getGroupId())) {
standardIds.add(tmp.getGroupId()); standardIds.add(tmp.getGroupId());
//样品标样Vo
GroupStandard groupStandard = new GroupStandard(); GroupStandard groupStandard = new GroupStandard();
groupStandard.setGroupName(tmp.getGroupName()); groupStandard.setGroupName(tmp.getGroupName());
Map<String, String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
List<KeyValueMap> keyValueMaps = ObjUtils.str2Obj(tmp.getElementValue()); List<KeyValueMap> keyValueMaps = ObjUtils.str2Obj(tmp.getElementValue());
//将标样元素添加进样品标样
keyValueMaps keyValueMaps
.stream() .stream()
.filter(arg -> "标准值".equals(arg.getName())) .filter(arg -> "标准值".equals(arg.getName()))
...@@ -450,7 +464,74 @@ public class StandardServiceImpl extends ServiceImpl<StandardMapper, Standard> i ...@@ -450,7 +464,74 @@ public class StandardServiceImpl extends ServiceImpl<StandardMapper, Standard> i
} }
} }
//获取历史样品信息
List<SampleCheck> sampleChecks = iSampleCheckService.list();
if (CollectionUtil.isEmpty(sampleChecks)) {
return rts;
}
Set<String> cementCodes = sampleChecks.stream()
.map(SampleCheck::getCementCode).collect(Collectors.toSet());
//根据cementCodes和team_group_id计算多个平行样的平均值
for (String cementCode : cementCodes) {
List<SampleCheck> collect = sampleChecks
.stream()
.filter(arg -> arg.getCementCode().equals(cementCode)).collect(Collectors.toList());
if (CollectionUtil.isEmpty(collect)) {
continue;
}
Set<Integer> groupIds = collect.stream()
.map(SampleCheck::getTeamGroupId).collect(Collectors.toSet());
//根据groupI处理team检测值
for (Integer groupId : groupIds) {
List<SampleCheck> checkGroups = collect.stream()
.filter(arg -> arg.getTeamGroupId().intValue() == groupId)
.collect(Collectors.toList());
if (CollectionUtil.isEmpty(checkGroups)) {
continue;
}
//将每个元素组的所有元素的标准值累加
Map<String, BigDecimal> elementMap = new HashMap<>();
checkGroups.forEach(arg -> {
List<KeyValueMap> keyValueMaps = ObjUtils.str2Obj(arg.getCountResults());
//将样品的输入值添加到map中
keyValueMaps
.forEach(opt -> {
if (elementMap.containsKey(opt.getName())) {
elementMap.get(opt.getName()).add(new BigDecimal(StrUtil.isEmpty(opt.getValue()) ? "0" : opt.getValue()));
} else {
elementMap.put(opt.getName(), new BigDecimal(StrUtil.isEmpty(opt.getValue()) ? "0" : opt.getValue()));
}
});
});
//求平均
GroupStandard groupStandard = new GroupStandard();
Map<String, String> map = new HashMap<>();
groupStandard.setMap(map);
groupStandard.setCementCode(cementCode);
groupStandard.setGroupName(checkGroups.get(0).getTeamGroupName() + "|" + cementCode);
if (CollectionUtil.isEmpty(elementMap)) {
continue;
}
elementMap.keySet().forEach(opt -> {
BigDecimal avg = elementMap.get(opt)
.divide(new BigDecimal(checkGroups.size()))
.setScale(2, RoundingMode.HALF_DOWN);
map.put(opt, avg.toString());
});
rts.add(groupStandard);
}
}
if (!StrUtil.isEmpty(name)) {
return rts.stream()
.filter(opt -> opt.getGroupName().contains(name) || name.equals(opt.getCementCode()))
.collect(Collectors.toList());
}
return rts; return rts;
} }
public static void main(String[] args) {
BigDecimal bigDecimal = new BigDecimal(111);
System.out.println(bigDecimal.toString());
}
} }
...@@ -16,6 +16,7 @@ import org.apache.poi.ss.usermodel.Font; ...@@ -16,6 +16,7 @@ import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.ss.usermodel.HorizontalAlignment; import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.VerticalAlignment;
import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.Workbook;
/** /**
...@@ -113,7 +114,42 @@ public class ExcelUtil { ...@@ -113,7 +114,42 @@ public class ExcelUtil {
} }
} }
} }
public static void excelExportNew(String fileName, String[] headers, List<Object[]> datas,
HttpServletResponse response) {
Workbook workbook = getWorkbookNew(headers, datas);
if (workbook != null) {
ByteArrayOutputStream byteArrayOutputStream = null;
try {
byteArrayOutputStream = new ByteArrayOutputStream();
workbook.write(byteArrayOutputStream);
String suffix = ".xls";
response.setContentType("application/vnd.ms-excel;charset=utf-8");
response.setHeader("Content-Disposition",
"attachment;filename=" + new String((fileName + suffix).getBytes(), "iso-8859-1"));
OutputStream outputStream = response.getOutputStream();
outputStream.write(byteArrayOutputStream.toByteArray());
outputStream.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (byteArrayOutputStream != null) {
byteArrayOutputStream.close();
}
} catch (IOException e) {
e.printStackTrace();
}
try {
workbook.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
/** /**
* @param headers 列头 * @param headers 列头
* @param datas 数据 * @param datas 数据
...@@ -176,4 +212,65 @@ public class ExcelUtil { ...@@ -176,4 +212,65 @@ public class ExcelUtil {
return workbook; return workbook;
} }
public static Workbook getWorkbookNew(String[] headers, List<Object[]> datas) {
Workbook workbook = new HSSFWorkbook();
Sheet sheet = workbook.createSheet();
workbook.setSheetName(0,"样品处置记录");
Row row = null;
Cell cell = null;
Font font = workbook.createFont();
int line = 0, maxColumn = 0;
if (headers != null && headers.length > 0) { // 设置列头
CellStyle style = workbook.createCellStyle();
style.setAlignment(HorizontalAlignment.CENTER_SELECTION);
style.setVerticalAlignment(VerticalAlignment.CENTER);
row = sheet.createRow(line++);
row.setHeightInPoints(23);
font.setFontHeightInPoints((short) 12);
font.setFontName("宋体");
style.setFont(font);
maxColumn = headers.length;
for (int i = 0; i < maxColumn; i++) {
cell = row.createCell(i);
cell.setCellValue(headers[i]);
cell.setCellStyle(style);
}
}
if (datas != null && datas.size() > 0) {// 渲染数据
CellStyle style = workbook.createCellStyle();
for (int index = 0, size = datas.size(); index < size; index++) {
Object[] data = datas.get(index);
if (data != null && data.length > 0) {
row = sheet.createRow(line++);
row.setHeightInPoints(20);
int length = data.length;
if (length > maxColumn) {
maxColumn = length;
}
for (int i = 0; i < length; i++) {
style.setWrapText(true); //关键
style.setFont(font);
cell = row.createCell(i);
cell.setCellValue(data[i] == null ? null : data[i].toString());
cell.setCellStyle(style);
style.setAlignment(HorizontalAlignment.CENTER_SELECTION);
}
}
}
}
for (int i = 0; i < maxColumn; i++) {
sheet.autoSizeColumn(i);
}
return workbook;
}
} }
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