kangwei:修改bug,以及完善代码

1 个父辈 36cfe130
......@@ -54,6 +54,12 @@ public class DangerInspectionRecord {
@ApiModelProperty(value = "风险点类型")
@Dict(dicCode = "dangerType")
private String dangerType;
@ApiModelProperty(value = "巡检类型")
@Dict(dicCode = "inspection_type")
private String inspectionType;
/**上报人(用户id)*/
@Excel(name = "上报人(用户id)", width = 15)
@ApiModelProperty(value = "上报人(用户id)")
......
......@@ -204,10 +204,10 @@ public class EquipmentStatisticsController {
if( StringUtils.isNotEmpty(equipmentInfo.getDepartId())){
departIds = departService.getChildDepartId(equipmentInfo.getDepartId());
}
equipmentInfo.setDepartIds(departIds);
equipmentInfo.setDepartIds(JSUtils.quoteEach(departIds,","));
Page<EquipmentInfoDuration> page = new Page<EquipmentInfoDuration>(pageNo, pageSize);
// queryWrapper.orderByDesc("create_time");
IPage<EquipmentInfoDuration> pageList = equipmentInfoDurationService.queryPageList(page,equipmentInfo);
IPage<EquipmentInfoDuration> pageList = equipmentInfoDurationService.queryEquipmentInfoDurationByPage(page,equipmentInfo);
result.setSuccess(true);
result.setResult(pageList);
return result;
......
......@@ -35,6 +35,11 @@ public class EquipmentInfoDuration {
@ApiModelProperty(value = "设备编号")
@Dict(dicCode = "id",dictTable="equipment_info",dicText="equipment_name")
private String infoId;
@Dict(dicCode = "id",dicText = "des",dictTable = "equipment_category")
@ApiModelProperty(value = "设备类别")
private String equipmentType;
/**日期*/
@Excel(name = "日期", width = 15)
@ApiModelProperty(value = "日期")
......
......@@ -20,4 +20,6 @@ public interface EquipmentInfoDurationMapper extends BaseMapper<EquipmentInfoDur
@Anonymous
IPage<EquipmentInfoDuration> queryPageList(Page page, @Param("param") EquipmentInfoDuration equipmentInfoDuration);
IPage<EquipmentInfoDuration> queryEquipmentInfoDurationByPage(Page<EquipmentInfoDuration> page,@Param("param") EquipmentInfoDuration equipmentInfo);
}
......
......@@ -9,6 +9,9 @@
<if test="param.departIds !=null and param.departIds !=''">
and eid.depart_id in(${param.departIds})
</if>
<if test="param.infoId !=null and param.infoId !=''">
and eid.info_id in(${param.departIds})
</if>
<if test="param.startTime !=null and param.startTime !=''">
AND eid.data_time &gt;= #{param.startTime}
</if>
......@@ -18,4 +21,22 @@
</select>
<select id="queryEquipmentInfoDurationByPage" resultType="com.skua.modules.statistics.entity.EquipmentInfoDuration">
select ei.equipment_type,ei.equipment_name, eid.depart_id ,eid.info_id ,sum(eid.yz_duration) 'yz_duration',max(eid.total_duration) 'total_duration',
round(100*sum(eid.yz_duration)/max(eid.total_duration),2) 'sbyxRate' from equipment_info_duration eid
left join equipment_info ei on ei.id = eid.info_id
where 1=1
<if test="param.departIds !=null and param.departIds !=''">
and eid.depart_id in(${param.departIds})
</if>
<if test="param.startTime !=null and param.startTime !=''">
AND eid.data_time &gt;= #{param.startTime}
</if>
<if test="param.endTime !=null and param.endTime !=''">
AND eid.data_time &lt;= #{param.endTime}
</if>
group by eid.depart_id ,eid.info_id
</select>
</mapper>
......
......@@ -27,4 +27,6 @@ public interface IEquipmentInfoDurationService extends IService<EquipmentInfoDur
* @throws Exception
*/
public boolean fillOutEquipmentInfoDuration(String departId,String startTime,String endTime) throws Exception;
IPage<EquipmentInfoDuration> queryEquipmentInfoDurationByPage(Page<EquipmentInfoDuration> page, EquipmentInfoDuration equipmentInfo);
}
......
......@@ -32,8 +32,6 @@ public class EquipmentInfoDurationServiceImpl extends ServiceImpl<EquipmentInfoD
@Autowired
private ICommonSqlService commonSqlService;
@Autowired
private IPgCommonService pgCommonService;
/***
* 分页列表
* @param page
......@@ -43,6 +41,9 @@ public class EquipmentInfoDurationServiceImpl extends ServiceImpl<EquipmentInfoD
public IPage<EquipmentInfoDuration> queryPageList(Page page, EquipmentInfoDuration equipmentInfoDuration){
return this.baseMapper.queryPageList(page,equipmentInfoDuration);
}
public IPage<EquipmentInfoDuration> queryEquipmentInfoDurationByPage(Page<EquipmentInfoDuration> page, EquipmentInfoDuration equipmentInfo){
return this.baseMapper.queryEquipmentInfoDurationByPage(page,equipmentInfo);
}
/***
* 设备运行时长填报数据
......@@ -86,22 +87,29 @@ public class EquipmentInfoDurationServiceImpl extends ServiceImpl<EquipmentInfoD
List<Object[]> batchArgs=new ArrayList<Object[]>();
if(metricMapList != null && !metricMapList.isEmpty()){
for(Map<String, Object> metricMap : metricMapList){ //遍历设备记录以及metric 标签
pgSql = "select aaaaa.time , aaaaa.yx_duration ,bbbbb.gz_duration from ( ";
pgSql = "select aaaaa.time , aaaaa.yx_duration ,bbbbb.gz_duration ,ddddd.zt_duration,ccccc.total_duration from ( ";
pgSql += " select '11111111' info_id , aaa.time , ROUND(SUM( to_number ( aaa.monitorValue, '9999999999999999.99' ) ) / 60 ,2)as yx_duration from ( ";
pgSql += " select TO_TIMESTAMP(ts ::BIGINT)::DATE AS time,nm as monitorId,v as monitorValue from TCSWSCLC_count where nm ='"+metricMap.get("yxExpress")+"' and ts>='"+tsStartTime+"' and ts <'"+tsEndTime+"' ";
pgSql += " select TO_TIMESTAMP(ts ::BIGINT)::DATE AS time,nm as monitorId,v as monitorValue from "+countTableName+"_count where nm ='"+metricMap.get("yxExpress")+"' and ts>='"+tsStartTime+"' and ts <'"+tsEndTime+"' ";
pgSql += " ) aaa group by aaa.time order by aaa.time asc ";
pgSql += " ) aaaaa ";
pgSql += " left join ( ";
pgSql += " select aaa.time , ROUND(SUM( to_number ( aaa.monitorValue, '9999999999999999.99' ) ) / 60 ,2)as gz_duration from ( ";
pgSql += " select TO_TIMESTAMP(ts ::BIGINT)::DATE AS time,nm as monitorId,v as monitorValue from TCSWSCLC_count where nm ='"+ ConvertUtils.getString(metricMap.get("gzExpress"),"-")+"' and ts>='"+tsStartTime+"' and ts <'"+tsEndTime+"' ";
pgSql += " select TO_TIMESTAMP(ts ::BIGINT)::DATE AS time,nm as monitorId,v as monitorValue from "+countTableName+"_count where nm ='"+ ConvertUtils.getString(metricMap.get("gzExpress"),"-")+"' and ts>='"+tsStartTime+"' and ts <'"+tsEndTime+"' ";
pgSql += " ) aaa group by aaa.time order by aaa.time asc ";
pgSql += " )bbbbb on aaaaa.time = bbbbb.time ";
pgSql += " left join ( ";
pgSql += " select aaa.time , ROUND(SUM( to_number ( aaa.monitorValue, '9999999999999999.99' ) ) / 60 ,2)as zt_duration from ( ";
pgSql += " select TO_TIMESTAMP(ts ::BIGINT)::DATE AS time,nm as monitorId,v as monitorValue from "+countTableName+"_count where nm ='"+ ConvertUtils.getString(metricMap.get("tzExpress"),"-")+"' and ts>='"+tsStartTime+"' and ts <'"+tsEndTime+"' ";
pgSql += " ) aaa group by aaa.time order by aaa.time asc ";
pgSql += " )ddddd on aaaaa.time = ddddd.time ";
pgSql += " left join ( ";
pgSql += " select '11111111' info_id , ROUND(SUM( to_number ( aaa.monitorValue, '9999999999999999.99' ) ) / 60 ,2)as total_duration from ( ";
pgSql += " select TO_TIMESTAMP(ts ::BIGINT)::DATE AS time,nm as monitorId,v as monitorValue from TCSWSCLC_count where nm in('"+metricMap.get("yxExpress")+"','"+ConvertUtils.getString(metricMap.get("gzExpress"),"-")+"','"+ConvertUtils.getString(metricMap.get("tzExpress"),"-")+"') and ts <'"+tsEndTime+"' ";
pgSql += " select TO_TIMESTAMP(ts ::BIGINT)::DATE AS time,nm as monitorId,v as monitorValue from "+countTableName+"_count where nm in('"+metricMap.get("yxExpress")+"','"+ConvertUtils.getString(metricMap.get("gzExpress"),"-")+"','"+ConvertUtils.getString(metricMap.get("tzExpress"),"-")+"') and ts <'"+tsEndTime+"' ";
pgSql += " ) aaa ";
pgSql += ")ccccc on aaaaa.info_id = ccccc.info_id ";
......@@ -109,7 +117,8 @@ public class EquipmentInfoDurationServiceImpl extends ServiceImpl<EquipmentInfoD
//总时间长
if(dataList != null && !dataList.isEmpty()){
for(Map<String,Object > dataMap : dataList){
Object[] obj = { UniqIdUtils.getInstance().getUniqID() ,departId ,metricMap.get("info_id"),dataMap.get("time"),dataMap.get("yx_duration"),dataMap.get("gz_duration"),dataMap.get("total_duration"),DateUtils.now()};
Object[] obj = { UniqIdUtils.getInstance().getUniqID() ,departId ,metricMap.get("info_id"),dataMap.get("time"),ConvertUtils.getString(dataMap.get("yx_duration"),"0"),ConvertUtils.getString(dataMap.get("gz_duration"),"0")
,ConvertUtils.getString(dataMap.get("zt_duration"),"0"),ConvertUtils.getString(dataMap.get("total_duration"),"0"),DateUtils.now()};
batchArgs.add(obj);
}
}
......@@ -118,7 +127,7 @@ public class EquipmentInfoDurationServiceImpl extends ServiceImpl<EquipmentInfoD
}
// this.getJdbcTemplate().batchUpdate();
if(batchArgs != null && !batchArgs.isEmpty()){
this.getJdbcTemplate().batchUpdate("insert into equipment_info_duration (id,depart_id,info_id,data_time,gz_duration,yz_duration,total_duration,create_time) value(?,?,?,?,?,?,?,?)",batchArgs);
this.getJdbcTemplate().batchUpdate("insert into equipment_info_duration (id,depart_id,info_id,data_time,yz_duration,gz_duration,zt_duration,total_duration,create_time) value(?,?,?,?,?,?,?,?,?)",batchArgs);
}
//计算总时长
......
......@@ -75,7 +75,7 @@ public class EquipmentStatisticsServiceImpl implements IEquipmentStatisticsServ
*/
public List<EquipmentRepairMaintainTaskCostDetailVO> repairMaintainTaskCostDetailList(String departId, String startTime, String endTime){
String sql = "select d.depart_name, aaa.* from ( ";
sql +=" select er.depart_id , ei.equipment_name 'name' , '维修费用' as 'cost_type',er.total_cost 'cost',\tDATE_FORMAT( er.repair_date, '%Y-%m-%d' ) 'time' from equipment_repair er , equipment_info ei ";
sql +=" select er.depart_id , ei.equipment_name 'name' , '维修费用' as 'cost_type',er.total_cost 'cost',DATE_FORMAT( er.repair_date, '%Y-%m-%d' ) 'time' from equipment_repair er , equipment_info ei ";
sql += " where er.info_id = ei.id and er.total_cost > 0 and er.repair_date >= '"+startTime+" 00:00:00' and er.repair_date <='"+endTime+" 23:59:59' and er.depart_id = '"+departId+"' ";
sql += " UNION " ;
sql += " select emt.depart_id, emt.maintain_plan_name 'name',";
......@@ -167,67 +167,7 @@ public class EquipmentStatisticsServiceImpl implements IEquipmentStatisticsServ
return dataList;
}
/***
* 设备运行时长填报数据
* @param departId
* @param startTime
* @param endTime
* @return
*/
@Transactional
public boolean fillOutEquipmentInfoDuration(String departId,String startTime,String endTime) throws Exception{
//清理数据
String deleteSql = " delete from equipment_info_duration where depart_id = '"+departId+"' and date_time >= '"+startTime+"' and date_time <='"+endTime+"' ";
commonSqlService.delete(deleteSql);
//2
String countTableName = commonSqlService.queryForString("select device_id from sys_factory_device where depart_id = '" + departId + "'");
// 步骤3
String metric_sql = "select t.equipment_code as 'info_id', ei.equipment_name , t.metric_express1 'gzExpress' , t.metric_express2 'yxExpress' ,t.metric_express3 'tzExpress' from sys_monitor_metric_info t ";
metric_sql += " left join equipment_info ei on ei.id = t.equipment_code where t.metric_type = 1 and t.depart_id = '"+departId+"' and t.equipment_code > 0 ";
List<Map<String, Object>> metricMapList = commonSqlService.queryForList(metric_sql);
if(startTime.length() < 11 ){
startTime = startTime +" 00:00:00";
}
if(endTime.length() < 11 ){
endTime = endTime +" 23:59:59";
}
String tsStartTime = String.valueOf(DateUtils.getMillis(DateUtils.parseDate(startTime, "yyyy-MM-dd HH:mm:ss")) / 1000L);
String tsEndTime = String.valueOf(DateUtils.getMillis(DateUtils.parseDate(endTime, "yyyy-MM-dd HH:mm:ss")) / 1000L);
String pgSql = null;
//步骤4 查询 pg数据库
List<Map<String, Object>> dataList = null;
String insertSql = null;
if(metricMapList != null && !metricMapList.isEmpty()){
for(Map<String, Object> metricMap : metricMapList){ //遍历设备记录以及metric 标签
pgSql = "select aaaaa.depart_id, aaaaa.info_id, aaaaa.time data_time, aaaaa.yx_duration ,bbbbb.gz_duration from (";
pgSql += " select '"+departId+"' depart_id, '"+metricMap.get("info_id")+"' info_id , aaa.time , ROUND(SUM( to_number ( aaa.monitorValue, '9999999999999999.99' ) ) / 60 ,2)as yx_duration from ( ";
pgSql += " select TO_TIMESTAMP(ts ::BIGINT)::DATE AS time,nm as monitorId,v as monitorValue from TCSWSCLC_count where nm ='"+metricMap.get("yxExpress")+"' and ts>='"+tsStartTime+"' and ts <'"+tsEndTime+"' ";
pgSql += " ) aaa group by aaa.time order by aaa.time asc ";
pgSql += " ) aaaaa ";
if(metricMap.get("gzExpress") != null ){
pgSql += " left join ( ";
pgSql += " select aaa.time , ROUND(SUM( to_number ( aaa.monitorValue, '9999999999999999.99' ) ) / 60 ,2)as gz_duration from ( ";
pgSql += " select TO_TIMESTAMP(ts ::BIGINT)::DATE AS time,nm as monitorId,v as monitorValue from TCSWSCLC_count where nm ='"+metricMap.get("yxExpress")+"' and ts>='"+tsStartTime+"' and ts <'"+tsEndTime+"' ";
pgSql += " ) aaa group by aaa.time order by aaa.time asc ";
pgSql += " )bbbbb on aaaaa.time = bbbbb.time ";
}
dataList = pgCommonService.queryForList(pgSql);
//总时间长
}
}
return false;
}
......
......@@ -45,8 +45,8 @@ public class OperationReportServiceImpl implements IOperationReportService {
* @return
*/
public ProductDataVO handeReportMonthData(String departId,Integer year, Integer season,String startDate,String endDate){
ProductDataVO productDataVO = new ProductDataVO();//返回结果
if(year != null ){
ProductDataVO productDataVO = new ProductDataVO(year,season,startDate,endDate);//返回结果
/* if(year != null ){ //前端传递
int lastYear = year - 1;//去年
productDataVO.setLastYear(lastYear);
productDataVO.setYear( year );
......@@ -64,7 +64,10 @@ public class OperationReportServiceImpl implements IOperationReportService {
}
if(StringUtils.isNotEmpty(endDate)){
productDataVO.setEndTime( endDate);//结束时间
}
}*/
String startMonth = DateUtils.formatDate(productDataVO.getStartTime(),"yyyy-MM");//开始月份
String endMonth = DateUtils.formatDate(productDataVO.getEndTime(),"yyyy-MM");//结束月份
//水务公司总数
String sql = "select count(1) from sys_depart where depart_type = 1 and id in ("+JSUtils.quoteEach(departId,",")+")";
......@@ -87,6 +90,8 @@ public class OperationReportServiceImpl implements IOperationReportService {
productDataVO.setChargeWaterVolume( ysfsl ); //收费水量
productDataVO.setYsjslWaterVolume(ysjsl );//实际处理水量
}
//目标水量
sql = "select sum(ifnull(target_water,0)) target_water from report_target_config where 1=1 ";
if(StringUtils.isNotEmpty(departId)){
......@@ -117,7 +122,7 @@ public class OperationReportServiceImpl implements IOperationReportService {
productDataVO.setYsjslWaterRatio( JSUtils.executeExpression(expression,"0"));//实际处理水量--同比增长
/***************** 实际水量同比下降水务公司原因分析一览表************************/
dataViewName4411 = ReportViewUtil.buildView(ReportConstant.view4411,"ysjsl,tqysjsl,ysjsldyqntqyy", departId, productDataVO.getStartTime(), productDataVO.getEndTime());
dataViewName4411 = ReportViewUtil.buildView(ReportConstant.view4411,"ysjsl,tqysjsl,ysjsldyqntqyy", departId, startMonth,endMonth);
sql = " select aaa.depart_id , d.depart_name departName, round(100*(sum(ifnull(aaa.ysjsl,0)) - sum(ifnull(aaa.tqysjsl,0)) )/ sum(ifnull(aaa.tqysjsl,0)),2) 'ratio', ";
sql += " round( sum(ifnull(aaa.ysjsl,0)),2 ) 'ysjsl' ,round( sum(ifnull(aaa.tqysjsl,0)),2 ) 'tqysjsl' ,GROUP_CONCAT(aaa.ysjsldyqntqyy SEPARATOR '') 'causeAnalysis' from "+ dataViewName4411+" aaa";
sql += " left join sys_depart d on d.id = aaa.depart_id";
......@@ -125,19 +130,19 @@ public class OperationReportServiceImpl implements IOperationReportService {
List<FReportWaterMonthDataVO> waterMonthDataList = getJdbcTemplate().query(sql,new BeanPropertyRowMapper<FReportWaterMonthDataVO>(FReportWaterMonthDataVO.class));
productDataVO.setWaterDeptartList(waterMonthDataList);
//水电耗高于控制目标--水务公司列表
dataViewName4411 = ReportViewUtil.buildView(ReportConstant.view4411,"ydh,dhcmbzyy", departId, productDataVO.getStartTime(), productDataVO.getEndTime());
//水电耗高于控制目标--水务公司列表 YYYY-MM
dataViewName4411 = ReportViewUtil.buildView(ReportConstant.view4411,"ydh,dhcmbzyy", departId, startMonth,endMonth);
sql = "select * from ( ";
sql += " select d.depart_name 'departName', aaa.depart_id , round(avg(aaa.ydh),2) realConsume , IFNULL(tc.target_power,2) 'targetConsume' ,GROUP_CONCAT(aaa.dhcmbzyy SEPARATOR '') 'causeAnalysis' from "+ dataViewName4411+" aaa";;
sql += " left join report_target_config tc on (tc.depart_id = aaa.depart_id and tc.target_year='2024')";
sql += " left join report_target_config tc on (tc.depart_id = aaa.depart_id and tc.target_year='2024')";
sql += " left join sys_depart d on d.id = aaa.depart_id ";
sql += " group by aaa.depart_id )bbb where bbb.realConsume > bbb.targetConsume ";
List<FReportPowerMonthDataVO> dhMonthDataList = getJdbcTemplate().query(sql,new BeanPropertyRowMapper<FReportPowerMonthDataVO>(FReportPowerMonthDataVO.class));
productDataVO.setPowerDeptartList(dhMonthDataList);
/** ysjsl:月实际水量 ; 月药耗 yyh; 去年同期药耗 qntqyh; 月药费 yyf;药耗高于去年同期原因 yhgyqntqyy;药耗超预期原因 yhcyqyy; 本年实际药耗 bnsjyh; 本年药耗目标 bnyhmb*/
//药剂成本高于控制目标--水务公司列表
dataViewName4411 = ReportViewUtil.buildView(ReportConstant.view4411,"yyh,yhcyqyy", departId, productDataVO.getStartTime(), productDataVO.getEndTime());
//药剂成本高于控制目标--水务公司列表 YYYY-MM
dataViewName4411 = ReportViewUtil.buildView(ReportConstant.view4411,"yyh,yhcyqyy", departId, startMonth,endMonth);
sql = "select * from ( ";
sql += " select d.depart_name 'departName', aaa.depart_id , round(avg(aaa.yyh),2) realConsume , IFNULL(tc.target_drug,2) 'targetConsume' ,GROUP_CONCAT(aaa.yhcyqyy SEPARATOR '') 'causeAnalysis' from "+ dataViewName4411+" aaa";;
sql += " left join report_target_config tc on (tc.depart_id = aaa.depart_id and tc.target_year='2024')";
......
......@@ -166,7 +166,8 @@ public class EquipmentInfoMonthReportController {
String plan_cost = commonSqlService.queryForString(sql);
dataMap.put("planCost",plan_cost);//月度计划维修费合计XX万元
//执行XX万元
sql = "select round(ifnull(sum(total_cost),0)/10000,2) 'repair_cost' from equipment_repair where reality_maintenance_end_time >= '"+startDate+" 00:00:00' and reality_maintenance_end_time <='"+endDate+" 23:59:59'";
// sql = "select round(ifnull(sum(total_cost),0)/10000,2) 'repair_cost' from equipment_repair where reality_maintenance_end_time >= '"+startDate+" 00:00:00' and reality_maintenance_end_time <='"+endDate+" 23:59:59'";
sql = "select round(ifnull(sum(maintenance_cost),0)/10000,2) 'repair_cost' from equipment_maintain_task where real_end_time >= '"+startDate+" 00:00:00' and real_end_time <='"+endDate+" 23:59:59'";
String repair_cost = commonSqlService.queryForString(sql);
dataMap.put("repairCost",repair_cost);//执行XX万元
String expression = "100 * "+ repair_cost +" /"+plan_cost;
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!