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

元素含量分布统计

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