Browse Source

1、对外接口

develop
bobol 9 months ago
parent
commit
7a39f4360f
  1. 1
      lzbi-framework/src/main/java/com/lzbi/framework/config/SecurityConfig.java
  2. 18
      lzbi-module/src/main/java/com/lzbi/draft/mapper/DcBusiParamDraftDayMapper.java
  3. 34
      lzbi-module/src/main/java/com/lzbi/external/controller/ParamsController.java
  4. 37
      lzbi-module/src/main/java/com/lzbi/external/service/ParamsService.java
  5. 2
      lzbi-module/src/main/java/com/lzbi/task/TaskParamDfratProcess.java
  6. 39
      lzbi-module/src/main/resources/mapper/asset/DcBusiParamDraftDayMapper.xml

1
lzbi-framework/src/main/java/com/lzbi/framework/config/SecurityConfig.java

@ -116,6 +116,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
.antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll() .antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll()
.antMatchers( "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll() .antMatchers( "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll()
.antMatchers("/wechat/biz/login/**").permitAll() .antMatchers("/wechat/biz/login/**").permitAll()
.antMatchers("/external/**").permitAll()
// 除上面外的所有请求全部需要鉴权认证 // 除上面外的所有请求全部需要鉴权认证
.anyRequest().authenticated() .anyRequest().authenticated()
.and() .and()

18
lzbi-module/src/main/java/com/lzbi/draft/mapper/DcBusiParamDraftDayMapper.java

@ -4,6 +4,7 @@ import java.util.List;
import com.lzbi.draft.domain.DcBusiParamDraftDay; import com.lzbi.draft.domain.DcBusiParamDraftDay;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lzbi.draft.domain.ParamDraftQueryVo; import com.lzbi.draft.domain.ParamDraftQueryVo;
import org.apache.ibatis.annotations.Param;
/** /**
* 参数数据底稿Mapper接口 * 参数数据底稿Mapper接口
@ -23,6 +24,23 @@ public interface DcBusiParamDraftDayMapper extends BaseMapper<DcBusiParamDraftDa
public DcBusiParamDraftDay selectDcBusiParamDraftDayById(String id); public DcBusiParamDraftDay selectDcBusiParamDraftDayById(String id);
public DcBusiParamDraftDay selectOneByParam(DcBusiParamDraftDay queryVo); public DcBusiParamDraftDay selectOneByParam(DcBusiParamDraftDay queryVo);
/**
* 查询最后一天的参数底稿
* @param assetCode
* @param paramsModelCode
* @return
*/
DcBusiParamDraftDay selectLastDataByAssetCodeAndParamsModelCode(@Param("assetCode") String assetCode,
@Param("paramsModelCode") String paramsModelCode);
/**
* 查询最后一天的参数底稿
* @param assetCodeList
* @param paramsModelCode
* @return
*/
List<DcBusiParamDraftDay> selectLastDataByAssetCodeListAndParamsModelCode(@Param("assetCodeList") List<String> assetCodeList,
@Param("paramsModelCode") String paramsModelCode);
/** /**
* 查询参数数据底稿列表 * 查询参数数据底稿列表
* *

34
lzbi-module/src/main/java/com/lzbi/external/controller/ParamsController.java

@ -0,0 +1,34 @@
package com.lzbi.external.controller;
import com.lzbi.common.core.domain.AjaxResult;
import com.lzbi.external.service.ParamsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RequestMapping("/external/params")
@RestController
public class ParamsController {
@Autowired
private ParamsService paramsService;
/**
* 获取供热面积
* @return
*/
@GetMapping("/heat-supply-area/singleAsset")
public AjaxResult getHeatSupplyArea(@RequestParam(value = "assetCode") String assetCode) {
return AjaxResult.success(paramsService.getHeatSupplyArea(assetCode));
}
/**
* 获取供气面积
* @return
*/
@PostMapping("/heat-supply-area/multipleAsset")
public AjaxResult getGasSupplyArea(@RequestBody List<String> assetCodeList) {
return AjaxResult.success(paramsService.getGasSupplyArea(assetCodeList));
}
}

37
lzbi-module/src/main/java/com/lzbi/external/service/ParamsService.java

