Commit accf7639 authored by chenzhao's avatar chenzhao

统计首页开发

parent 2432116a
package com.yeejoin.amos.boot.module.hygf.api.mapper;
import com.yeejoin.amos.boot.module.hygf.api.config.UserEmpower;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
......@@ -8,17 +9,27 @@ import java.util.Map;
public interface StatisticsHomepageMapper {
@UserEmpower(field ={"ph.regional_companies_code"},dealerField ={"hygf_peasant_household.developer_code"} ,fieldConditions ={"eq"} ,relationship="and")
public List<Map<String,Object>> surveyStatusTotal(@RequestParam(value = "developerCode") String developerCode, @RequestParam(value = "regionalCompaniesCode")String regionalCompaniesCode, @RequestParam(value = "province")String province, @RequestParam(value = "city") String city, @RequestParam(value = "district")String district);
@UserEmpower(field ={"hygf_peasant_household.regional_companies_code"},dealerField ={"hygf_peasant_household.developer_code"} ,fieldConditions ={"eq"} ,relationship="and")
public List<Map<String,Object>> contractStatusTotal(@RequestParam(value = "developerCode") String developerCode, @RequestParam(value = "regionalCompaniesCode")String regionalCompaniesCode, @RequestParam(value = "province")String province, @RequestParam(value = "city") String city, @RequestParam(value = "district")String district);
@UserEmpower(field ={"hygf_peasant_household.regional_companies_code"},dealerField ={"hygf_peasant_household.developer_code"} ,fieldConditions ={"eq"} ,relationship="and")
public List<Map<String,Object>> desionTotal(@RequestParam(value = "developerCode") String developerCode, @RequestParam(value = "regionalCompaniesCode")String regionalCompaniesCode, @RequestParam(value = "province")String province, @RequestParam(value = "city") String city, @RequestParam(value = "district")String district);
@UserEmpower(field ={"hygf_peasant_household.regional_companies_code"},dealerField ={"hygf_peasant_household.developer_code"} ,fieldConditions ={"eq"} ,relationship="and")
public List<Map<String,Object>> preparationMoneyTotal(@RequestParam(value = "developerCode") String developerCode, @RequestParam(value = "regionalCompaniesCode")String regionalCompaniesCode, @RequestParam(value = "province")String province, @RequestParam(value = "city") String city, @RequestParam(value = "district")String district);
@UserEmpower(field ={"hygf_peasant_household.regional_companies_code"},dealerField ={"hygf_peasant_household.developer_code"} ,fieldConditions ={"eq"} ,relationship="and")
public List<Map<String,Object>> workOrderTotal(@RequestParam(value = "developerCode") String developerCode, @RequestParam(value = "regionalCompaniesCode")String regionalCompaniesCode, @RequestParam(value = "province")String province, @RequestParam(value = "city") String city, @RequestParam(value = "district")String district);
@UserEmpower(field ={"hygf_peasant_household.regional_companies_code"},dealerField ={"hygf_peasant_household.developer_code"} ,fieldConditions ={"eq"} ,relationship="and")
public List<Map<String,Object>> gridStatusTotal(@RequestParam(value = "developerCode") String developerCode, @RequestParam(value = "regionalCompaniesCode")String regionalCompaniesCode, @RequestParam(value = "province")String province, @RequestParam(value = "city") String city, @RequestParam(value = "district")String district);
@UserEmpower(field ={"hygf_peasant_household.regional_companies_code"},dealerField ={"hygf_peasant_household.developer_code"} ,fieldConditions ={"eq"} ,relationship="and")
public List<Map<String,Object>> acceptanceStatusTotal(@RequestParam(value = "developerCode") String developerCode, @RequestParam(value = "regionalCompaniesCode")String regionalCompaniesCode, @RequestParam(value = "province")String province, @RequestParam(value = "city") String city, @RequestParam(value = "district")String district);
@UserEmpower(field ={"hygf_peasant_household.regional_companies_code"},dealerField ={"hygf_peasant_household.developer_code"} ,fieldConditions ={"eq"} ,relationship="and")
public List<Map<String,Object>> financingStatusTotal(@RequestParam(value = "developerCode") String developerCode, @RequestParam(value = "regionalCompaniesCode")String regionalCompaniesCode, @RequestParam(value = "province")String province, @RequestParam(value = "city") String city, @RequestParam(value = "district")String district);
@UserEmpower(field ={"hygf_peasant_household.regional_companies_code"},dealerField ={"hygf_peasant_household.developer_code"} ,fieldConditions ={"eq"} ,relationship="and")
public List<Map<String,Object>> inverterTotal(@RequestParam(value = "developerCode") String developerCode, @RequestParam(value = "regionalCompaniesCode")String regionalCompaniesCode, @RequestParam(value = "province")String province, @RequestParam(value = "city") String city, @RequestParam(value = "district")String district, @RequestParam(value = "regions")List<String> regions);
@UserEmpower(field ={"jp.regional_companies_code"},dealerField ={"hygf_peasant_household.developer_code"} ,fieldConditions ={"eq"} ,relationship="and")
public List<Map<String,Object>> inverterTotalJp(@RequestParam(value = "developerCode") String developerCode, @RequestParam(value = "regionalCompaniesCode")String regionalCompaniesCode, @RequestParam(value = "province")String province, @RequestParam(value = "city") String city, @RequestParam(value = "district")String district, @RequestParam(value = "regions")List<String> regions);
......
......@@ -4,27 +4,11 @@
<select id="surveyStatusTotal" resultType="map">
SELECT
CAST(FLOOR(SUM(CASE WHEN ps.process_status = '不通过' THEN 1 ELSE 0 END)) AS SIGNED)AS '未通过',
CAST(FLOOR(SUM(CASE WHEN ps.process_status = '进行中' AND ps.business_status = '通过' THEN 1 ELSE 0 END)) AS SIGNED) AS '已完成(法务审核)',
CAST(FLOOR(SUM(CASE WHEN ps.process_status = '完成' THEN 1 ELSE 0 END)) AS SIGNED) AS completeTotal,
CAST(FLOOR(SUM(CASE WHEN ps.process_status = '进行中' AND (ps.business_status IS NULL OR ps.design_status IS NULL OR ps.technology_status IS NULL) THEN 1 ELSE 0 END)) AS SIGNED) AS '进行中(审核)',
( SELECT count(*) FROM hygf_peasant_household WHERE construction_state = '待勘察' and is_delete = 0
<if test="developerCode != null and developerCode != ''">
AND hygf_peasant_household.developer_code = #{developerCode}
</if>
<if test="regionalCompaniesCode != null and regionalCompaniesCode != ''">
AND hygf_peasant_household.regional_companies_code = #{regionalCompaniesCode}
</if>
<if test="province != null and province != ''">
AND hygf_peasant_household.project_address LIKE CONCAT ('%',#{province},'%')
</if>
<if test="city != null and city != ''">
AND hygf_peasant_household.project_address LIKE CONCAT ('%',#{city},'%')
</if>
<if test="district != null and district != ''">
AND hygf_peasant_household.project_address LIKE CONCAT ('%',#{district},'%')
</if>
) AS '未勘察'
SUM(CASE WHEN ps.process_status = '不通过' THEN 1 ELSE 0 END)AS '未通过',
SUM(CASE WHEN ps.process_status = '进行中' AND ps.business_status = '通过' THEN 1 ELSE 0 END) AS '已完成(法务审核)',
SUM(CASE WHEN ps.process_status = '完成' THEN 1 ELSE 0 END) AS completeTotal,
SUM(CASE WHEN ps.process_status = '进行中' AND (ps.business_status IS NULL OR ps.design_status IS NULL OR ps.technology_status IS NULL) THEN 1 ELSE 0 END) AS '进行中(审核)'
FROM
hygf_power_station ps
LEFT JOIN
......@@ -52,9 +36,9 @@
<select id="contractStatusTotal" resultType="map">
SELECT
CAST(SUM(CASE WHEN status = '未签署' and initiate_status = '未发起' THEN 1 ELSE 0 END) AS SIGNED)AS '未发起',
CAST(SUM(CASE WHEN status = '双方已签署' THEN 1 ELSE 0 END) AS SIGNED) AS '双方已签署',
CAST(SUM(CASE WHEN status = '农户已签署' THEN 1 ELSE 0 END) AS SIGNED) AS '农户已签署'
SUM(CASE WHEN status = '未签署' and initiate_status = '未发起' THEN 1 ELSE 0 END) AS '未发起',
SUM(CASE WHEN status = '双方已签署' THEN 1 ELSE 0 END) AS '双方已签署',
SUM(CASE WHEN status = '农户已签署' THEN 1 ELSE 0 END) AS '农户已签署'
FROM
hygf_household_contract
LEFT JOIN
......@@ -107,9 +91,9 @@
<select id="preparationMoneyTotal" resultType="map">
SELECT
CAST(SUM( CASE WHEN preparation_money_state = '待发货' or preparation_money_state = '暂存发货' THEN 1 ELSE 0 END ) AS SIGNED)AS '待发货',
CAST(SUM( CASE WHEN preparation_money_state = '备货完成' THEN 1 ELSE 0 END ) AS SIGNED) AS '已收货',
CAST(SUM( CASE WHEN preparation_money_state = '待收货' THEN 1 ELSE 0 END ) AS SIGNED)AS '已发货'
SUM( CASE WHEN preparation_money_state = '待发货' or preparation_money_state = '暂存发货' THEN 1 ELSE 0 END ) AS '待发货',
SUM( CASE WHEN preparation_money_state = '备货完成' THEN 1 ELSE 0 END ) AS '已收货',
SUM( CASE WHEN preparation_money_state = '待收货' THEN 1 ELSE 0 END ) AS '已发货'
FROM
hygf_peasant_household
WHERE
......@@ -257,16 +241,28 @@
<select id="financingStatusTotal" resultType="map">
SELECT
COUNT( * ) AS total,
status AS statusText,
ROUND(COALESCE(SUM(ei.real_scale), 0), 2) AS realScale,
SUM(disbursement_money) as disbursementMoney
count(*) AS total,
CASE
WHEN info.`status` = '已放款' THEN
'已放款'
WHEN info.`status` = '审核通过' THEN
'待放款'
WHEN info.`status` = '待融资审核' THEN
'待审核'
WHEN info.`status` = '审核不通过' THEN
'未通过'
WHEN info.`status` = '放款完成' THEN
'放款完成' ELSE '待推送'
END AS statusText,
SUM( info.disbursement_money ) AS disbursementMoney,
SUM( ei.real_scale ) AS realScale
FROM
hygf_financing_info
LEFT JOIN hygf_work_order_power_station ps ON ps.peasant_household_id = hygf_financing_info.peasant_household_id
`hygf_peasant_household` hph
LEFT JOIN hygf_financing_info info ON info.peasant_household_id = hph.sequence_nbr
LEFT JOIN hygf_work_order_power_station ps ON ps.peasant_household_id = hph.sequence_nbr
LEFT JOIN hygf_power_station_engineering_info ei ON ei.work_order_power_station_id = ps.sequence_nbr
LEFT JOIN hygf_peasant_household ON hygf_financing_info.peasant_household_id = hygf_peasant_household.sequence_nbr
<where>
WHERE
hph.construction_state = '验收完成'
<if test="developerCode != null and developerCode != ''">
AND hygf_peasant_household.developer_code = #{developerCode}
</if>
......@@ -282,39 +278,18 @@
<if test="district != null and district != ''">
AND hygf_peasant_household.project_address LIKE CONCAT ('%',#{district},'%')
</if>
</where>
GROUP BY
status
STATUS
</select>
<select id="inverterTotal" resultType="map">
SELECT
COUNT(*) total,
'接入逆变器' AS statusText
FROM
hygf_jp_inverter ji
LEFT JOIN hygf_jp_station jp ON jp.third_station_id = ji.third_station_id
LEFT JOIN privilege_company pc on jp.regional_companies_code = pc.ORG_CODE
WHERE
jp.regional_companies_code IS NOT NULL
AND jp.amos_company_code IS NOT NULL
<if test="developerCode != null and developerCode != ''">
AND jp.amos_company_code = #{developerCode}
</if>
<if test="regionalCompaniesCode != null and regionalCompaniesCode != ''">
AND jp.regional_companies_code = #{regionalCompaniesCode}
</if>
<if test="regions != null and regions.size()>0 ">
and pc.REGION_SEQ in
<foreach collection="regions" separator="," open="(" close=")" item="item">
#{item}
</foreach>
</if>
UNION ALL
SELECT
FLOOR(SUM((LENGTH(construction_inverter_info)-LENGTH(REPLACE(construction_inverter_info,'id',''))))/LENGTH('id')) AS total,
'户用开发逆变器' AS statusText
'户用开发逆变器' AS statusText,
0 AS realScale
FROM
hygf_power_station_construction_data
LEFT JOIN
......@@ -337,4 +312,30 @@
AND hygf_peasant_household.project_address LIKE CONCAT ('%',#{district},'%')
</if>
</select>
<select id="inverterTotalJp" resultType="map">
SELECT
COUNT(*) total,
'接入逆变器' AS statusText,
ROUND(COALESCE(SUM( ji.capacity),0),2) AS realScale
FROM
hygf_jp_inverter ji
LEFT JOIN hygf_jp_station jp ON jp.third_station_id = ji.third_station_id
LEFT JOIN privilege_company pc on jp.regional_companies_code = pc.ORG_CODE
WHERE
jp.regional_companies_code IS NOT NULL
AND jp.amos_company_code IS NOT NULL
<if test="developerCode != null and developerCode != ''">
AND jp.amos_company_code = #{developerCode}
</if>
<if test="regionalCompaniesCode != null and regionalCompaniesCode != ''">
AND jp.regional_companies_code = #{regionalCompaniesCode}
</if>
<if test="regions != null and regions.size()>0 ">
and pc.REGION_SEQ in
<foreach collection="regions" separator="," open="(" close=")" item="item">
#{item}
</foreach>
</if>
</select>
</mapper>
\ No newline at end of file
package com.yeejoin.amos.boot.module.hygf.biz.controller;
import com.google.common.net.HttpHeaders;
import com.yeejoin.amos.boot.module.hygf.api.config.UserLimits;
import com.yeejoin.amos.boot.module.hygf.api.dto.CommerceInfoDto;
import com.yeejoin.amos.boot.module.hygf.api.util.CommonResponseNewUtil;
import com.yeejoin.amos.boot.module.hygf.biz.service.impl.CommonServiceImpl;
......@@ -108,6 +109,7 @@ public class CommonController {
@GetMapping(value = "/statisticsHomepage")
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "资料下载进度获取", notes = "资料下载进度获取")
@UserLimits
public ResponseModel<Map<String, Object>> getSchedule(@RequestParam(required = false) String developerCode,
@RequestParam(required = false) String regionalCompaniesCode,
@RequestParam(required = false) String province,
......
......@@ -44,6 +44,8 @@ public class StatisticsHomepageServiceImpl {
this.resuleMapBuild(map,resultMap,financingMaps,"financing");
List<String> regionNodeByCode = jpStationMapper.getRegionNodeByCode(province);
List<Map<String, Object>> inverterMaps = statisticsHomepageMapper.inverterTotal(developerCode, regionalCompaniesCode, province, city, district,regionNodeByCode);
List<Map<String, Object>> inverterJpMaps = statisticsHomepageMapper.inverterTotalJp(developerCode, regionalCompaniesCode, province, city, district,regionNodeByCode);
inverterMaps.addAll(inverterJpMaps);
this.resuleMapBuild(map,resultMap,inverterMaps,"inverter");
......@@ -54,7 +56,11 @@ public class StatisticsHomepageServiceImpl {
Map<String,Object> resuleMapBuild(Map<String, Object> li, Map<String, Object> resultMap,List<Map<String, Object>> maps,String type){
long total= 0;
long trtotal= 0;
double trrealScale = 0.00;
double realScale = 0.00;
long sgtotal= 0;
double sgrealScale = 0.00;
long sureyNum = 0;
long workNum = 0;
long preparationNum = 0;
......@@ -71,6 +77,7 @@ public class StatisticsHomepageServiceImpl {
List<String> desionKeys = new ArrayList<>(Arrays.asList("施工图已上传","典设图已上传"));
List<String> gridKeys = new ArrayList<>(Arrays.asList("待登记","审核中","已完成","未通过","整改待审核" ,"待整改"));
List<String> acceptanceKeys = new ArrayList<>(Arrays.asList("待提交","已完成","审核中","整改待审核","待整改","未通过"));
List<String> financingKeys = new ArrayList<>(Arrays.asList("未通过","已放款","放款完成","待审核","待推送","待放款"));
List<Map<String, Object>> list = new ArrayList<>();
switch(type){
case "surey" :
......@@ -86,7 +93,7 @@ public class StatisticsHomepageServiceImpl {
list.add( MapBuilder.<String, Object>create().put("statusText",e).put("total",surey.get(e)).build());
}
if (!e.equals("未勘察")){
sureyNum += (long)surey.get(e);
sureyNum += new BigDecimal(surey.get(e).toString()).longValue();
} else {
stationNum += (long)surey.get(e);
}
......@@ -105,7 +112,7 @@ public class StatisticsHomepageServiceImpl {
list = this.nullDataBuildResult(list,desionKeys);
}else {
Map<String, Object> desion = maps.get(0);
desionKeys.remove(desion.keySet());
desionKeys.removeAll(desion.keySet());
for (String e : desion.keySet()) {
list.add( MapBuilder.<String, Object>create().put("statusText",e).put("total",desion.get(e)).build());
......@@ -126,6 +133,7 @@ public class StatisticsHomepageServiceImpl {
list = this.nullDataBuildResult(list,contractKeys);
}else {
Map<String, Object> contract = maps.get(0);
contractKeys.removeAll(contract.keySet());
for (String e : contract.keySet()) {
list.add(MapBuilder.<String, Object>create().put("statusText", e).put("total", contract.get(e)).build());
}
......@@ -138,9 +146,10 @@ public class StatisticsHomepageServiceImpl {
list = this.nullDataBuildResult(list,preparationMoneyKeys);
}else {
Map<String, Object> preparationMoney = maps.get(0);
preparationMoneyKeys.removeAll(preparationMoney.keySet());
for (String e : preparationMoney.keySet()) {
list.add(MapBuilder.<String, Object>create().put("statusText", e).put("total", preparationMoney.get(e)).build());
preparationNum += (long) preparationMoney.get(e);
preparationNum += new BigDecimal(preparationMoney.get(e).toString()).longValue();
}
list = this.nullDataBuildResult(list,preparationMoneyKeys);
}
......@@ -162,13 +171,19 @@ public class StatisticsHomepageServiceImpl {
realScale += (double) map.get("realScale");
iterator.remove();
}
if ("施工资料已上传".equals(map.get("statusText"))) {
sgtotal += (long) map.get("total");
sgrealScale += (double) map.get("realScale");
iterator.remove();
}
}
maps.add(MapBuilder.<String, Object>create().put("statusText","审核中").put("total",total).put("realScale",realScale).build());
maps.add(MapBuilder.<String, Object>create().put("statusText","审核中").put("total",total).put("realScale",new BigDecimal(realScale).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()).build());
maps.add(MapBuilder.<String, Object>create().put("statusText","施工资料已上传").put("total",sgtotal).put("realScale",new BigDecimal(sgrealScale).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()).build());
differenceValue(maps,workOrder);
resultMap.put("workOrder",maps);
}
li.put("workNum",workNum);
li.put("stationRealScale",stationRealScale);
li.put("stationRealScale",new BigDecimal(stationRealScale/1000).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
break;
case "grid":
......@@ -186,7 +201,7 @@ public class StatisticsHomepageServiceImpl {
iterator1.remove();
}
}
maps.add(MapBuilder.<String, Object>create().put("statusText", "审核中").put("total", total).put("realScale", realScale).build());
maps.add(MapBuilder.<String, Object>create().put("statusText", "审核中").put("total", total).put("realScale",new BigDecimal(realScale).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()).build());
differenceValue(maps,gridKeys);
resultMap.put("grid",maps);
}
......@@ -207,22 +222,37 @@ public class StatisticsHomepageServiceImpl {
iterator2.remove();
}
}
maps.add(MapBuilder.<String, Object>create().put("statusText","审核中").put("total",total).put("realScale",realScale).build());
maps.add(MapBuilder.<String, Object>create().put("statusText","审核中").put("total",total).put("realScale",new BigDecimal(realScale).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()).build());
differenceValue(maps,acceptanceKeys);
resultMap.put("acceptance",maps);
}
li.put("acceptanceNum",acceptanceNum);
break;
case "financing":
resultMap.put("financing",maps);
for (Map<String, Object> map : maps) {
if (CollectionUtil.isEmpty(maps)|| Objects.isNull(maps.get(0))){
list = this.nullDataBuildResult(list,financingKeys);
resultMap.put("financing",list);
}else {
Iterator<Map<String, Object>> iterator2 = maps.iterator();
while (iterator2.hasNext()) {
Map<String, Object> map = iterator2.next();
financingNum += (long) map.get("total");
if (map.get("statusText").equals("放款完成")){
if ("放款完成".equals(map.get("statusText"))) {
disbursementMoney += (double)map.get("disbursementMoney");
}
if ("待推送".equals(map.get("statusText"))) {
trtotal += (long) map.get("total");
trrealScale += (double) map.get("realScale");
iterator2.remove();
}
}
maps.add(MapBuilder.<String, Object>create().put("statusText","待推送").put("total",trtotal).put("realScale",new BigDecimal(trrealScale).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()).build());
differenceValue(maps,financingKeys);
resultMap.put("financing",maps);
}
li.put("financingNum",financingNum);
li.put("disbursementMoney",financingNum);
li.put("disbursementMoney",new BigDecimal(disbursementMoney).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
break;
default:
resultMap.put("inverter",maps);
......
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