Commit 5c1fe114 authored by lisong's avatar lisong

优化地图上气瓶加载接口

parent 8a3c0c23
package com.yeejoin.amos.boot.module.cylinder.flc.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.cylinder.flc.api.dto.CylinderUnitDto;
import com.yeejoin.amos.boot.module.cylinder.flc.api.entity.CylinderUnit;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 气瓶企业信息 Mapper 接口
*
......@@ -43,4 +46,6 @@ public interface CylinderUnitMapper extends BaseMapper<CylinderUnit> {
Integer getLicenseOutOfDate(String creditCode);
Integer getThisMonthUnitTotalByRegionCode(String regionCode);
List<CylinderUnitDto> getMessage(@Param("regionCode") String regionCode);
}
......@@ -31,4 +31,20 @@
<select id="getThisMonthUnitTotalByRegionCode" resultType="java.lang.Integer">
select count(sequence_nbr) from tz_cylinder_unit where date_format(sync_date ,'yyyy-mm') LIKE date_format ( NOW( ) ,'yyyy-mm') and region_code like CONCAT('%',#{regionCode},'%')
</select>
<select id="getMessage" resultType="com.yeejoin.amos.boot.module.cylinder.flc.api.dto.CylinderUnitDto">
SELECT tcu.*,
CASE
WHEN (SELECT COUNT(1)
FROM tz_cylinder_inspection ins
WHERE ins.app_id = tcu.app_id
and TO_DAYS(ins.next_inspection_date) - TO_DAYS(NOW()) &lt;= 30) > 0 THEN
1
WHEN (SELECT COUNT(1) FROM view_unit_outofdate v WHERE v.credit_code = tcu.credit_code) > 0 THEN
1
ELSE 0
END AS outOfDate
FROM tz_cylinder_unit tcu
WHERE tcu.region_code like concat('%', #{regionCode}, '%')
</select>
</mapper>
......@@ -53,25 +53,26 @@ public class CylinderUnitController extends BaseController {
@RequestMapping(value = "/queryCylinderUnitList", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "通过regionCode查询气瓶企业", notes = "通过regionCode查询气瓶企业")
public ResponseModel<List<CylinderUnitDto>> querySpecialEquipmentList(@RequestParam String regionCode) {
List<CylinderUnit> unitList = cylinderUnitServiceImpl
.list(new LambdaQueryWrapper<CylinderUnit>().like(CylinderUnit::getRegionCode, regionCode));
List<CylinderUnitDto> result = new ArrayList<>();
unitList.stream().forEach(t -> {
CylinderUnitDto temp = new CylinderUnitDto();
BeanUtils.copyProperties(t, temp);
temp.setOutOfDate(false);
int num = cylinderUnitServiceImpl.getWarnNumByAppId(t.getAppId());
if (num > 0) {
temp.setOutOfDate(true);
}
num = cylinderUnitServiceImpl.getLicenseOutOfDate(temp.getCreditCode());
if(num > 0){
temp.setOutOfDate(true);
}
result.add(temp);
});
return ResponseHelper.buildResponse(result);
return ResponseHelper.buildResponse(cylinderUnitServiceImpl.getMessage(regionCode));
// List<CylinderUnit> unitList = cylinderUnitServiceImpl
// .list(new LambdaQueryWrapper<CylinderUnit>().like(CylinderUnit::getRegionCode, regionCode));
//
// List<CylinderUnitDto> result = new ArrayList<>();
// unitList.stream().forEach(t -> {
// CylinderUnitDto temp = new CylinderUnitDto();
// BeanUtils.copyProperties(t, temp);
// temp.setOutOfDate(false);
// int num = cylinderUnitServiceImpl.getWarnNumByAppId(t.getAppId());
// if (num > 0) {
// temp.setOutOfDate(true);
// }
// num = cylinderUnitServiceImpl.getLicenseOutOfDate(temp.getCreditCode());
// if(num > 0){
// temp.setOutOfDate(true);
// }
// result.add(temp);
// });
// return ResponseHelper.buildResponse(result);
}
/**
......
......@@ -149,4 +149,9 @@ public class CylinderUnitServiceImpl extends BaseService<CylinderUnitDto, Cylind
public Integer getLicenseOutOfDate(String creditCode){
return baseMapper.getLicenseOutOfDate(creditCode);
}
public List<CylinderUnitDto> getMessage(String regionCode){
return baseMapper.getMessage(regionCode);
}
}
\ No newline at end of file
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