@ -0,0 +1,37 @@
package com.lzbi.external.service;
import com.lzbi.common.constant.ParamsModelCodeConstants;
import com.lzbi.draft.domain.DcBusiParamDraftDay;
import com.lzbi.draft.mapper.DcBusiParamDraftDayMapper;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service
public class ParamsService {
@Resource
private DcBusiParamDraftDayMapper dcBusiParamDraftDayMapper;
public Double getHeatSupplyArea(String assetCode) {
DcBusiParamDraftDay dcBusiParamDraftDay = dcBusiParamDraftDayMapper.selectLastDataByAssetCodeAndParamsModelCode(assetCode, ParamsModelCodeConstants.供暖面积);
return dcBusiParamDraftDay.getValLast();
}
public Map<String, Double> getGasSupplyArea(List<String> assetCodeList) {
if (CollectionUtils.isEmpty(assetCodeList)) {
throw new RuntimeException("资产编码列表不能为空");
}
List<DcBusiParamDraftDay> list = dcBusiParamDraftDayMapper.selectLastDataByAssetCodeListAndParamsModelCode(assetCodeList, ParamsModelCodeConstants.供暖面积);
if (CollectionUtils.isEmpty(list)) {
throw new RuntimeException("暂无数据");
}
Map<String, Double> map = list.stream().collect(Collectors.toMap(DcBusiParamDraftDay::getAssetCode, DcBusiParamDraftDay::getValLast));
return map;
}
}

2
lzbi-module/src/main/java/com/lzbi/task/TaskParamDfratProcess.java

@ -78,7 +78,7 @@ public class TaskParamDfratProcess {
public void doBills() { public void doBills() {
DcBusiParamBillMaster dcBusiParamBillMasterDao = new DcBusiParamBillMaster(); DcBusiParamBillMaster dcBusiParamBillMasterDao = new DcBusiParamBillMaster();
dcBusiParamBillMasterDao.setCheckStatus("1"); dcBusiParamBillMasterDao.setCheckStatus("0");
List<DcBusiParamBillMaster> dcBusiParamBillMasterDaos = dcBusiParamBillMasterService.selectDcBusiParamBillMasterDaoList(dcBusiParamBillMasterDao); List<DcBusiParamBillMaster> dcBusiParamBillMasterDaos = dcBusiParamBillMasterService.selectDcBusiParamBillMasterDaoList(dcBusiParamBillMasterDao);
dcBusiParamBillMasterDaos.forEach(item -> { dcBusiParamBillMasterDaos.forEach(item -> {
doBill(item); doBill(item);

39
lzbi-module/src/main/resources/mapper/asset/DcBusiParamDraftDayMapper.xml

@ -98,6 +98,45 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where> </where>
</select> </select>
<select id="selectLastDataByAssetCodeAndParamsModelCode" parameterType="String" resultMap="DcBusiParamDraftDayResult">
SELECT
t1.*
FROM
`dc_busi_param_draft_day` t1
INNER JOIN dc_base_asset_target t2 ON t1.param_code = t2.target_code
WHERE
t2.target_model_code = #{paramsModelCode}
AND t2.asset_code = #{assetCode}
AND t2.column_type = "P"
ORDER BY
t1.count_date DESC
LIMIT 1
</select>
<select id="selectLastDataByAssetCodeListAndParamsModelCode" resultMap="DcBusiParamDraftDayResult">
SELECT
t.*
FROM
dc_busi_param_draft_day t
INNER JOIN (
SELECT
max( t1.id ) AS id
FROM
dc_busi_param_draft_day t1
INNER JOIN dc_base_asset_target t2 ON t1.param_code = t2.target_code
WHERE
t2.target_model_code = #{paramsModelCode}
AND t2.asset_code IN
<foreach collection="assetCodeList" item="assetCode" open="(" separator="," close=")">
#{assetCode}
</foreach>
AND t2.column_type = "P"
GROUP BY
t1.asset_code
) tt1
ON t.id = tt1.id
</select>
<insert id="insertDcBusiParamDraftDay" parameterType="DcBusiParamDraftDay" useGeneratedKeys="true" keyProperty="id"> <insert id="insertDcBusiParamDraftDay" parameterType="DcBusiParamDraftDay" useGeneratedKeys="true" keyProperty="id">
insert into dc_busi_param_draft_day insert into dc_busi_param_draft_day
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">

Loading…
Cancel
Save