Commit 0e362a24 authored by 竹天卫's avatar 竹天卫

统计功能完成

parent d9b7542f
...@@ -106,9 +106,6 @@ public class DataStatisticsController { ...@@ -106,9 +106,6 @@ public class DataStatisticsController {
//todo 委托单进展统计-列表导出 //todo 委托单进展统计-列表导出
@ApiOperation(value = "统计概览-进行中任务数量统计") @ApiOperation(value = "统计概览-进行中任务数量统计")
@GetMapping("/countTaskIng") @GetMapping("/countTaskIng")
public BaseResponse countTaskIng(PageQuery pageQuery) { public BaseResponse countTaskIng(PageQuery pageQuery) {
...@@ -133,30 +130,47 @@ public class DataStatisticsController { ...@@ -133,30 +130,47 @@ public class DataStatisticsController {
} }
@ApiOperation(value = "检测项数量统计-检测项数量统计") @ApiOperation(value = "检测项统计-检测项数量统计")
@GetMapping("/countTeamDetail") @GetMapping("/countTeamDetail")
public BaseResponse countTeamDetail(Integer cycle, String startDate, String endDate) { public BaseResponse countTeamDetail(Integer cycle, String startDate, String endDate) {
try { try {
return dataStatisticsService.countTeamDetail(cycle, startDate, endDate); return dataStatisticsService.countTeamDetail(cycle, startDate, endDate);
} catch (Exception e) { } catch (Exception e) {
log.debug("检测项数量统计-检测项数量统计{}", e); log.debug("检测项统计-检测项数量统计{}", e);
} }
return BaseResponse.errorMsg("失败!"); return BaseResponse.errorMsg("失败!");
} }
@ApiOperation(value = "检测项数量统计-列表") @ApiOperation(value = "检测项统计-分页列表")
@GetMapping("/countTeamList") @GetMapping("/countTeamList")
public BaseResponse countTeamList() { public BaseResponse countTeamList(PageQuery pageQuery, Integer cycle, String startDate, String endDate) {
try {
return dataStatisticsService.countTeamList(pageQuery, cycle, startDate, endDate);
} catch (Exception e) {
log.debug("检测项统计-列表{}", e);
}
return BaseResponse.errorMsg("失败!");
}
//todo 检测项"检测项统计-列表导出
@ApiOperation(value = "各委托单位项目数量统计")
@GetMapping("/countByClient")
public BaseResponse countByClient() {
try { try {
return dataStatisticsService.countTeamList(); return dataStatisticsService.countByClient();
} catch (Exception e) { } catch (Exception e) {
log.debug("检测项数量统计-列表{}", e); log.debug("各委托单位项目数量统计{}", e);
} }
return BaseResponse.errorMsg("失败!"); return BaseResponse.errorMsg("失败!");
} }
@ApiOperation("检测项分布统计")
@ApiOperation("检测元素含量分布情况统计")
@PostMapping("/item/download") @PostMapping("/item/download")
public BaseResponse<Page<ItemDistributionVo>> downloadItemDistribution(@RequestBody CountItemDistributionQuery query, public BaseResponse<Page<ItemDistributionVo>> downloadItemDistribution(@RequestBody CountItemDistributionQuery query,
HttpServletResponse response) { HttpServletResponse response) {
...@@ -164,5 +178,7 @@ public class DataStatisticsController { ...@@ -164,5 +178,7 @@ public class DataStatisticsController {
} }
} }
...@@ -113,7 +113,7 @@ public class NormProductionController { ...@@ -113,7 +113,7 @@ public class NormProductionController {
@GetMapping("/statistics") @GetMapping("/statistics")
@ApiOperation("标准产值统计") @ApiOperation("标准产值统计-分页")
public BaseResponse<Page<NormProductionStatistics>> normProductionStatistics(String start, String end, String name, Integer groupId, PageQuery pageQuery) { public BaseResponse<Page<NormProductionStatistics>> normProductionStatistics(String start, String end, String name, Integer groupId, PageQuery pageQuery) {
Long startTime = null; Long startTime = null;
...@@ -137,6 +137,27 @@ public class NormProductionController { ...@@ -137,6 +137,27 @@ public class NormProductionController {
return BaseResponse.okData(new Page<>()); return BaseResponse.okData(new Page<>());
} }
@GetMapping("/statisticsList")
@ApiOperation("标准产值统计-列表")
public BaseResponse<List<NormProductionStatistics>> normProductionStatisticsList(String start, String end, String name, Integer groupId) {
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();
}
//将list拆分成分页
BaseResponse<List<NormProductionStatistics>> baseResponse = iPrecipriceService
.normProductionStatistics(startTime, endTime, name, groupId);
return baseResponse;
}
@GetMapping("/statistics/detail") @GetMapping("/statistics/detail")
@ApiOperation("标准产值详情") @ApiOperation("标准产值详情")
public BaseResponse<Page<NormProduction.NormProductionDetail>> normProductionDetails(Integer userId, String start, public BaseResponse<Page<NormProduction.NormProductionDetail>> normProductionDetails(Integer userId, String start,
......
...@@ -34,7 +34,7 @@ public interface DataStatisticsMapper { ...@@ -34,7 +34,7 @@ public interface DataStatisticsMapper {
List<DataStatisticsVo> countEntrustType(@Param("params") Map<String, Object> params); List<DataStatisticsVo> countEntrustType(@Param("params") Map<String, Object> params);
IPage<EntrustVo> countEntrustPage(@Param("page") Page page); IPage<EntrustVo> countEntrustPage(@Param("page") Page page, @Param("params") Map<String, Object> params);
IPage<DataStatisticsVo> countHandlePage(@Param("page") Page page); IPage<DataStatisticsVo> countHandlePage(@Param("page") Page page);
...@@ -48,14 +48,25 @@ public interface DataStatisticsMapper { ...@@ -48,14 +48,25 @@ public interface DataStatisticsMapper {
List<DataStatisticsVo> countTeam(@Param("params") Map<String, Object> params); List<DataStatisticsVo> countTeam(@Param("params") Map<String, Object> params);
List<DataStatisticsTeamVo> countTeamList(); IPage<DataStatisticsTeamVo> countTeamPage(@Param("page") Page page, @Param("params") Map<String, Object> params);
Integer countEntrustNum(@Param("teamId") Integer teamId);
Integer countSampleNum(@Param("teamId") Integer teamId);
List<DataStatisticsVo> countByClient();
IPage<ItemDistribution> countItemDistribution(@Param("page") Page<ItemDistribution> page, IPage<ItemDistribution> countItemDistribution(@Param("page") Page<ItemDistribution> page,
@Param("start") Date startTime, @Param("start") String startTime,
@Param("end") Date endTime, @Param("end") String endTime,
@Param("origins") List<String> origins, @Param("origins") List<String> origins,
@Param("itemId") Long itemId); @Param("itemId") Long itemId);
ItemDistributionSample countItemDistributionSample(@Param("start") Date startTime, @Param("end") Date endTime, ItemDistributionSample countItemDistributionSample(@Param("start") String startTime, @Param("end") String endTime,
@Param("origin") String origin, @Param("teamId") Long teamId); @Param("origin") String origin, @Param("teamId") Long teamId);
} }
...@@ -43,8 +43,8 @@ ...@@ -43,8 +43,8 @@
<if test="params.cycle == 3 "> <if test="params.cycle == 3 ">
and YEAR(sd.create_time) = YEAR( NOW( ) ) and YEAR(sd.create_time) = YEAR( NOW( ) )
</if> </if>
<if test="params.endDate != null and params.endDate != ''"> <if test="params.startDate != null and params.startDate != ''">
and DATE(sd.create_time) &lt;= #{params.endDate} and DATE(sd.create_time) &gt;= #{params.startDate}
</if> </if>
<if test="params.endDate != null and params.endDate != ''"> <if test="params.endDate != null and params.endDate != ''">
and DATE(sd.create_time) &lt;= #{params.endDate} and DATE(sd.create_time) &lt;= #{params.endDate}
...@@ -81,8 +81,8 @@ ...@@ -81,8 +81,8 @@
<if test="params.cycle == 3 "> <if test="params.cycle == 3 ">
and YEAR(e.create_time) = YEAR( NOW( ) ) and YEAR(e.create_time) = YEAR( NOW( ) )
</if> </if>
<if test="params.endDate != null and params.endDate != ''"> <if test="params.startDate != null and params.startDate != ''">
and DATE(e.create_time) &lt;= #{params.endDate} and DATE(e.create_time) &gt;= #{params.startDate}
</if> </if>
<if test="params.endDate != null and params.endDate != ''"> <if test="params.endDate != null and params.endDate != ''">
and DATE(e.create_time) &lt;= #{params.endDate} and DATE(e.create_time) &lt;= #{params.endDate}
...@@ -91,7 +91,7 @@ ...@@ -91,7 +91,7 @@
</select> </select>
<select id="countEntrustType" resultType="cn.wise.sc.cement.business.model.vo.DataStatisticsVo"> <select id="countEntrustType" resultType="cn.wise.sc.cement.business.model.vo.DataStatisticsVo">
select e.project_type, count(*) select e.project_type as name, count(*) as value
from entrust e from entrust e
where e.status != 0 and e.project_type is not null where e.status != 0 and e.project_type is not null
<if test="params.cycle == 1 "> <if test="params.cycle == 1 ">
...@@ -103,8 +103,8 @@ ...@@ -103,8 +103,8 @@
<if test="params.cycle == 3 "> <if test="params.cycle == 3 ">
and YEAR(e.create_time) = YEAR( NOW( ) ) and YEAR(e.create_time) = YEAR( NOW( ) )
</if> </if>
<if test="params.endDate != null and params.endDate != ''"> <if test="params.startDate != null and params.startDate != ''">
and DATE(e.create_time) &lt;= #{params.endDate} and DATE(e.create_time) &gt;= #{params.startDate}
</if> </if>
<if test="params.endDate != null and params.endDate != ''"> <if test="params.endDate != null and params.endDate != ''">
and DATE(e.create_time) &lt;= #{params.endDate} and DATE(e.create_time) &lt;= #{params.endDate}
...@@ -136,6 +136,12 @@ ...@@ -136,6 +136,12 @@
<if test="params.clientName != null and params.clientName != ''"> <if test="params.clientName != null and params.clientName != ''">
and c.name like concat('%', #{params.clientName}, '%') and c.name like concat('%', #{params.clientName}, '%')
</if> </if>
<if test="params.startDate != null and params.startDate != ''">
and DATE(e.create_time) &gt;= #{params.startDate}
</if>
<if test="params.endDate != null and params.endDate != ''">
and DATE(e.create_time) &lt;= #{params.endDate}
</if>
order by create_time desc order by create_time desc
</select> </select>
...@@ -212,25 +218,68 @@ ...@@ -212,25 +218,68 @@
<if test="params.cycle == 3 "> <if test="params.cycle == 3 ">
and YEAR(sd.create_time) = YEAR( NOW( ) ) and YEAR(sd.create_time) = YEAR( NOW( ) )
</if> </if>
<if test="params.startDate != null and params.startDate != ''">
and DATE(sd.create_time) &gt;= #{params.startDate}
</if>
<if test="params.endDate != null and params.endDate != ''"> <if test="params.endDate != null and params.endDate != ''">
and DATE(sd.create_time) &lt;= #{params.endDate} and DATE(sd.create_time) &lt;= #{params.endDate}
</if> </if>
group by sd.team_id
</select>
<select id="countTeamPage" resultType="cn.wise.sc.cement.business.model.vo.DataStatisticsTeamVo">
SELECT t.id as id, t.name as teamName, count(*) as teamNum FROM sample_distribution sd
left join team t on t.id = sd.team_id
where 1=1
<if test="params.cycle == 1 ">
and YEARWEEK(date_format(sd.create_time,'%Y-%m-%d' ) ) = YEARWEEK(now())
</if>
<if test="params.cycle == 2 ">
and DATE_FORMAT( sd.create_time, '%Y%m' ) = DATE_FORMAT( CURDATE( ) ,'%Y%m')
</if>
<if test="params.cycle == 3 ">
and YEAR(sd.create_time) = YEAR( NOW( ) )
</if>
<if test="params.startDate != null and params.startDate != ''">
and DATE(sd.create_time) &gt;= #{params.startDate}
</if>
<if test="params.endDate != null and params.endDate != ''"> <if test="params.endDate != null and params.endDate != ''">
and DATE(sd.create_time) &lt;= #{params.endDate} and DATE(sd.create_time) &lt;= #{params.endDate}
</if> </if>
group by sd.team_id group by sd.team_id
</select> </select>
<select id="countTeamList" resultType="cn.wise.sc.cement.business.model.vo.DataStatisticsTeamVo"> <select id="countEntrustNum" resultType="integer">
SELECT DISTINCT t.name as teamName, e.project_code as projectCode, select count(*) as entrustNum from (
e.entrust_code as entrustCode, e.entrust_date as entrustDate, SELECT sd.entrust_id as id, count(*) as entrustNum FROM sample_distribution sd
e.sample_num as sampleNum where sd.team_id = #{teamId}
FROM sample_distribution sd group by sd.entrust_id
left join sample s on s.id = sd.sample_id )aa
left join entrust e on e.id = s.entrust_id
left join team t on t.id = sd.team_id
</select> </select>
<select id="countSampleNum" resultType="integer">
select count(*) as sampleNum from (
SELECT sd.sample_id as id, count(*) as entrustNum FROM sample_distribution sd
where sd.team_id = #{teamId}
group by sd.sample_id
)aa
</select>
<select id="countByClient" resultType="cn.wise.sc.cement.business.model.vo.DataStatisticsVo">
select c.name as name, count(*) as value from entrust e
left join client c on c.id = e.client_id
group by e.client_id
</select>
...@@ -242,8 +291,10 @@ ...@@ -242,8 +291,10 @@
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 WHERE 1=1
sd.finish_time BETWEEN #{start} AND #{end} <if test="start != null and end != null">
AND (sd.finish_time between #{start} and #{end})
</if>
<if test="origin != null and origin != '' "> <if test="origin != null and origin != '' ">
AND s.origin = #{origin} AND s.origin = #{origin}
</if> </if>
...@@ -258,7 +309,10 @@ ...@@ -258,7 +309,10 @@
`key` FROM sample_distribution sd `key` 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 (sd.finish_time between #{start} and #{end}) WHERE 1=1
<if test="start != null and end != null">
AND (sd.finish_time between #{start} and #{end})
</if>
<if test="origins != null and origins.size()>0"> <if test="origins != null and origins.size()>0">
AND s.origin in AND s.origin in
<foreach collection="origins" item="item" open="(" separator="," close=")"> <foreach collection="origins" item="item" open="(" separator="," close=")">
......
...@@ -438,7 +438,7 @@ ...@@ -438,7 +438,7 @@
<select id="getSampleReturnCheckPage" resultType="cn.wise.sc.cement.business.model.vo.EntrustVo"> <select id="getSampleReturnCheckPage" resultType="cn.wise.sc.cement.business.model.vo.EntrustVo">
select e.id as id, e.entrust_code as entrustCode, e.sample_num as sampleNum,e.entrust_date as entrustDate, select DISTINCT e.id as id, e.entrust_code as entrustCode, e.sample_num as sampleNum,e.entrust_date as entrustDate,
e.project_type as projectType, t.remark as opinion, e.project_type as projectType, t.remark as opinion,
e.status, e.status,
( (
......
package cn.wise.sc.cement.business.model.query; package cn.wise.sc.cement.business.model.query;
import cn.wise.sc.cement.business.model.PageQuery; import cn.wise.sc.cement.business.model.PageQuery;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.time.Period; import java.time.Period;
...@@ -13,10 +14,18 @@ import java.util.List; ...@@ -13,10 +14,18 @@ import java.util.List;
**/ **/
@Data @Data
public class CountItemDistributionQuery { public class CountItemDistributionQuery {
@ApiModelProperty("检测元素(单选)")
private Long itemId; private Long itemId;
@ApiModelProperty("地区(多选)")
private List<String> origins; private List<String> origins;
@ApiModelProperty("开始日期 2021-02-22")
private String startTime; private String startTime;
@ApiModelProperty("结束日期 2021-02-22")
private String endTime; private String endTime;
private String type;
@ApiModelProperty("分页参数")
private PageQuery pageQuery; private PageQuery pageQuery;
} }
...@@ -15,21 +15,20 @@ import java.time.LocalDate; ...@@ -15,21 +15,20 @@ import java.time.LocalDate;
@ApiModel("数据统计-检测项数量统计列表") @ApiModel("数据统计-检测项数量统计列表")
public class DataStatisticsTeamVo { public class DataStatisticsTeamVo {
@ApiModelProperty("检测项目")
private String teamName;
@ApiModelProperty("项目编号") @ApiModelProperty("检测项目ID")
private String projectCode; private Integer id;
@ApiModelProperty("委托编号") @ApiModelProperty("检测项目名称")
private String entrustCode; private String teamName;
@ApiModelProperty("委托日期") @ApiModelProperty("检测项数量")
private LocalDate entrustDate; private Integer teamNum;
@ApiModelProperty("样品数量")
private String sampleNum;
@ApiModelProperty("委托数量")
private Integer entrustNum;
@ApiModelProperty("样品数量")
private Integer sampleNum;
} }
...@@ -56,4 +56,9 @@ public class SampleDistributionEnclosureVo { ...@@ -56,4 +56,9 @@ public class SampleDistributionEnclosureVo {
@ApiModelProperty("pdf地址") @ApiModelProperty("pdf地址")
private String pdfUrl; private String pdfUrl;
@ApiModelProperty("是否允许委托人查看 是否公开 (0不公开,1公开)")
private Integer isPublic;
} }
...@@ -61,4 +61,8 @@ public class SampleHandleEnclosureVo { ...@@ -61,4 +61,8 @@ public class SampleHandleEnclosureVo {
@ApiModelProperty("pdf地址") @ApiModelProperty("pdf地址")
private String pdfUrl; private String pdfUrl;
@ApiModelProperty("是否允许委托人查看 是否公开 (0不公开,1公开)")
private Integer isPublic;
} }
...@@ -42,7 +42,9 @@ public interface IDataStatisticsService { ...@@ -42,7 +42,9 @@ public interface IDataStatisticsService {
BaseResponse<List<DataStatisticsVo>> countTeamDetail(Integer cycle, String startDate, String endDate); BaseResponse<List<DataStatisticsVo>> countTeamDetail(Integer cycle, String startDate, String endDate);
BaseResponse<List<DataStatisticsTeamVo>> countTeamList(); BaseResponse<IPage<DataStatisticsTeamVo>> countTeamList(PageQuery pageQuery, Integer cycle, String startDate, String endDate);
BaseResponse<List<DataStatisticsVo>> countByClient();
/** /**
* 导出检查项分布统计 * 导出检查项分布统计
......
...@@ -191,6 +191,12 @@ public class DataStatisticsServiceImpl implements IDataStatisticsService { ...@@ -191,6 +191,12 @@ public class DataStatisticsServiceImpl implements IDataStatisticsService {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
QueryWrapper<Entrust> entrustQw = new QueryWrapper<>(); QueryWrapper<Entrust> entrustQw = new QueryWrapper<>();
if(StringUtils.isNotBlank(startDate)){
entrustQw.ge("create_time",startDate);
}
if(StringUtils.isNotBlank(endDate)){
entrustQw.le("create_time",endDate);
}
Integer sum_counts = entrustService.count(entrustQw); Integer sum_counts = entrustService.count(entrustQw);
if(sum_counts == null){ if(sum_counts == null){
map.put("sumCounts", "0"); map.put("sumCounts", "0");
...@@ -198,7 +204,7 @@ public class DataStatisticsServiceImpl implements IDataStatisticsService { ...@@ -198,7 +204,7 @@ public class DataStatisticsServiceImpl implements IDataStatisticsService {
map.put("typeList", null); map.put("typeList", null);
}else{ }else{
List<DataStatisticsVo> statusList = dataStatisticsMapper.countEntrustStatus(params); List<DataStatisticsVo> statusList = dataStatisticsMapper.countEntrustStatus(params);
List<DataStatisticsVo> typeList = dataStatisticsMapper.countEntrustStatus(params); List<DataStatisticsVo> typeList = dataStatisticsMapper.countEntrustType(params);
map.put("sumCounts", sum_counts); map.put("sumCounts", sum_counts);
map.put("statusList", statusList); map.put("statusList", statusList);
map.put("typeList", typeList); map.put("typeList", typeList);
...@@ -221,7 +227,7 @@ public class DataStatisticsServiceImpl implements IDataStatisticsService { ...@@ -221,7 +227,7 @@ public class DataStatisticsServiceImpl implements IDataStatisticsService {
params.put("endDate", endDate); params.put("endDate", endDate);
params.put("clientName", clientName); params.put("clientName", clientName);
Page<EntrustVo> page = new Page<>(pageQuery.getPageNo(), pageQuery.getPageSize()); Page<EntrustVo> page = new Page<>(pageQuery.getPageNo(), pageQuery.getPageSize());
IPage<EntrustVo> pages = dataStatisticsMapper.countEntrustPage(page); IPage<EntrustVo> pages = dataStatisticsMapper.countEntrustPage(page, params);
List<EntrustVo> list = pages.getRecords(); List<EntrustVo> list = pages.getRecords();
if (list != null && list.size() > 0) { if (list != null && list.size() > 0) {
...@@ -428,34 +434,51 @@ public class DataStatisticsServiceImpl implements IDataStatisticsService { ...@@ -428,34 +434,51 @@ public class DataStatisticsServiceImpl implements IDataStatisticsService {
* @return * @return
*/ */
@Override @Override
public BaseResponse<List<DataStatisticsTeamVo>> countTeamList(){ public BaseResponse<IPage<DataStatisticsTeamVo>> countTeamList(PageQuery pageQuery, Integer cycle, String startDate, String endDate){
List<DataStatisticsTeamVo> list = dataStatisticsMapper.countTeamList(); Map<String, Object> params = new HashMap<>();
return BaseResponse.okData(list); params.put("cycle", cycle);
params.put("startDate", startDate);
params.put("endDate", endDate);
Page<DataStatisticsTeamVo> page = new Page<>(pageQuery.getPageNo(), pageQuery.getPageSize());
IPage<DataStatisticsTeamVo> pages = dataStatisticsMapper.countTeamPage(page, params);
List<DataStatisticsTeamVo> list = pages.getRecords();
if (list != null && list.size() > 0) {
for (DataStatisticsTeamVo dstVo : list) {
Integer entrustNum = dataStatisticsMapper.countEntrustNum(dstVo.getId());
dstVo.setEntrustNum(entrustNum);
Integer sampleNum = dataStatisticsMapper.countSampleNum(dstVo.getId());
dstVo.setSampleNum(sampleNum);
}
} }
return BaseResponse.okData(pages);
}
/**
* 各委托单位项目数量统计
* @return
*/
@Override
public BaseResponse<List<DataStatisticsVo>> countByClient(){
List<DataStatisticsVo> list = dataStatisticsMapper.countByClient();
return BaseResponse.okData(list);
}
/**
* 检测元素含量分布情况统计
* @param query 请求参数
* @param response 响应
* @return
*/
@Override @Override
public BaseResponse<Page<ItemDistributionVo>> countItemDistribution(CountItemDistributionQuery query, HttpServletResponse response) { public BaseResponse<Page<ItemDistributionVo>> countItemDistribution(CountItemDistributionQuery query, HttpServletResponse response) {
String startTimeStr = query.getStartTime(); String startTime = query.getStartTime();
String endTimeStr = query.getEndTime(); String endTime = query.getEndTime();
String type = query.getType();
Long itemId = query.getItemId(); Long itemId = query.getItemId();
List<String> origins = query.getOrigins(); List<String> origins = query.getOrigins();
Date startTime = null;
Date endTime = null;
Page<ItemDistribution> page = new Page<>(query.getPageQuery().getPageNo(), query.getPageQuery().getPageSize()); Page<ItemDistribution> page = new Page<>(query.getPageQuery().getPageNo(), query.getPageQuery().getPageSize());
if (StrUtil.isNotEmpty(type)) {
startTime = DateUtil.getStartTime(Integer.parseInt(type));
endTime = cn.hutool.core.date.DateUtil.date();
}
if (StrUtil.isNotEmpty(startTimeStr)) {
startTime = cn.hutool.core.date.DateUtil.parseDate(startTimeStr);
}
if (StrUtil.isNotEmpty(endTimeStr)) {
endTime = cn.hutool.core.date.DateUtil.parseDate(endTimeStr);
}
//获取检测项目城市分布统计 //获取检测项目城市分布统计
IPage<ItemDistribution> list = dataStatisticsMapper IPage<ItemDistribution> list = dataStatisticsMapper
...@@ -482,7 +505,11 @@ public class DataStatisticsServiceImpl implements IDataStatisticsService { ...@@ -482,7 +505,11 @@ public class DataStatisticsServiceImpl implements IDataStatisticsService {
vo.setItemName(sample.getName()); vo.setItemName(sample.getName());
vo.setSampleCount(sample.getCount()); vo.setSampleCount(sample.getCount());
vo.setItemCount(distribution.getCount()); vo.setItemCount(distribution.getCount());
if(StringUtils.isEmpty(startTime) || StringUtils.isEmpty(endTime)){
vo.setTime(null);
}else{
vo.setTime(startTime + "_" + endTime); vo.setTime(startTime + "_" + endTime);
}
rtsRecords.add(vo); rtsRecords.add(vo);
} }
......
...@@ -2529,7 +2529,13 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl ...@@ -2529,7 +2529,13 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
} }
sampleDistributionEquipmentService.saveBatch(sdeList); sampleDistributionEquipmentService.saveBatch(sdeList);
} }
//改变校核表状态为待校核状态
SampleDistributionCheckinput sampleDistributionCheckinput =
sampleDistributionCheckinputMapper.selectById(distribution.getCheckInputId());
if(sampleDistributionCheckinput != null){
sampleDistributionCheckinput.setStatus(2);//待校核
sampleDistributionCheckinputMapper.updateById(sampleDistributionCheckinput);
}
} }
} }
......
...@@ -43,8 +43,8 @@ ...@@ -43,8 +43,8 @@
<if test="params.cycle == 3 "> <if test="params.cycle == 3 ">
and YEAR(sd.create_time) = YEAR( NOW( ) ) and YEAR(sd.create_time) = YEAR( NOW( ) )
</if> </if>
<if test="params.endDate != null and params.endDate != ''"> <if test="params.startDate != null and params.startDate != ''">
and DATE(sd.create_time) &lt;= #{params.endDate} and DATE(sd.create_time) &gt;= #{params.startDate}
</if> </if>
<if test="params.endDate != null and params.endDate != ''"> <if test="params.endDate != null and params.endDate != ''">
and DATE(sd.create_time) &lt;= #{params.endDate} and DATE(sd.create_time) &lt;= #{params.endDate}
...@@ -81,8 +81,8 @@ ...@@ -81,8 +81,8 @@
<if test="params.cycle == 3 "> <if test="params.cycle == 3 ">
and YEAR(e.create_time) = YEAR( NOW( ) ) and YEAR(e.create_time) = YEAR( NOW( ) )
</if> </if>
<if test="params.endDate != null and params.endDate != ''"> <if test="params.startDate != null and params.startDate != ''">
and DATE(e.create_time) &lt;= #{params.endDate} and DATE(e.create_time) &gt;= #{params.startDate}
</if> </if>
<if test="params.endDate != null and params.endDate != ''"> <if test="params.endDate != null and params.endDate != ''">
and DATE(e.create_time) &lt;= #{params.endDate} and DATE(e.create_time) &lt;= #{params.endDate}
...@@ -91,7 +91,7 @@ ...@@ -91,7 +91,7 @@
</select> </select>
<select id="countEntrustType" resultType="cn.wise.sc.cement.business.model.vo.DataStatisticsVo"> <select id="countEntrustType" resultType="cn.wise.sc.cement.business.model.vo.DataStatisticsVo">
select e.project_type, count(*) select e.project_type as name, count(*) as value
from entrust e from entrust e
where e.status != 0 and e.project_type is not null where e.status != 0 and e.project_type is not null
<if test="params.cycle == 1 "> <if test="params.cycle == 1 ">
...@@ -103,8 +103,8 @@ ...@@ -103,8 +103,8 @@
<if test="params.cycle == 3 "> <if test="params.cycle == 3 ">
and YEAR(e.create_time) = YEAR( NOW( ) ) and YEAR(e.create_time) = YEAR( NOW( ) )
</if> </if>
<if test="params.endDate != null and params.endDate != ''"> <if test="params.startDate != null and params.startDate != ''">
and DATE(e.create_time) &lt;= #{params.endDate} and DATE(e.create_time) &gt;= #{params.startDate}
</if> </if>
<if test="params.endDate != null and params.endDate != ''"> <if test="params.endDate != null and params.endDate != ''">
and DATE(e.create_time) &lt;= #{params.endDate} and DATE(e.create_time) &lt;= #{params.endDate}
...@@ -136,6 +136,12 @@ ...@@ -136,6 +136,12 @@
<if test="params.clientName != null and params.clientName != ''"> <if test="params.clientName != null and params.clientName != ''">
and c.name like concat('%', #{params.clientName}, '%') and c.name like concat('%', #{params.clientName}, '%')
</if> </if>
<if test="params.startDate != null and params.startDate != ''">
and DATE(e.create_time) &gt;= #{params.startDate}
</if>
<if test="params.endDate != null and params.endDate != ''">
and DATE(e.create_time) &lt;= #{params.endDate}
</if>
order by create_time desc order by create_time desc
</select> </select>
...@@ -165,18 +171,33 @@ ...@@ -165,18 +171,33 @@
</select> </select>
<select id="countDistributionPage" resultType="cn.wise.sc.cement.business.model.vo.DataStatisticsVo"> <select id="countDistributionPage" resultType="cn.wise.sc.cement.business.model.vo.DataStatisticsVo">
SELECT su.name as name, count(*) as value FROM sample_distribution sd SELECT su.id as id, su.name as name, count(*) as value FROM sample_distribution sd
left join sys_user su on su.id = sd.user_id left join sys_user su on su.id = sd.user_id
where sd.status = 1 or sd.status = 5 where sd.status = 1 or sd.status = 5
group by sd.user_id group by sd.user_id
</select> </select>
<select id="countDistributionWeek" resultType="integer">
SELECT count(*)
FROM sample_distribution sd
left join sys_user su on su.id = sd.user_id
where (sd.status =2 or sd.status =4)
<if test="userId != null ">
and sd.user_id = #{userId}
</if>
<if test="weekType == 1 ">
and YEARWEEK(date_format(sd.create_time,'%Y-%m-%d' ) ) = YEARWEEK(now())-1
</if>
<if test="weekType == 2 ">
and YEARWEEK(date_format(sd.create_time,'%Y-%m-%d' ) ) = YEARWEEK(now())
</if>
group by sd.user_id
</select>
<select id="countTeamIng" resultType="cn.wise.sc.cement.business.model.vo.DataStatisticsVo"> <select id="countTeamIng" resultType="cn.wise.sc.cement.business.model.vo.DataStatisticsVo">
SELECT t.name as name, count(*) as value FROM sample_distribution sd SELECT t.name as name, count(*) as value FROM sample_distribution sd
left join team t on t.id = sd.team_id left join team t on t.id = sd.team_id
...@@ -197,23 +218,59 @@ ...@@ -197,23 +218,59 @@
<if test="params.cycle == 3 "> <if test="params.cycle == 3 ">
and YEAR(sd.create_time) = YEAR( NOW( ) ) and YEAR(sd.create_time) = YEAR( NOW( ) )
</if> </if>
<if test="params.startDate != null and params.startDate != ''">
and DATE(sd.create_time) &gt;= #{params.startDate}
</if>
<if test="params.endDate != null and params.endDate != ''"> <if test="params.endDate != null and params.endDate != ''">
and DATE(sd.create_time) &lt;= #{params.endDate} and DATE(sd.create_time) &lt;= #{params.endDate}
</if> </if>
group by sd.team_id
</select>
<select id="countTeamPage" resultType="cn.wise.sc.cement.business.model.vo.DataStatisticsTeamVo">
SELECT t.id as id, t.name as teamName, count(*) as teamNum FROM sample_distribution sd
left join team t on t.id = sd.team_id
where 1=1
<if test="params.cycle == 1 ">
and YEARWEEK(date_format(sd.create_time,'%Y-%m-%d' ) ) = YEARWEEK(now())
</if>
<if test="params.cycle == 2 ">
and DATE_FORMAT( sd.create_time, '%Y%m' ) = DATE_FORMAT( CURDATE( ) ,'%Y%m')
</if>
<if test="params.cycle == 3 ">
and YEAR(sd.create_time) = YEAR( NOW( ) )
</if>
<if test="params.startDate != null and params.startDate != ''">
and DATE(sd.create_time) &gt;= #{params.startDate}
</if>
<if test="params.endDate != null and params.endDate != ''"> <if test="params.endDate != null and params.endDate != ''">
and DATE(sd.create_time) &lt;= #{params.endDate} and DATE(sd.create_time) &lt;= #{params.endDate}
</if> </if>
group by sd.team_id group by sd.team_id
</select> </select>
<select id="countTeamList" resultType="cn.wise.sc.cement.business.model.vo.DataStatisticsTeamVo"> <select id="countEntrustNum" resultType="integer">
SELECT DISTINCT t.name as teamName, e.project_code as projectCode, select count(*) as entrustNum from (
e.entrust_code as entrustCode, e.entrust_date as entrustDate, SELECT sd.entrust_id as id, count(*) as entrustNum FROM sample_distribution sd
e.sample_num as sampleNum where sd.team_id = #{teamId}
FROM sample_distribution sd group by sd.entrust_id
left join sample s on s.id = sd.sample_id )aa
left join entrust e on e.id = s.entrust_id </select>
left join team t on t.id = sd.team_id
<select id="countSampleNum" resultType="integer">
select count(*) as sampleNum from (
SELECT sd.sample_id as id, count(*) as entrustNum FROM sample_distribution sd
where sd.team_id = #{teamId}
group by sd.sample_id
)aa
</select>
<select id="countByClient" resultType="cn.wise.sc.cement.business.model.vo.DataStatisticsVo">
select c.name as name, count(*) as value from entrust e
left join client c on c.id = e.client_id
group by e.client_id
</select> </select>
...@@ -222,13 +279,22 @@ ...@@ -222,13 +279,22 @@
<select id="countItemDistributionSample" <select id="countItemDistributionSample"
resultType="cn.wise.sc.cement.business.entity.ItemDistributionSample"> resultType="cn.wise.sc.cement.business.entity.ItemDistributionSample">
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 WHERE 1=1
sd.finish_time BETWEEN #{start} AND #{end} <if test="start != null and end != null">
AND (sd.finish_time between #{start} and #{end})
</if>
<if test="origin != null and origin != '' "> <if test="origin != null and origin != '' ">
AND s.origin = #{origin} AND s.origin = #{origin}
</if> </if>
...@@ -243,7 +309,10 @@ ...@@ -243,7 +309,10 @@
`key` FROM sample_distribution sd `key` 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 (sd.finish_time between #{start} and #{end}) WHERE 1=1
<if test="start != null and end != null">
AND (sd.finish_time between #{start} and #{end})
</if>
<if test="origins != null and origins.size()>0"> <if test="origins != null and origins.size()>0">
AND s.origin in AND s.origin in
<foreach collection="origins" item="item" open="(" separator="," close=")"> <foreach collection="origins" item="item" open="(" separator="," close=")">
......
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