Commit 744be23d authored by 竹天卫's avatar 竹天卫

元素含量分布统计

parent c0b44c16
...@@ -35,8 +35,7 @@ public class DataStatisticsController { ...@@ -35,8 +35,7 @@ public class DataStatisticsController {
@Autowired @Autowired
private IDataStatisticsService dataStatisticsService; private IDataStatisticsService dataStatisticsService;
@Autowired
private IEntrustService entrustService;
@ApiOperation(value = "统计概览-重要数值统计") @ApiOperation(value = "统计概览-重要数值统计")
...@@ -110,7 +109,7 @@ public class DataStatisticsController { ...@@ -110,7 +109,7 @@ public class DataStatisticsController {
return BaseResponse.errorMsg("失败!"); return BaseResponse.errorMsg("失败!");
} }
@ApiOperation("列表导出-委托单进展统计") @ApiOperation("导出-委托单进展统计")
@PostMapping("/exportEntrustList") @PostMapping("/exportEntrustList")
public void exportEntrustList(Integer cycle, String startDate, public void exportEntrustList(Integer cycle, String startDate,
String endDate, Integer clientId, String clientName, String fileName, HttpServletResponse response) { String endDate, Integer clientId, String clientName, String fileName, HttpServletResponse response) {
...@@ -170,7 +169,7 @@ public class DataStatisticsController { ...@@ -170,7 +169,7 @@ public class DataStatisticsController {
} }
@ApiOperation("列表导出-检测项统计") @ApiOperation("导出-检测项统计")
@PostMapping("/exportTeamList") @PostMapping("/exportTeamList")
public void exportTeamList(Integer cycle, String startDate, String endDate, String fileName, HttpServletResponse response) { public void exportTeamList(Integer cycle, String startDate, String endDate, String fileName, HttpServletResponse response) {
try { try {
...@@ -202,7 +201,7 @@ public class DataStatisticsController { ...@@ -202,7 +201,7 @@ public class DataStatisticsController {
} }
@ApiOperation("列表导出-检测元素含量分布情况统计") @ApiOperation("导出-检测元素含量分布情况统计")
@PostMapping("/exportItemDistribution") @PostMapping("/exportItemDistribution")
public void exportItemDistribution(@RequestBody CountItemDistributionQuery query, String fileName, HttpServletResponse response) { public void exportItemDistribution(@RequestBody CountItemDistributionQuery query, String fileName, HttpServletResponse response) {
try { try {
......
...@@ -9,6 +9,7 @@ import lombok.Data; ...@@ -9,6 +9,7 @@ import lombok.Data;
**/ **/
@Data @Data
public class ItemDistribution { public class ItemDistribution {
private Integer count; private String maxCount;
private String minCount;
private String key; private String key;
} }
...@@ -457,7 +457,8 @@ ...@@ -457,7 +457,8 @@
SELECT COUNT(sd.team_id) as `count`,t.`name` FROM sample_distribution sd SELECT COUNT(sd.team_id) as `count`,t.`name` FROM sample_distribution sd
LEFT JOIN sample s ON sd.sample_id = s.id LEFT JOIN sample s ON sd.sample_id = s.id
LEFT JOIN team t ON t.id = sd.team_id LEFT JOIN team t ON t.id = sd.team_id
WHERE 1=1 WHERE s.is_check = 1 and s.cement_code = s.parallel_code
and sd.status = 4 and sd.check_id is not null
<if test="start != null and end != null"> <if test="start != null and end != null">
AND (sd.finish_time between #{start} and #{end}) AND (sd.finish_time between #{start} and #{end})
</if> </if>
...@@ -470,12 +471,19 @@ ...@@ -470,12 +471,19 @@
</select> </select>
<select id="countItemDistribution" resultType="cn.wise.sc.cement.business.entity.ItemDistribution"> <select id="countItemDistribution" resultType="cn.wise.sc.cement.business.entity.ItemDistribution">
SELECT COUNT(a.sample_id) as `count`,`key` from SELECT
(SELECT sd.team_id,sd.sample_id,t.`name`,sd.finish_time,CONCAT(sd.team_id,',',s.origin,',',s.is_foreign) as IF(LENGTH(TRIM(MAX(a.last_result))) &lt; 1 ,0, MAX(a.last_result)) as maxCount,
`key` FROM sample_distribution sd IF(LENGTH(TRIM(MIN(a.last_result))) &lt; 1 ,0, MIN(a.last_result) ) as minCount,
`key`
from(
SELECT sd.team_id,t.`name`,sdc.last_result,
CONCAT(sd.team_id,',',s.origin,',',s.is_foreign) as `key`
FROM sample_distribution sd
left join sample_distribution_check sdc on sdc.id = sd.check_id
LEFT JOIN sample s ON sd.sample_id = s.id LEFT JOIN sample s ON sd.sample_id = s.id
LEFT JOIN team t ON t.id = sd.team_id LEFT JOIN team t ON t.id = sd.team_id
WHERE 1=1 WHERE s.is_check = 1 and s.cement_code = s.parallel_code
and sd.status = 4 and sd.check_id is not null
<if test="start != null and end != null"> <if test="start != null and end != null">
AND (sd.finish_time between #{start} and #{end}) AND (sd.finish_time between #{start} and #{end})
</if> </if>
...@@ -488,20 +496,25 @@ ...@@ -488,20 +496,25 @@
<if test="itemId != null"> <if test="itemId != null">
AND sd.team_id = #{itemId} AND sd.team_id = #{itemId}
</if> </if>
) a GROUP BY a.`key` ) a
GROUP BY a.`key`
</select> </select>
<select id="exporItemDistributionList" resultType="java.util.HashMap"> <select id="exporItemDistributionList" resultType="java.util.HashMap">
SELECT (@i:=@i+1) as 序号, SELECT (@i:=@i+1) as 序号,
COUNT(a.sample_id) as `count`, IF(LENGTH(TRIM(MAX(a.last_result))) &lt; 1 ,0, MAX(a.last_result)) as maxCount,
IF(LENGTH(TRIM(MIN(a.last_result))) &lt; 1 ,0, MIN(a.last_result) ) as minCount,
`key` `key`
from from
(SELECT sd.team_id,sd.sample_id,t.`name`,sd.finish_time,CONCAT(sd.team_id,',',s.origin,',',s.is_foreign) as (SELECT sd.team_id,t.`name`,sdc.last_result,
`key` FROM sample_distribution sd CONCAT(sd.team_id,',',s.origin,',',s.is_foreign) as `key`
FROM sample_distribution sd
left join sample_distribution_check sdc on sdc.id = sd.check_id
LEFT JOIN sample s ON sd.sample_id = s.id LEFT JOIN sample s ON sd.sample_id = s.id
LEFT JOIN team t ON t.id = sd.team_id LEFT JOIN team t ON t.id = sd.team_id
,(select @i:=0)t ,(select @i:=0)t
WHERE 1=1 WHERE s.is_check = 1 and s.cement_code = s.parallel_code
and sd.status = 4 and sd.check_id is not null
<if test="start != null and end != null"> <if test="start != null and end != null">
AND (sd.finish_time between #{start} and #{end}) AND (sd.finish_time between #{start} and #{end})
</if> </if>
......
...@@ -17,7 +17,9 @@ public class ItemDistributionVo implements Serializable { ...@@ -17,7 +17,9 @@ public class ItemDistributionVo implements Serializable {
private String id; private String id;
private String itemName; private String itemName;
private String origin; private String origin;
private Integer itemCount;
private String time;
private Integer sampleCount; private Integer sampleCount;
private String maxCount;
private String minCount;
} }
...@@ -820,7 +820,9 @@ public class DataStatisticsServiceImpl implements IDataStatisticsService { ...@@ -820,7 +820,9 @@ public class DataStatisticsServiceImpl implements IDataStatisticsService {
String endTime = query.getEndTime(); String endTime = query.getEndTime();
Long itemId = query.getItemId(); Long itemId = query.getItemId();
List<String> origins = query.getOrigins(); List<String> origins = query.getOrigins();
if(query.getPageQuery() == null){
return BaseResponse.errorMsg("请传入分页参数");
}
Page<ItemDistribution> page = new Page<>(query.getPageQuery().getPageNo(), query.getPageQuery().getPageSize()); Page<ItemDistribution> page = new Page<>(query.getPageQuery().getPageNo(), query.getPageQuery().getPageSize());
//获取检测项目城市分布统计 //获取检测项目城市分布统计
...@@ -843,12 +845,8 @@ public class DataStatisticsServiceImpl implements IDataStatisticsService { ...@@ -843,12 +845,8 @@ public class DataStatisticsServiceImpl implements IDataStatisticsService {
vo.setOrigin(origin); vo.setOrigin(origin);
vo.setItemName(sample.getName()); vo.setItemName(sample.getName());
vo.setSampleCount(sample.getCount()); vo.setSampleCount(sample.getCount());
vo.setItemCount(distribution.getCount()); vo.setMaxCount(distribution.getMaxCount());
if(StringUtils.isEmpty(startTime) || StringUtils.isEmpty(endTime)){ vo.setMinCount(distribution.getMinCount());
vo.setTime(null);
}else{
vo.setTime(startTime + "_" + endTime);
}
rtsRecords.add(vo); rtsRecords.add(vo);
} }
...@@ -885,7 +883,7 @@ public class DataStatisticsServiceImpl implements IDataStatisticsService { ...@@ -885,7 +883,7 @@ public class DataStatisticsServiceImpl implements IDataStatisticsService {
headers[0] = "序号"; headers[0] = "序号";
headers[1] = "检测元素"; headers[1] = "检测元素";
headers[2] = "地区"; headers[2] = "地区";
headers[3] = "元素含量"; headers[3] = "元素含量区间";
headers[4] = "样品数量"; headers[4] = "样品数量";
List<Object[]> datas = new ArrayList<>(list.size()); List<Object[]> datas = new ArrayList<>(list.size());
...@@ -905,12 +903,10 @@ public class DataStatisticsServiceImpl implements IDataStatisticsService { ...@@ -905,12 +903,10 @@ public class DataStatisticsServiceImpl implements IDataStatisticsService {
vo.setOrigin(origin); vo.setOrigin(origin);
vo.setItemName(sample.getName()); vo.setItemName(sample.getName());
vo.setSampleCount(sample.getCount()); vo.setSampleCount(sample.getCount());
vo.setItemCount(Integer.valueOf(m.get("count").toString())); vo.setMaxCount(m.get("maxCount").toString());
if(StringUtils.isEmpty(startTime) || StringUtils.isEmpty(endTime)){ vo.setMinCount(m.get("minCount").toString());
vo.setTime(null);
}else{
vo.setTime(startTime + "_" + endTime);
}
for (int j = 0; j < headers.length; j++) { for (int j = 0; j < headers.length; j++) {
String obj = ""; String obj = "";
if(j == 1){ if(j == 1){
...@@ -918,7 +914,7 @@ public class DataStatisticsServiceImpl implements IDataStatisticsService { ...@@ -918,7 +914,7 @@ public class DataStatisticsServiceImpl implements IDataStatisticsService {
}else if(j == 2){ }else if(j == 2){
objects[2] = vo.getOrigin(); objects[2] = vo.getOrigin();
}else if(j == 3){ }else if(j == 3){
objects[3] = vo.getItemCount(); objects[3] = vo.getMinCount()+"-"+vo.getMaxCount();
}else if(j == 4){ }else if(j == 4){
objects[4] = vo.getSampleCount(); objects[4] = vo.getSampleCount();
}else{ }else{
......
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