Commit ae8e7e00 authored by 竹天卫's avatar 竹天卫

统计 设备

parent d90b342f
......@@ -32,14 +32,20 @@ public class DataStatisticsController {
@ApiOperation(value = "统计概览-检测项数量统计")
@ApiImplicitParams(value = {
@ApiImplicitParam(name = "type", value = "类型1:按时间 2:按地区", paramType = "query", dataType = "Integer"),
@ApiImplicitParam(name = "cycle", value = "统计周期1:本周 2:本月 3:本年", paramType = "query", dataType = "Integer"),
@ApiImplicitParam(name = "type", value = "类型1:图 2:表", paramType = "query", dataType = "Integer"),
@ApiImplicitParam(name = "cycle", value = "统计周期1:本周 2:本月 3:本季度,4:本年", paramType = "query", dataType = "Integer"),
@ApiImplicitParam(name = "startDate", value = "开始日期", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "endDate", value = "结束日期", paramType = "query", dataType = "String")
})
@GetMapping("/countByPhoto")
public R countByPhoto(String TruckID, Integer cycle, String startDate, String endDate) {
return dataStatisticsService.countByPhoto(TruckID, cycle, startDate, endDate);
public R countByPhoto(Integer type, String TruckID, Integer cycle, String startDate, String endDate) {
if(type == 1){
return dataStatisticsService.countByPhoto(TruckID, cycle, startDate, endDate);
}else if(type == 2){
return dataStatisticsService.countByTable(TruckID, cycle, startDate, endDate);
}else{
return R.fail(400, "参数错误");
}
}
......
package cn.wise.sc.acquisition.business.mapper;
import cn.wise.sc.acquisition.business.model.vo.DataStatisticsTableVo;
import cn.wise.sc.acquisition.business.model.vo.DataStatisticsVo;
import org.apache.ibatis.annotations.Param;
import java.util.List;
......@@ -18,5 +19,5 @@ public interface DataStatisticsMapper {
List<DataStatisticsVo> countByPhoto(@Param("params") Map<String, Object> params);
List<DataStatisticsTableVo> countByTable(@Param("params") Map<String, Object> params);
}
......@@ -3,31 +3,69 @@
<mapper namespace="cn.wise.sc.acquisition.business.mapper.DataStatisticsMapper">
<select id="countByPhoto" resultType="cn.wise.sc.acquisition.business.model.vo.DataStatisticsVo">
SELECT DATE_FORMAT(sd.create_time,'%Y-%m-%d') as name, count(sd.id) as value
FROM sample_distribution sd
where sd.finish_time is not null
SELECT tw.Rq as name, SUM(tw.Jz) as value
FROM T_Weight tw
where 1=1
<if test="params.cycle == 1 ">
and YEARWEEK(date_format(sd.create_time,'%Y-%m-%d' ) ) = YEARWEEK(now())
and datediff(week, tw.Rq,getdate())=0
</if>
<if test="params.cycle == 2 ">
and DATE_FORMAT( sd.create_time, '%Y%m' ) = DATE_FORMAT( CURDATE( ) ,'%Y%m')
and datediff(month, tw.Rq,getdate())=0
</if>
<if test="params.cycle = 3 ">
and YEAR(sd.create_time) = YEAR( NOW( ) )
and datediff(quarter, tw.Rq,getdate())=0
</if>
<if test="params.cycle = 4 ">
and datediff(year, tw.Rq,getdate())=0
</if>
<if test="params.startDate != null and params.startDate != ''">
and tw.Rq > &gt;= #{params.startDate}
</if>
<if test="params.endDate != null and params.endDate != ''">
and tw.Rq > &lt;= #{params.endDate}
</if>
<if test="params.startDate == null and params.endDate == null">
and datediff(week, tw.Rq,getdate())=0
</if>
group by tw.Rq
</select>
<select id="countByTable" resultType="cn.wise.sc.acquisition.business.model.vo.DataStatisticsTableVo">
SELECT tw.Uid,tw.Rq,tw.Sj,tw.TruckID,'发货单位' as clientName,tpt.WorkType,tw.Mz,tw.Pz,tw.Jz
FROM T_Weight tw
left join T_Processes_Truck tpt on tpt.TruckID = tw.TruckID
where 1=1
<if test="params.cycle == 1 ">
and datediff(week, tw.Rq,getdate())=0
</if>
<if test="params.cycle == 2 ">
and datediff(month, tw.Rq,getdate())=0
</if>
<if test="params.cycle = 3 ">
and datediff(quarter, tw.Rq,getdate())=0
</if>
<if test="params.cycle = 4 ">
and datediff(year, tw.Rq,getdate())=0
</if>
<if test="params.startDate != null and params.startDate != ''">
and DATE(sd.create_time) &gt;= #{params.startDate}
and tw.Rq > &gt;= #{params.startDate}
</if>
<if test="params.endDate != null and params.endDate != ''">
and DATE(sd.create_time) &lt;= #{params.endDate}
and tw.Rq > &lt;= #{params.endDate}
</if>
<if test="params.startDate == null and params.endDate == null">
and date(sd.create_time) > date_sub(curdate(),interval 30 day)
and datediff(week, tw.Rq,getdate())=0
</if>
group by name
group by tw.Rq
</select>
</mapper>
package cn.wise.sc.acquisition.business.model.vo;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @description:
* @author: ztw
* @create: 2021-04-26
**/
@Data
@ApiModel("数据统计-产量统计表格展示类")
public class DataStatisticsTableVo {
/**
* ID号
*/
@TableId("地磅称重表id")
private String Uid;
/**
* 日期
*/
@ApiModelProperty("日期")
private String Rq;
/**
* 时间
*/
@ApiModelProperty("时间")
private String Sj;
/**
* 矿车编号
*/
@ApiModelProperty("矿车编号")
private String TruckID;
@ApiModelProperty("发货单位")
private String clientName;
@ApiModelProperty("货品名称")
private String WorkType;
/**
* 总毛重
*/
@ApiModelProperty("总毛重")
private Float Mz;
/**
* 总皮重
*/
@ApiModelProperty("总皮重")
private Float Pz;
/**
* 总净重
*/
@ApiModelProperty("总净重")
private Float Jz;
}
package cn.wise.sc.acquisition.business.service;
import cn.wise.im.common.http.R;
import cn.wise.sc.acquisition.business.model.vo.DataStatisticsTableVo;
import cn.wise.sc.acquisition.business.model.vo.DataStatisticsVo;
import java.util.List;
......@@ -17,4 +18,5 @@ public interface IDataStatisticsService {
R<List<DataStatisticsVo>> countByPhoto(String TruckID, Integer cycle, String startDate, String endDate);
R<List<DataStatisticsTableVo>> countByTable(String TruckID, Integer cycle, String startDate, String endDate);
}
......@@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.StrUtil;
import cn.wise.im.common.http.R;
import cn.wise.sc.acquisition.business.mapper.DataStatisticsMapper;
import cn.wise.sc.acquisition.business.model.vo.DataStatisticsTableVo;
import cn.wise.sc.acquisition.business.model.vo.DataStatisticsVo;
import cn.wise.sc.acquisition.business.service.IDataStatisticsService;
import io.jsonwebtoken.lang.Assert;
......@@ -27,6 +28,14 @@ public class DataStatisticsServiceImpl implements IDataStatisticsService {
@Resource
private DataStatisticsMapper dataStatisticsMapper;
/**
* 产品产量统计-图
* @param TruckID
* @param cycle
* @param startDate
* @param endDate
* @return
*/
@Override
public R<List<DataStatisticsVo>> countByPhoto(String TruckID, Integer cycle, String startDate, String endDate){
Map<String, Object> params = new HashMap<>();
......@@ -35,11 +44,27 @@ public class DataStatisticsServiceImpl implements IDataStatisticsService {
params.put("startDate", startDate);
params.put("endDate", endDate);
List<DataStatisticsVo> list = dataStatisticsMapper.countByPhoto(params);
return R.ok(list);
}
/**
* 产品产量统计-表
* @param TruckID
* @param cycle
* @param startDate
* @param endDate
* @return
*/
@Override
public R<List<DataStatisticsTableVo>> countByTable(String TruckID, Integer cycle, String startDate, String endDate){
Map<String, Object> params = new HashMap<>();
params.put("TruckID", TruckID);
params.put("cycle", cycle);
params.put("startDate", startDate);
params.put("endDate", endDate);
List<DataStatisticsTableVo> list = dataStatisticsMapper.countByTable(params);
return R.ok(list);
}
......
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