Browse Source

天气调用IOT平台天气查询接口

develop
bobol 6 months ago
parent
commit
13c17e7ec8
  1. 8
      lzbi-admin/src/main/resources/application-test.yml
  2. 4
      lzbi-common/src/main/java/com/lzbi/common/config/IotServerApiConfig.java
  3. 21
      lzbi-module/src/main/java/com/lzbi/asset/domain/dto/ChargeSystemDTO.java
  4. 74
      lzbi-module/src/main/java/com/lzbi/asset/service/ChargeSystemService.java
  5. 63
      lzbi-module/src/main/java/com/lzbi/bi/controller/DcBusiDataScreenMainController.java
  6. 83
      lzbi-module/src/main/java/com/lzbi/bi/service/DcBusiDataScreenMainService.java
  7. 37
      lzbi-module/src/main/resources/mapper/DcBusiDataScreenMainMapper.xml

8
lzbi-admin/src/main/resources/application-test.yml

@ -177,7 +177,7 @@ wechat:
# 外部服务
goal-server:
# iot平台服务地址
iot: http://localhost:9010
iot: http://10.10.10.56:9010
magic: http://10.10.10.56:9012/magic/api
# 巡检系统服务
patrol: http://10.10.10.22:16882
@ -202,8 +202,12 @@ iot-server-api:
updateUser: ${goal-server.iot}/interior/sign/system/user
# 删除用户
deleteUser: ${goal-server.iot}/interior/sign/system/user
# 获取天气
weather: ${goal-server.iot}/biz/common/weather/oneLast
# magic api
#
# 获取部门列表magic api
magic-server-api:
# 获取收费系统参数
chargeSystemParams: ${goal-server.magic}/charge/sqaure

4
lzbi-common/src/main/java/com/lzbi/common/config/IotServerApiConfig.java

@ -41,5 +41,9 @@ public class IotServerApiConfig {
* 删除用户
*/
private String deleteUser;
/**
* 天气
*/
private String weather;
}

21
lzbi-module/src/main/java/com/lzbi/asset/domain/dto/ChargeSystemDTO.java

@ -0,0 +1,21 @@
package com.lzbi.asset.domain.dto;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class ChargeSystemDTO {
private String GUANLIDANWEI;
private String REYUAN;
private String HUANREZHAN;
private String HUANREZHANID;
private BigDecimal GONGNUANMIANJI;
private BigDecimal KAISHUANYIZHIXING;
}

74
lzbi-module/src/main/java/com/lzbi/asset/service/ChargeSystemService.java

