Commit 3e34d9c1 authored by 耿迪迪's avatar 耿迪迪

气瓶统计

parent 155c72ef
......@@ -6,6 +6,7 @@ import com.zehong.common.core.domain.AjaxResult;
import com.zehong.common.core.page.TableDataInfo;
import com.zehong.common.enums.BusinessType;
import com.zehong.common.utils.poi.ExcelUtil;
import com.zehong.system.domain.BottleStatistics;
import com.zehong.system.domain.TGasBottleInfo;
import com.zehong.system.service.ITGasBottleInfoService;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -119,4 +120,18 @@ public class TGasBottleInfoController extends BaseController
ExcelUtil<TGasBottleInfo> util = new ExcelUtil<>(TGasBottleInfo.class);
return util.importTemplateExcel("气瓶数据");
}
@GetMapping("/bottleStatistics")
public TableDataInfo bottleStatistics(@RequestParam(value="stationId",required = false) Long stationId){
startPage();
return getDataTable(tGasBottleInfoService.bottleStatistics(stationId));
}
@GetMapping("/bottleStatisticsExport")
public AjaxResult bottleStatisticsExport(@RequestParam(value = "stationId",required = false) Long stationId)
{
List<BottleStatistics> statistics = tGasBottleInfoService.bottleStatistics(stationId);
ExcelUtil<BottleStatistics> util = new ExcelUtil<>(BottleStatistics.class);
return util.exportExcel(statistics, "气瓶信息数据");
}
}
package com.zehong.system.domain;
import com.zehong.common.annotation.Excel;
public class BottleStatistics {
/** 储配站主键*/
private Long stationId;
/** 储配站*/
@Excel(name = "储配站")
private String stationName;
/** 气瓶数量*/
@Excel(name = "气瓶数量")
private Integer totalNum;
/** 正常数量*/
@Excel(name = "正常数量")
private Integer normalNum;
/** 逾期数量*/
@Excel(name = "逾期数量")
private Integer overNum;
/** 报废数量*/
@Excel(name = "报废数量")
private Integer junkNum;
public Long getStationId() {
return stationId;
}
public void setStationId(Long stationId) {
this.stationId = stationId;
}
public String getStationName() {
return stationName;
}
public void setStationName(String stationName) {
this.stationName = stationName;
}
public Integer getTotalNum() {
return totalNum;
}
public void setTotalNum(Integer totalNum) {
this.totalNum = totalNum;
}
public Integer getNormalNum() {
return normalNum;
}
public void setNormalNum(Integer normalNum) {
this.normalNum = normalNum;
}
public Integer getOverNum() {
return overNum;
}
public void setOverNum(Integer overNum) {
this.overNum = overNum;
}
public Integer getJunkNum() {
return junkNum;
}
public void setJunkNum(Integer junkNum) {
this.junkNum = junkNum;
}
}
package com.zehong.system.mapper;
import java.util.List;
import com.zehong.system.domain.BottleStatistics;
import com.zehong.system.domain.TGasBottleInfo;
import java.util.List;
/**
* 气瓶信息Mapper接口
*
......@@ -58,4 +60,11 @@ public interface TGasBottleInfoMapper
* @return 结果
*/
public int deleteTGasBottleInfoByIds(Long[] bottleIds);
/**
* 气瓶统计
* @param stationId 储配站id
* @return
*/
List<BottleStatistics> bottleStatistics(Long stationId);
}
package com.zehong.system.service;
import java.util.List;
import com.zehong.system.domain.BottleStatistics;
import com.zehong.system.domain.TGasBottleInfo;
import java.util.List;
/**
* 气瓶信息Service接口
*
......@@ -66,4 +68,11 @@ public interface ITGasBottleInfoService
* @return
*/
String importTGasBottleInfo(List<TGasBottleInfo> tGasBottleInfoList,Boolean isUpdateSupport);
/**
* 气瓶统计
* @param stationId 储配站id
* @return
*/
List<BottleStatistics> bottleStatistics(Long stationId);
}
......@@ -3,6 +3,7 @@ package com.zehong.system.service.impl;
import com.zehong.common.exception.CustomException;
import com.zehong.common.utils.DateUtils;
import com.zehong.common.utils.StringUtils;
import com.zehong.system.domain.BottleStatistics;
import com.zehong.system.domain.TGasBottleInfo;
import com.zehong.system.domain.TGasStorageStationInfo;
import com.zehong.system.mapper.TGasBottleInfoMapper;
......@@ -174,4 +175,14 @@ public class TGasBottleInfoServiceImpl implements ITGasBottleInfoService
}
return successMsg.toString();
}
/**
* 气瓶统计
* @param stationId 储配站id
* @return
*/
@Override
public List<BottleStatistics> bottleStatistics(Long stationId){
return tGasBottleInfoMapper.bottleStatistics(stationId);
}
}
......@@ -213,4 +213,31 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{bottleId}
</foreach>
</delete>
<select id="bottleStatistics" parameterType="java.lang.Long" resultType="com.zehong.system.domain.BottleStatistics">
select
(select station_name from t_gas_storage_station_info info where info.station_id = final.station_id) as stationName,
sum(final.totalNum) as totalNum,
sum(final.normalNum) as normalNum,
sum(final.overNum) as overNum,
sum(final.junkNum) as junkNum
from(
select
base.station_id,
count(1) as totalNum,
case bottle_status when '1' then count(1) else 0 end as normalNum,
case bottle_status when '2' then count(1) else 0 end as overNum,
case bottle_status when '3' then count(1) else 0 end as junkNum
from
t_gas_bottle_info base
<where>
<if test="stationId != null">
base.station_id = #{stationId}
</if>
</where>
group by
base.station_id,base.bottle_status
)final
group by final.station_id
</select>
</mapper>
\ No newline at end of file
......@@ -119,7 +119,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach>
</delete>
<select id="baseInfoStatistics" parameterType="java.lang.String" resultType="com.zehong.system.domain.BaseInfoStatistics">
<select id="baseInfoStatistics" parameterType="java.lang.Long" resultType="com.zehong.system.domain.BaseInfoStatistics">
SELECT
station.station_name as stationName,
(SELECT COUNT(1) FROM t_gas_bottle_info bottle WHERE bottle.station_id = station.station_id)as totalBottle,
......
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