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

统计功能完成

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