Commit cfb74d2292a5efc34eb62c4317a5439ee57d05a6
1 parent
ba456af1
Exists in
master
开发:项目汇总表
Showing
6 changed files
with
282 additions
and
10 deletions
Show diff stats
backend/bpm-runtime/src/main/java/com/hotent/runtime/script/ScriptImpl.java
... | ... | @@ -21,6 +21,7 @@ import com.hotent.base.manager.CommonManager; |
21 | 21 | import com.hotent.base.util.*; |
22 | 22 | import com.hotent.base.util.Base64; |
23 | 23 | import com.hotent.runtime.utils.SubCalcUtils; |
24 | +import org.apache.commons.lang.ObjectUtils; | |
24 | 25 | import org.apache.commons.lang.exception.ExceptionUtils; |
25 | 26 | import org.springframework.context.annotation.Primary; |
26 | 27 | import org.springframework.jdbc.core.JdbcTemplate; |
... | ... | @@ -1793,7 +1794,7 @@ public class ScriptImpl implements IScript { |
1793 | 1794 | //当前登陆用户的ID |
1794 | 1795 | private static final String LOGIN_USER = "loginUser"; |
1795 | 1796 | //当前登陆用户所属组织的ID |
1796 | - private static final String LOGIN_USER_ORGS = "loginUserOrgs"; | |
1797 | + private static final String LOGIN_USER_ORGS = "loginUserOrgs";//获取用户组织关联表中的组织数据 | |
1797 | 1798 | //当前登陆用户所属组织及下属组织的ID |
1798 | 1799 | private static final String LOGIN_USER_SUB_ORGS = "loginUserSubOrgs"; |
1799 | 1800 | //当前登陆用户所属组织及所有下属组织的ID |
... | ... | @@ -1802,16 +1803,16 @@ public class ScriptImpl implements IScript { |
1802 | 1803 | private static final String LOGIN_USER_ALL_ORGS = "loginUserAllOrgs"; |
1803 | 1804 | public ArrayList<String> getDataPermission(String type) { |
1804 | 1805 | ArrayList<String> orgIds = new ArrayList<String>(); |
1805 | - IUser currentUser = ContextUtil.getCurrentUser(); | |
1806 | + IUser currentUser = ContextUtil.getCurrentUser();//获取当前用户信息 | |
1806 | 1807 | if (BeanUtils.isNotEmpty(type)) { |
1807 | 1808 | if (LOGIN_USER.equals(type)) { |
1808 | - orgIds.add(currentUser.getUserId()); | |
1809 | + orgIds.add(currentUser.getUserId());//当前用户id | |
1809 | 1810 | } else if (LOGIN_USER_ORGS.equals(type)) { |
1810 | - String currentUserOrgIds = currentUser.getAttrbuite("CURRENT_USER_ORGIDS"); | |
1811 | - if (StringUtil.isNotEmpty(currentUserOrgIds)) { | |
1812 | - String[] oids = currentUserOrgIds.split(","); | |
1813 | - Set<String> oidSet = new HashSet<String>(Arrays.asList(oids)); | |
1814 | - orgIds.addAll(oidSet); | |
1811 | + ArrayNode orgArrayNode = uCFeignService.getOrgListByUserId(currentUser.getUserId()); | |
1812 | + if (BeanUtils.isNotEmpty(orgArrayNode)) { | |
1813 | + for (JsonNode jsonNode : orgArrayNode) { | |
1814 | + orgIds.add(jsonNode.get("id").asText()); | |
1815 | + } | |
1815 | 1816 | } |
1816 | 1817 | } else if (LOGIN_USER_SUB_ORGS.equals(type)) { |
1817 | 1818 | String currentUserSubOrgIds = StringUtil.isNotEmpty(AuthenticationUtil.getCurrentUserSubOrgIds()) ? AuthenticationUtil.getCurrentUserSubOrgIds() : ""; | ... | ... |
backend/chkpower/src/main/java/com/hotent/chkpower/controller/WProjectLibraryInventoryController.java
... | ... | @@ -118,9 +118,9 @@ public class WProjectLibraryInventoryController extends BaseController<WProjectL |
118 | 118 | queryWrapper.like("F_update_time", wProjectLibraryInventory.getUpdateTime()); |
119 | 119 | } |
120 | 120 | if (ObjectUtils.isNotEmpty(wProjectLibraryInventory.getIdList())) { |
121 | - queryWrapper.in("ID_",wProjectLibraryInventory.getIdList()); | |
121 | + queryWrapper.in("ID_", wProjectLibraryInventory.getIdList()); | |
122 | 122 | } |
123 | - queryWrapper.orderByDesc("F_create_time","F_update_time"); | |
123 | + queryWrapper.orderByDesc("F_create_time", "F_update_time"); | |
124 | 124 | |
125 | 125 | |
126 | 126 | ArrayList<String> orgIds = script.getDataPermission("loginUserAllSubOrgs"); |
... | ... | @@ -193,4 +193,12 @@ public class WProjectLibraryInventoryController extends BaseController<WProjectL |
193 | 193 | |
194 | 194 | } |
195 | 195 | |
196 | + @GetMapping(value = "/statistics") | |
197 | + @ApiOperation(value = "项目汇总", httpMethod = "GET", notes = "项目汇总") | |
198 | + public CommonResult<Object> statistics(@ApiParam(name = "startDate", value = "开始日期", required = true) @RequestParam(required = true) String startDate | |
199 | + ,@ApiParam(name = "endDate", value = "结束日期", required = true) @RequestParam(required = true) String endDate) throws Exception { | |
200 | + return CommonResult.<Object>ok().value(baseService.statistics(startDate,endDate)); | |
201 | + } | |
202 | + | |
203 | + | |
196 | 204 | } | ... | ... |
backend/chkpower/src/main/java/com/hotent/chkpower/dao/WProjectLibraryInventoryDao.java
... | ... | @@ -2,6 +2,11 @@ package com.hotent.chkpower.dao; |
2 | 2 | |
3 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
4 | 4 | import com.hotent.chkpower.model.WProjectLibraryInventory; |
5 | +import org.apache.ibatis.annotations.Param; | |
6 | + | |
7 | +import java.util.ArrayList; | |
8 | +import java.util.HashMap; | |
9 | +import java.util.List; | |
5 | 10 | |
6 | 11 | /** |
7 | 12 | * 项目库清单 Mapper 接口 |
... | ... | @@ -11,5 +16,66 @@ import com.hotent.chkpower.model.WProjectLibraryInventory; |
11 | 16 | * @since 2024-07-12 |
12 | 17 | */ |
13 | 18 | public interface WProjectLibraryInventoryDao extends BaseMapper<WProjectLibraryInventory> { |
19 | + /** | |
20 | + * 项目类型总数量、收入、利润、在推项目概况汇总、项目总规模 | |
21 | + * @param startDate | |
22 | + * @param endDate | |
23 | + * @param orgIdList | |
24 | + * @return | |
25 | + */ | |
26 | + HashMap<String, Object> basicsStatistics(@Param("startDate") String startDate, @Param("endDate")String endDate, @Param("list")ArrayList<String> orgIdList); | |
27 | + | |
28 | + /** | |
29 | + * 项目质量总数量 | |
30 | + * @param startDate | |
31 | + * @param endDate | |
32 | + * @param orgIdList | |
33 | + * @return | |
34 | + */ | |
35 | + List<HashMap<String, Object>> projectRatingStatistics(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("list")ArrayList<String> orgIdList,@Param("xmpjList")List<String >xmpjList); | |
36 | + | |
37 | + /** | |
38 | + * 投资规模 | |
39 | + * @param startDate | |
40 | + * @param endDate | |
41 | + * @param orgIdList | |
42 | + * @return | |
43 | + */ | |
44 | + List<HashMap<String, Object>> investmentScaleStatistics(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("list")ArrayList<String> orgIdList); | |
45 | + | |
46 | + /** | |
47 | + * 项目主体项目占比 | |
48 | + * @param startDate | |
49 | + * @param endDate | |
50 | + * @param orgIdList | |
51 | + * @return | |
52 | + */ | |
53 | + List<HashMap<String, Object>> orgNameProjectStatistics(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("list")ArrayList<String> orgIdList); | |
54 | + | |
55 | + /** | |
56 | + * 查询业务场景字典 | |
57 | + * @param ywcj | |
58 | + * @return | |
59 | + */ | |
60 | + List<String> listDictByKey(String ywcj); | |
61 | + | |
62 | + /** | |
63 | + * 业务场景占比 | |
64 | + * @param startDate | |
65 | + * @param endDate | |
66 | + * @param orgIdList | |
67 | + * @param ywcjList | |
68 | + * @return | |
69 | + */ | |
70 | + List<HashMap<String, Object>> businessScenariosScaleStatistics(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("list")ArrayList<String> orgIdList, @Param("ywcjList")List<String> ywcjList); | |
14 | 71 | |
72 | + /** | |
73 | + * 商务模式占比 | |
74 | + * @param startDate | |
75 | + * @param endDate | |
76 | + * @param orgIdList | |
77 | + * @param swmsList | |
78 | + * @return | |
79 | + */ | |
80 | + List<HashMap<String, Object>> businessModelStatistics(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("list")ArrayList<String> orgIdList, @Param("swmsList")List<String> swmsList); | |
15 | 81 | } | ... | ... |
backend/chkpower/src/main/java/com/hotent/chkpower/manager/WProjectLibraryInventoryManager.java
... | ... | @@ -3,6 +3,8 @@ package com.hotent.chkpower.manager; |
3 | 3 | import com.hotent.base.manager.BaseManager; |
4 | 4 | import com.hotent.chkpower.model.WProjectLibraryInventory; |
5 | 5 | |
6 | +import java.util.HashMap; | |
7 | + | |
6 | 8 | /** |
7 | 9 | * 项目库清单 服务类 |
8 | 10 | * |
... | ... | @@ -26,4 +28,6 @@ public interface WProjectLibraryInventoryManager extends BaseManager<WProjectLib |
26 | 28 | * @return |
27 | 29 | */ |
28 | 30 | void createOrUpdate(WProjectLibraryInventory wProjectLibraryInventory); |
31 | + | |
32 | + HashMap<String,Object> statistics(String startDate, String endDate); | |
29 | 33 | } | ... | ... |
backend/chkpower/src/main/java/com/hotent/chkpower/manager/impl/WProjectLibraryInventoryManagerImpl.java
1 | 1 | package com.hotent.chkpower.manager.impl; |
2 | 2 | |
3 | +import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |
3 | 4 | import com.hotent.base.manager.impl.BaseManagerImpl; |
4 | 5 | import com.hotent.chkpower.dao.WProjectLibraryInventoryDao; |
5 | 6 | import com.hotent.chkpower.manager.WProjectLibraryInventoryManager; |
6 | 7 | import com.hotent.chkpower.model.WProjectLibraryInventory; |
8 | +import com.hotent.runtime.script.ScriptImpl; | |
9 | +import org.redisson.transaction.operation.map.MapPutIfAbsentOperation; | |
7 | 10 | import org.springframework.stereotype.Service; |
8 | 11 | import org.springframework.transaction.annotation.Transactional; |
9 | 12 | |
13 | +import javax.annotation.Resource; | |
14 | +import java.util.ArrayList; | |
15 | +import java.util.Dictionary; | |
16 | +import java.util.HashMap; | |
17 | +import java.util.List; | |
18 | + | |
10 | 19 | |
11 | 20 | /** |
12 | 21 | * 项目库清单 服务实现类 |
... | ... | @@ -18,6 +27,8 @@ import org.springframework.transaction.annotation.Transactional; |
18 | 27 | @Service |
19 | 28 | public class WProjectLibraryInventoryManagerImpl extends BaseManagerImpl<WProjectLibraryInventoryDao, WProjectLibraryInventory> implements WProjectLibraryInventoryManager { |
20 | 29 | |
30 | + @Resource | |
31 | + private ScriptImpl script; | |
21 | 32 | @Override |
22 | 33 | public WProjectLibraryInventory getDetail(String id) { |
23 | 34 | WProjectLibraryInventory wProjectLibraryInventory = this.get(id); |
... | ... | @@ -30,4 +41,27 @@ public class WProjectLibraryInventoryManagerImpl extends BaseManagerImpl<WProjec |
30 | 41 | //新建或更新 |
31 | 42 | this.saveOrUpdate(wProjectLibraryInventory); |
32 | 43 | } |
44 | + | |
45 | + @Override | |
46 | + public HashMap<String, Object> statistics(String startDate, String endDate) { | |
47 | + HashMap<String, Object> map = new HashMap<>(); | |
48 | + //获取当前用户所属组织及下属组织id集合 | |
49 | + ArrayList<String> orgIdList = script.getDataPermission("loginUserAllSubOrgs"); | |
50 | + map = baseMapper.basicsStatistics(startDate, endDate, orgIdList); | |
51 | + List<String> xmpjList = baseMapper.listDictByKey("xmpj"); | |
52 | + List<HashMap<String, Object>> xmzlMap = baseMapper.projectRatingStatistics(startDate, endDate, orgIdList, xmpjList); | |
53 | + map.put("XMZL", xmzlMap); | |
54 | + List<HashMap<String, Object>> tzgmMap = baseMapper.investmentScaleStatistics(startDate, endDate, orgIdList); | |
55 | + map.put("TZGM", tzgmMap); | |
56 | + | |
57 | + List<HashMap<String, Object>> xmztxmzbMap = baseMapper.orgNameProjectStatistics(startDate, endDate, orgIdList); | |
58 | + map.put("XMZTXMZB", xmztxmzbMap); | |
59 | + List<String> ywcjList = baseMapper.listDictByKey("ywcj"); | |
60 | + List<HashMap<String, Object>> ywcjzbMap = baseMapper.businessScenariosScaleStatistics(startDate, endDate, orgIdList, ywcjList); | |
61 | + map.put("YWCJZB", ywcjzbMap); | |
62 | + List<String> swmsList = baseMapper.listDictByKey("swms"); | |
63 | + List<HashMap<String, Object>> swmszbMap = baseMapper.businessModelStatistics(startDate, endDate, orgIdList, swmsList); | |
64 | + map.put("SWMSZB", swmszbMap); | |
65 | + return map; | |
66 | + } | |
33 | 67 | } | ... | ... |
backend/chkpower/src/main/resources/mapper/WProjectLibraryInventoryMapper.xml
... | ... | @@ -76,4 +76,163 @@ |
76 | 76 | where |
77 | 77 | ID_ = #{id} |
78 | 78 | </select> |
79 | + | |
80 | + | |
81 | + | |
82 | + <select id="basicsStatistics" resultType="java.util.HashMap"> | |
83 | + SELECT | |
84 | + SUM(CASE WHEN F_PROJECT_CATEGORY = '已通过投评项目' THEN 1 ELSE 0 END ) AS YTGTPXMS, -- 已通过投评项目 | |
85 | + SUM(CASE WHEN F_PROJECT_CATEGORY = '已签约项目' THEN 1 ELSE 0 END ) AS YQYXMS, -- 已签约项目 | |
86 | + ROUND(SUM(F_ANNUAL_INCOME_FORECAST/10000),2) AS YJZNSR, -- 预计总年收入(亿元) | |
87 | + ROUND(SUM(F_ANNUAL_NET_PROFIT_FORECAST/10000),2) AS YJZNLR, -- 预计总年利润(亿元) | |
88 | + | |
89 | + | |
90 | + COUNT(*) AS XMZS, -- 项目总数 | |
91 | + SUM(CASE WHEN F_PROJECT_CATEGORY = '暂缓项目' THEN 1 ELSE 0 END ) AS ZHXMS, -- 暂缓项目 | |
92 | + SUM(CASE WHEN F_PROJECT_CATEGORY = '出库项目' THEN 1 ELSE 0 END ) AS CKXMS, -- 出库项目数 | |
93 | + SUM(CASE WHEN F_PROJECT_CATEGORY = '本月重点推进项目' THEN 1 ELSE 0 END ) AS BYZDTJXMS, -- 本月重点推进项目 | |
94 | + ROUND(SUM(F_INVESTMENT_SCALE/10000),2) AS YJZTZ, -- 预计总投资(亿元) | |
95 | + | |
96 | + | |
97 | + SUM(F_SMART_HEATING) AS ZHGR, -- 智慧供热 | |
98 | + ROUND(SUM(F_ENERGY_EFFICIENCY/10000),2) AS ZHNX, -- 综合能效 | |
99 | + SUM(F_PHOTOVOLTAIC) AS GF, -- 光伏 | |
100 | + SUM(F_ENERGY_STORAGE) AS CN -- 储能 | |
101 | + | |
102 | + FROM | |
103 | + W_PROJECT_LIBRARY_INVENTORY | |
104 | + WHERE | |
105 | + F_PROJECT_STATE != '已作废' | |
106 | + <if test="startDate != null and startDate != '' and endDate != null and endDate != ''"> | |
107 | + AND F_create_time BETWEEN #{startDate} AND #{endDate} | |
108 | + </if> | |
109 | + <if test="list != null and list.size() > 0"> | |
110 | + AND F_org_id IN | |
111 | + <foreach collection="list" separator="," item="orgId" close=")" open="("> | |
112 | + #{orgId} | |
113 | + </foreach> | |
114 | + </if> | |
115 | + </select> | |
116 | + | |
117 | + <select id="projectRatingStatistics" resultType="java.util.HashMap"> | |
118 | + SELECT | |
119 | + temp1.project_rating AS xmzl, | |
120 | + count(W_PROJECT_LIBRARY_INVENTORY.F_project_rating)AS sl | |
121 | + FROM ( | |
122 | + <foreach collection="xmpjList" item="xmpj" separator="UNION ALL"> | |
123 | + SELECT #{xmpj} AS project_rating | |
124 | + </foreach> | |
125 | + ) temp1 | |
126 | + LEFT JOIN W_PROJECT_LIBRARY_INVENTORY ON W_PROJECT_LIBRARY_INVENTORY.F_project_rating = temp1.project_rating AND | |
127 | + W_PROJECT_LIBRARY_INVENTORY.F_PROJECT_STATE != '已作废' | |
128 | + <if test="startDate != null and startDate != '' and endDate != null and endDate != ''"> | |
129 | + AND W_PROJECT_LIBRARY_INVENTORY.F_create_time BETWEEN #{startDate} AND #{endDate} | |
130 | + </if> | |
131 | + <if test="list != null and list.size() > 0"> | |
132 | + AND W_PROJECT_LIBRARY_INVENTORY.F_org_id IN | |
133 | + <foreach collection="list" separator="," item="orgId" close=")" open="("> | |
134 | + #{orgId} | |
135 | + </foreach> | |
136 | + </if> | |
137 | + GROUP BY temp1.project_rating | |
138 | + </select> | |
139 | + | |
140 | + <select id="investmentScaleStatistics" resultType="java.util.HashMap"> | |
141 | + SELECT | |
142 | + SUM(CASE WHEN F_investment_scale <= 500 THEN 1 ELSE 0 END) AS '≤500万', | |
143 | + SUM(CASE WHEN F_investment_scale > 500 AND F_investment_scale <= 1000 THEN 1 ELSE 0 END) AS '500-1000万', | |
144 | + SUM(CASE WHEN F_investment_scale > 1000 AND F_investment_scale <= 3000 THEN 1 ELSE 0 END) AS '1000-3000万', | |
145 | + SUM(CASE WHEN F_investment_scale > 3000 THEN 1 ELSE 0 END) AS '>3000万' | |
146 | + FROM | |
147 | + W_PROJECT_LIBRARY_INVENTORY | |
148 | + WHERE | |
149 | + F_PROJECT_STATE != '已作废' | |
150 | + <if test="startDate != null and startDate != '' and endDate != null and endDate != ''"> | |
151 | + AND F_create_time BETWEEN #{startDate} AND #{endDate} | |
152 | + </if> | |
153 | + <if test="list != null and list.size() > 0"> | |
154 | + AND F_org_id IN | |
155 | + <foreach collection="list" separator="," item="orgId" close=")" open="("> | |
156 | + #{orgId} | |
157 | + </foreach> | |
158 | + </if> | |
159 | + </select> | |
160 | + | |
161 | + <select id="orgNameProjectStatistics" resultType="java.util.HashMap"> | |
162 | + SELECT | |
163 | + F_org_name AS xmzt, | |
164 | + count( F_org_id ) AS sl | |
165 | + FROM | |
166 | + W_PROJECT_LIBRARY_INVENTORY | |
167 | + WHERE | |
168 | + F_PROJECT_STATE != '已作废' | |
169 | + <if test="startDate != null and startDate != '' and endDate != null and endDate != ''"> | |
170 | + AND F_create_time BETWEEN #{startDate} AND #{endDate} | |
171 | + </if> | |
172 | + <if test="list != null and list.size() > 0"> | |
173 | + AND F_org_id IN | |
174 | + <foreach collection="list" separator="," item="orgId" close=")" open="("> | |
175 | + #{orgId} | |
176 | + </foreach> | |
177 | + </if> | |
178 | + GROUP BY | |
179 | + F_org_id | |
180 | + </select> | |
181 | + | |
182 | + <select id="listDictByKey" resultType="java.lang.String"> | |
183 | + SELECT | |
184 | + NAME_ | |
185 | + FROM | |
186 | + portal_sys_dic | |
187 | + WHERE | |
188 | + PARENT_ID_ = ( SELECT id_ FROM portal_sys_dic WHERE KEY_ = #{ywcj} ) | |
189 | + ORDER BY | |
190 | + SN_ | |
191 | + </select> | |
192 | + | |
193 | + <select id="businessScenariosScaleStatistics" resultType="java.util.HashMap"> | |
194 | + SELECT | |
195 | + temp1.business_scenarios AS ywcj, | |
196 | + count(W_PROJECT_LIBRARY_INVENTORY.F_business_scenarios)AS sl | |
197 | + FROM ( | |
198 | + <foreach collection="ywcjList" item="ywcj" separator="UNION ALL"> | |
199 | + SELECT #{ywcj} AS business_scenarios | |
200 | + </foreach> | |
201 | + ) temp1 | |
202 | + LEFT JOIN W_PROJECT_LIBRARY_INVENTORY ON W_PROJECT_LIBRARY_INVENTORY.F_business_scenarios = | |
203 | + temp1.business_scenarios AND W_PROJECT_LIBRARY_INVENTORY.F_PROJECT_STATE != '已作废' | |
204 | + <if test="startDate != null and startDate != '' and endDate != null and endDate != ''"> | |
205 | + AND F_create_time BETWEEN #{startDate} AND #{endDate} | |
206 | + </if> | |
207 | + <if test="list != null and list.size() > 0"> | |
208 | + AND F_org_id IN | |
209 | + <foreach collection="list" separator="," item="orgId" close=")" open="("> | |
210 | + #{orgId} | |
211 | + </foreach> | |
212 | + </if> | |
213 | + GROUP BY temp1.business_scenarios | |
214 | + </select> | |
215 | + | |
216 | + <select id="businessModelStatistics" resultType="java.util.HashMap"> | |
217 | + SELECT | |
218 | + temp1.business_model AS swms, | |
219 | + count(W_PROJECT_LIBRARY_INVENTORY.F_business_model)AS sl | |
220 | + FROM ( | |
221 | + <foreach collection="swmsList" item="swms" separator="UNION ALL"> | |
222 | + SELECT #{swms} AS business_model | |
223 | + </foreach> | |
224 | + ) temp1 | |
225 | + LEFT JOIN W_PROJECT_LIBRARY_INVENTORY ON W_PROJECT_LIBRARY_INVENTORY.F_business_model = temp1.business_model | |
226 | + AND W_PROJECT_LIBRARY_INVENTORY.F_PROJECT_STATE != '已作废' | |
227 | + <if test="startDate != null and startDate != '' and endDate != null and endDate != ''"> | |
228 | + AND F_create_time BETWEEN #{startDate} AND #{endDate} | |
229 | + </if> | |
230 | + <if test="list != null and list.size() > 0"> | |
231 | + AND F_org_id IN | |
232 | + <foreach collection="list" separator="," item="orgId" close=")" open="("> | |
233 | + #{orgId} | |
234 | + </foreach> | |
235 | + </if> | |
236 | + GROUP BY temp1.business_model | |
237 | + </select> | |
79 | 238 | </mapper> | ... | ... |