@ -6,6 +6,7 @@ import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.lzbi.asset.domain.ChargeSystemParamsDTO;
import com.lzbi.asset.domain.DcBaseAssetContrastConfig;
import com.lzbi.asset.domain.dto.ChargeSystemDTO;
import com.lzbi.asset.mapper.DcBaseAssetContrastConfigMapper;
import com.lzbi.code.domain.DcBaseCoderuleDefineDao;
import com.lzbi.code.domain.DcBusiCoderuleConfigDao;
@ -28,14 +29,12 @@ import org.springframework.util.CollectionUtils;
import org.springframework.web.client.RestTemplate;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.time.Duration;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -89,8 +88,8 @@ public class ChargeSystemService {
Integer code = jsonObject.getInteger("code");
if (1 == code) {
JSONArray jsonArray = jsonObject.getJSONArray("data");
// new Thread(() -> parseData(jsonArray)).start();
if (!CollectionUtils.isEmpty(jsonArray)) {
log.info("收费系统换热站参数:{}", jsonArray.toJSONString());
this.createParamBill(jsonArray);
}
} else {
@ -101,6 +100,71 @@ public class ChargeSystemService {
}
}
private void parseData(JSONArray data) {
if (CollectionUtils.isEmpty(data)) {
log.error("收费系统返回数据为空");
return;
}
List<ChargeSystemDTO> chargeSystemDTOList = JSONArray.parseArray(data.toJSONString(), ChargeSystemDTO.class);
Iterator<ChargeSystemDTO> iterator = chargeSystemDTOList.iterator();
while (iterator.hasNext()) {
ChargeSystemDTO chargeSystemDTO = iterator.next();
String guanlidanwei = chargeSystemDTO.getGUANLIDANWEI();
String reyuan = chargeSystemDTO.getREYUAN();
if (StringUtils.isNotBlank(guanlidanwei) && StringUtils.isNotBlank(reyuan)) {
String[] split = guanlidanwei.split(">");
chargeSystemDTO.setGUANLIDANWEI(split[0]);
} else {
iterator.remove();
}
}
JSONArray jituanArray = new JSONArray();
JSONObject jituanObject = new JSONObject();
jituanObject.put("name", "集团");
BigDecimal jituanGongnuanmianjiSum = new BigDecimal(0D);
BigDecimal jituanKaisuanyizhixingmianjiSum = new BigDecimal(0D);
JSONArray guanlidanweiArray = new JSONArray();
Map<String, List<ChargeSystemDTO>> guanlidanweiGroupMap = chargeSystemDTOList.stream().collect(Collectors.groupingBy(ChargeSystemDTO::getGUANLIDANWEI));
Set<String> guanlidanweiSet = guanlidanweiGroupMap.keySet();
for (String guanlidanwei : guanlidanweiSet) {
List<ChargeSystemDTO> guanlidanweiList = guanlidanweiGroupMap.get(guanlidanwei);
JSONObject guanlidanweiObject = new JSONObject();
guanlidanweiObject.put("name", guanlidanwei);
JSONArray reyuanArray = new JSONArray();
BigDecimal guanlidanweiGongnuanmianjiSum = new BigDecimal(0D);
BigDecimal guanlidanweiKaisuanyizhixingmianjiSum = new BigDecimal(0D);
Map<String, List<ChargeSystemDTO>> reyuanGroupMap = guanlidanweiList.stream().collect(Collectors.groupingBy(ChargeSystemDTO::getREYUAN));
Set<String> reyuanSet = reyuanGroupMap.keySet();
for (String reyuan : reyuanSet) {
List<ChargeSystemDTO> reyuanList = reyuanGroupMap.get(reyuan);
JSONObject reyuanObject = new JSONObject();
reyuanObject.put("name", reyuan);
BigDecimal reyuanGongnuanmianjiSum = new BigDecimal(0);
BigDecimal reyuanKaisuanyizhixingmianjiSum = new BigDecimal(0);
for (ChargeSystemDTO chargeSystemDTO : reyuanList) {
reyuanGongnuanmianjiSum = reyuanGongnuanmianjiSum.add(chargeSystemDTO.getGONGNUANMIANJI());
reyuanKaisuanyizhixingmianjiSum = reyuanKaisuanyizhixingmianjiSum.add(chargeSystemDTO.getKAISHUANYIZHIXING());
}
guanlidanweiGongnuanmianjiSum = guanlidanweiGongnuanmianjiSum.add(reyuanGongnuanmianjiSum);
guanlidanweiKaisuanyizhixingmianjiSum = guanlidanweiKaisuanyizhixingmianjiSum.add(reyuanKaisuanyizhixingmianjiSum);
reyuanObject.put("gongnuanmianji", reyuanGongnuanmianjiSum);
reyuanObject.put("kaishuanyizhixingmianji", reyuanKaisuanyizhixingmianjiSum);
reyuanArray.add(reyuanObject);
}
guanlidanweiObject.put("gongnuanmianji", guanlidanweiGongnuanmianjiSum);
guanlidanweiObject.put("kaishuanyizhixingmianji", guanlidanweiKaisuanyizhixingmianjiSum);
guanlidanweiObject.put("children", reyuanArray);
guanlidanweiArray.add(guanlidanweiObject);
jituanGongnuanmianjiSum = jituanGongnuanmianjiSum.add(guanlidanweiGongnuanmianjiSum);
jituanKaisuanyizhixingmianjiSum = jituanKaisuanyizhixingmianjiSum.add(guanlidanweiKaisuanyizhixingmianjiSum);
}
jituanObject.put("gongnuanmianji", jituanGongnuanmianjiSum);
jituanObject.put("kaishuanyizhixingmianji", jituanKaisuanyizhixingmianjiSum);
jituanObject.put("children", guanlidanweiArray);
jituanArray.add(jituanObject);
log.info("收费系统返回数据:{}", jituanArray.toJSONString());
}
private void createParamBill(JSONArray jsonArray) {
LocalDateTime localDateTime = LocalDateTime.now();
int hour = localDateTime.getHour();

63
lzbi-module/src/main/java/com/lzbi/bi/controller/DcBusiDataScreenMainController.java

@ -1,27 +1,23 @@
package com.lzbi.bi.controller;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.lzbi.bi.domain.req.ReportDataReq;
import com.lzbi.bi.service.DcBusiDataScreenMainService;
import com.lzbi.common.config.IotServerApiConfig;
import com.lzbi.common.core.controller.BaseController;
import com.lzbi.common.core.domain.AjaxResult;
import com.lzbi.common.core.domain.TreeSelect;
import com.lzbi.common.core.domain.entity.SysDept;
import com.lzbi.bi.domain.req.ReportDataReq;
import com.lzbi.system.service.impl.SysDeptServiceImpl;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.lang.Nullable;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;
import java.util.List;
import java.util.Optional;
/**
* 主数据大屏的页面接口
@ -41,6 +37,12 @@ public class DcBusiDataScreenMainController extends BaseController {
@Autowired
private SysDeptServiceImpl sysDeptService;
@Autowired
private IotServerApiConfig iotServerApiConfig;
@Autowired
private RestTemplate restTemplate;
/**
* 获取某个组织某天的某个图表数据
*
@ -151,52 +153,9 @@ public class DcBusiDataScreenMainController extends BaseController {
return AjaxResult.success(dcBusiDataScreenMainService.selectSomeReportDataRankingList(reportDataReq));
}
/**
* 获取天气信息
*/
@Value("${luenmeilz.baiduWeatherURL}")
String weatherUrl;
@Value("${luenmeilz.baiduWeatherAK}")
String weathAK;
@Value("${luenmeilz.yikeapiAppid}")
String yikeapiAppid;
@Value("${luenmeilz.yikeapiAppsecret}")
String yikeapiAppsecret;
@GetMapping("/weather/{areaCode}")
public AjaxResult getWeather(@PathVariable String areaCode) {
JSONObject ret = new JSONObject();
String url = StrUtil.format("https://v1.yiketianqi.com/free/week?city=沈阳&unescape=1&appid={}&appsecret={}", yikeapiAppid, yikeapiAppsecret);
JSONObject weather = JSONObject.parseObject(HttpUtil.get(url));
log.debug("天气接口返回数据:{}", weather);
JSONArray weatherInfo = Optional.ofNullable(weather.getJSONArray("data")).orElse(new JSONArray());
if (null != weatherInfo && !weatherInfo.isEmpty()) {
JSONArray we_date = new JSONArray();
JSONArray we_name = new JSONArray();
JSONArray tem_day = new JSONArray();
JSONArray tem_night = new JSONArray();
we_date.add("天气日期:");
we_name.add("天气情况:");
tem_day.add("日间气温:");
tem_night.add("夜间气温:");
weatherInfo.forEach(item -> {
JSONObject jsb = JSONObject.from(item);
we_date.add(jsb.getString("date"));
tem_day.add(jsb.getString("tem_day"));
tem_night.add(jsb.getString("tem_night"));
we_name.add(jsb.getString("wea"));
});
JSONArray list = new JSONArray();
list.add(we_date);
list.add(tem_day);
list.add(tem_night);
list.add(we_name);
ret.put("source", list);
ret.put("realwe", weatherInfo.get(0));
} else {
log.error("天气接口未返回数据");
}
return AjaxResult.success(ret);
public JSONObject getWeather(@PathVariable String areaCode) {
return restTemplate.getForObject(iotServerApiConfig.getWeather(), JSONObject.class, areaCode);
}
@PostMapping("/mapInfo")

83
lzbi-module/src/main/java/com/lzbi/bi/service/DcBusiDataScreenMainService.java

@ -9,20 +9,18 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lzbi.bi.domain.DcBusiDataScreenDto;
import com.lzbi.bi.domain.SysDeptLocation;
import com.lzbi.bi.domain.dto.MultiOrgSomeReportEverydayData;
import com.lzbi.bi.domain.dto.SomeOrgSomedaySomeParamSummarizingDataDTO;
import com.lzbi.bi.domain.dto.SomeOrgSomedayMultiReportDataDTO;
import com.lzbi.bi.domain.dto.SomeTypeChildrenOrgSomedayMultiReportDataDTO;
import com.lzbi.bi.domain.req.ParamSummarizingDataReq;
import com.lzbi.bi.domain.req.ReportDataReq;
import com.lzbi.bi.domain.vo.*;
import com.lzbi.bi.mapper.DcBusiDataScreenMainMapper;
import com.lzbi.bi.mapper.ScreenMockDataMapper;
import com.lzbi.common.constant.BizConstants;
import com.lzbi.common.constant.ParamsModelCodeConstants;
import com.lzbi.common.core.domain.entity.SysDept;
import com.lzbi.common.enums.ReportNameEnum;
import com.lzbi.bi.domain.dto.SomeOrgSomedayMultiReportDataDTO;
import com.lzbi.bi.domain.dto.SomeTypeChildrenOrgSomedayMultiReportDataDTO;
import com.lzbi.bi.domain.req.ReportDataReq;
import com.lzbi.common.utils.bean.BeanUtils;
import com.lzbi.draft.domain.vo.*;
import com.lzbi.draft.domain.vo.TargetDraftDaynewResVo;
import com.lzbi.draft.service.DcBusiTargetDraftDaynewService;
import com.lzbi.system.service.ISysDeptService;
import lombok.extern.slf4j.Slf4j;
@ -35,7 +33,9 @@ import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@ -87,12 +87,12 @@ public class DcBusiDataScreenMainService extends ServiceImpl<DcBusiDataScreenMai
static {
SPECIAL_REPORT_LIST = new ArrayList<>();
SPECIAL_REPORT_LIST.add(GRMJ);
SPECIAL_REPORT_LIST.add(LWMJ);
// SPECIAL_REPORT_LIST.add(GRMJ);
// SPECIAL_REPORT_LIST.add(LWMJ);
SPECIAL_REPORT_LIST.add(AQGR);
SPECIAL_REPORT_LIST.add(RY);
SPECIAL_REPORT_LIST.add(HRZ);
SPECIAL_REPORT_LIST.add(ZMJ);
// SPECIAL_REPORT_LIST.add(ZMJ);
}
/**
@ -100,16 +100,31 @@ public class DcBusiDataScreenMainService extends ServiceImpl<DcBusiDataScreenMai
* @param reportDataReq
* @return
*/
public SomeOrgSomedaySomeReportDataVO selectSomeOrgSomedaySomeReportData(ReportDataReq reportDataReq) {
public JSONObject selectSomeOrgSomedaySomeReportData(ReportDataReq reportDataReq) {
this.buildReportDataReq(reportDataReq);
SomeOrgSomedaySomeReportDataVO someOrgSomedaySomeReportDataVO;
if (SPECIAL_REPORT_LIST.contains(reportDataReq.getReportName())) {
return this.selectSpecialReportData(reportDataReq);
someOrgSomedaySomeReportDataVO = this.selectSpecialReportData(reportDataReq);
} else {
return baseMapper.selectSomeOrgSomedaySomeReportData(reportDataReq);
someOrgSomedaySomeReportDataVO = baseMapper.selectSomeOrgSomedaySomeReportData(reportDataReq);
}
if (null != someOrgSomedaySomeReportDataVO) {
log.info("结果:{}", someOrgSomedaySomeReportDataVO.toString());
JSONObject result = new JSONObject();
BigDecimal valueResult = someOrgSomedaySomeReportDataVO.getValueResult();
BigDecimal valuePlan = someOrgSomedaySomeReportDataVO.getValuePlan();
if (null != valueResult) {
result.put("valueResult", someOrgSomedaySomeReportDataVO.getValueResult().toPlainString());
}
if (null != valuePlan) {
result.put("valuePlan", someOrgSomedaySomeReportDataVO.getValuePlan().toPlainString());
}
return result;
}
return null;
}
public SomeOrgSomedaySomeReportDataVO selectSpecialReportData(ReportDataReq reportDataReq) {
private SomeOrgSomedaySomeReportDataVO selectSpecialReportData(ReportDataReq reportDataReq) {
ParamSummarizingDataReq paramSummarizingDataReq = new ParamSummarizingDataReq();
BeanUtils.copyBeanProp(paramSummarizingDataReq, reportDataReq);
BigDecimal value = null;
@ -172,13 +187,18 @@ public class DcBusiDataScreenMainService extends ServiceImpl<DcBusiDataScreenMai
*/
public List<ChildrenOrgSomedaySomeReportDataVO> selectChildrenOrgSomedaySomeReportDataList(ReportDataReq reportDataReq) {
this.buildChildrenOrgReportDataReq(reportDataReq);
return baseMapper.selectChildrenOrgSomedaySomeReportDataList(reportDataReq);
List<ChildrenOrgSomedaySomeReportDataVO> result = baseMapper.selectChildrenOrgSomedaySomeReportDataList(reportDataReq);
if (CollectionUtils.isEmpty(result)) {
return null;
}
return result;
}
public List<JSONArray> selectChildrenOrgSomedaySomeReportDataEchart(ReportDataReq reportDataReq) {
List<JSONArray> result = new ArrayList<>();
List<JSONArray> result = null;
List<ChildrenOrgSomedaySomeReportDataVO> data = this.selectChildrenOrgSomedaySomeReportDataList(reportDataReq);
if (!CollectionUtils.isEmpty(data)) {
result = new ArrayList<>();
JSONArray head = new JSONArray();
head.add("name");
JSONArray body = new JSONArray();
@ -194,9 +214,10 @@ public class DcBusiDataScreenMainService extends ServiceImpl<DcBusiDataScreenMai
}
public List<JSONArray> selectChildrenOrgSomedaySomeReportDataEchartHaveOrgId(ReportDataReq reportDataReq) {
List<JSONArray> result = new ArrayList<>();
List<JSONArray> result = null;
List<ChildrenOrgSomedaySomeReportDataVO> data = this.selectChildrenOrgSomedaySomeReportDataList(reportDataReq);
if (!CollectionUtils.isEmpty(data)) {
result = new ArrayList<>();
JSONArray head = new JSONArray();
head.add("name");
JSONArray body = new JSONArray();
@ -216,9 +237,10 @@ public class DcBusiDataScreenMainService extends ServiceImpl<DcBusiDataScreenMai
}
public List<JSONArray> selectChildrenOrgSomedaySomeReportDataEchartStacking(ReportDataReq reportDataReq) {
List<JSONArray> result = new ArrayList<>();
List<JSONArray> result = null;
List<ChildrenOrgSomedaySomeReportDataVO> data = this.selectChildrenOrgSomedaySomeReportDataList(reportDataReq);
if (!CollectionUtils.isEmpty(data)) {;
if (!CollectionUtils.isEmpty(data)) {
result = new ArrayList<>();
JSONArray head = new JSONArray();
head.add("name");
result.add(head);
@ -247,13 +269,14 @@ public class DcBusiDataScreenMainService extends ServiceImpl<DcBusiDataScreenMai
if (!CollectionUtils.isEmpty(someOrgSomedayMultiReportDataDTOS)) {
return JSONArray.parseArray(JSONArray.toJSONString(someOrgSomedayMultiReportDataDTOS), SomeOrgSomedayMultiReportDataVO.class);
}
return new ArrayList<>();
return null;
}
public List<JSONArray> selectChildrenOrgSomedayMultiReportDataBar(ReportDataReq reportDataReq) {
List<JSONArray> result = new ArrayList<>();
List<JSONArray> result;
List<SomeTypeChildrenOrgSomedayMultiReportDataDTO> data = this.selectSomeTypeChildrenOrgSomedayMultiReportDataDTOList(reportDataReq);
if (!CollectionUtils.isEmpty(data)) {
result = new ArrayList<>();
List<String> reportNames = reportDataReq.getReportNames();
JSONArray head = new JSONArray();
head.add("name");
@ -271,15 +294,18 @@ public class DcBusiDataScreenMainService extends ServiceImpl<DcBusiDataScreenMai
result.get(i).add(reportNameValueMap.get(String.valueOf(result.get(i).get(0))));
}
});
} else {
result = null;
}
return result;
}
public List<JSONArray> selectSomeOrgSomeMultiReportYearlyDataMultiEchart(ReportDataReq reportDataReq) {
List<JSONArray> result = new ArrayList<>();
List<JSONArray> result;
List<String> reportNames = reportDataReq.getReportNames();
List<SomeOrgSomeReportYearlyDataVO> data = this.selectSomeOrgSomeReportYearlyDataList(reportDataReq);
if (!CollectionUtils.isEmpty(data)) {
result = new ArrayList<>();
JSONArray head = new JSONArray();
head.add("name");
result.add(head);
@ -300,22 +326,29 @@ public class DcBusiDataScreenMainService extends ServiceImpl<DcBusiDataScreenMai
}
}
});
} else {
result = null;
}
return result;
}
public List<MapOrgVO> selectMapOrgList(ReportDataReq reportDataReq) {
this.buildChildrenOrgReportDataReq(reportDataReq);
return baseMapper.selectMapOrgList(reportDataReq);
List<MapOrgVO> result = baseMapper.selectMapOrgList(reportDataReq);
if (CollectionUtils.isEmpty(result)) {
return null;
}
return result;
}
public List<SomeReportDataRankingVO> selectSomeReportDataRankingList(ReportDataReq reportDataReq) {
List<SomeReportDataRankingVO> result = new ArrayList<>();
List<SomeReportDataRankingVO> result;
this.buildChildrenOrgReportDataReq(reportDataReq);
this.buildHeatingDate(reportDataReq);
List<MultiOrgSomeReportEverydayData> data = baseMapper.selectChildOrgSomeReportEverydayDataList(reportDataReq);
log.info("排名数据:{}", JSONArray.toJSONString(data));
if (!CollectionUtils.isEmpty(data)) {
result = new ArrayList<>();
// 排序后的日期列表
List<String> dateSoredList = data.stream().map(MultiOrgSomeReportEverydayData::getDate).collect(Collectors.toSet()).stream().sorted().collect(Collectors.toList());
// 排序后的组织id列表
@ -343,6 +376,8 @@ public class DcBusiDataScreenMainService extends ServiceImpl<DcBusiDataScreenMai
someReportDataRankingVO.setCut(StringUtils.join(valueList, ","));
result.add(someReportDataRankingVO);
});
} else {
result = null;
}
return result;
}

37
lzbi-module/src/main/resources/mapper/DcBusiDataScreenMainMapper.xml

@ -318,8 +318,8 @@
parameterType="com.lzbi.bi.domain.req.ReportDataReq"
resultType="com.lzbi.bi.domain.vo.SomeOrgSomedaySomeReportDataVO">
SELECT
t1.value_result,
t1.value_plan
concat(t1.value_result, '') AS "valueResult",
concat(t1.value_plan, '') AS "valuePlan"
FROM
dc_busi_target_draft_daynew t1
INNER JOIN dc_base_asset_target t2 ON t1.target_code = t2.target_code
@ -341,7 +341,8 @@
SELECT
t5.dept_id as "orgId",
t5.dept_name as "orgName",
t1.value_result
t1.value_result,
t1.value_plan
FROM
dc_busi_target_draft_daynew t1
INNER JOIN dc_base_asset_target t2 ON t1.target_code = t2.target_code
@ -454,28 +455,28 @@
tt.number
FROM
sys_dept t
LEFT JOIN (
LEFT JOIN (
SELECT
t5.dept_id,
SUM( t1.val_last ) as "number"
t4.dept_id,
t1.value_result AS "number"
FROM
dc_busi_param_draft_day t1
INNER JOIN dc_base_asset_target t2 ON t1.param_code = t2.target_code
AND t2.column_type = "P"
AND t2.target_model_code = "P00001"
dc_busi_target_draft_daynew t1
INNER JOIN dc_base_asset_target t2 ON t1.target_code = t2.target_code
AND t2.column_type = "T"
AND t2.target_model_code = "00086"
INNER JOIN dc_base_asset_info t3 ON t2.asset_code = t3.asset_code
INNER JOIN sys_dept t4 ON t3.org_id = t4.dept_id
AND t3.asset_level = "30"
AND t3.asset_type = "1"
INNER JOIN sys_dept t5 ON FIND_IN_SET( t5.dept_id, concat( t4.ancestors, ",", t4.dept_id ) )
AND t3.asset_level = #{assetLevel}
AND t3.asset_type = #{assetType}
WHERE
t5.parent_id = #{orgId}
AND t1.count_date = CONCAT( #{dateYear}, '-', #{dateMonth}, '-', #{dateDay} )
GROUP BY
t5.dept_id
FIND_IN_SET( #{orgId}, concat( t4.ancestors ) )
AND t4.org_type = #{orgType}
AND t1.date_year = #{dateYear}
AND t1.date_month = #{dateMonth}
AND t1.date_day = #{dateDay}
) tt ON t.dept_id = tt.dept_id
WHERE
t.parent_id = #{orgId}
FIND_IN_SET( #{orgId}, concat( t.ancestors ) )
AND t.org_type = #{orgType}
</select>

Loading…
Cancel
Save