Commit dfe1a9911f698fd8b3e6fa972dabadeedd85c25a
1 parent
66247ea0
Exists in
dev
工程维护通知
Showing
7 changed files
with
191 additions
and
14 deletions
Show diff stats
zr-cloud/zr-modules/zr-schsf/src/main/java/com/chinagas/modules/schsf/domain/notice/McConstructionTemplate.java
0 → 100644
... | ... | @@ -0,0 +1,24 @@ |
1 | +package com.chinagas.modules.schsf.domain.notice; | |
2 | + | |
3 | +import com.chinagas.modules.schsf.domain.McConstruction; | |
4 | + | |
5 | +import java.time.LocalDateTime; | |
6 | +import java.time.format.DateTimeFormatter; | |
7 | + | |
8 | +public class McConstructionTemplate { | |
9 | + private McConstruction mcConstruction; | |
10 | + public McConstructionTemplate(McConstruction mcConstruction) { | |
11 | + this.mcConstruction = mcConstruction; | |
12 | + } | |
13 | + public String getNoticemarkdown() { | |
14 | + return "###### 市场化收费-施工通知 \n " + | |
15 | + "村/小区:" + mcConstruction.getVlgOrCmty() + " \n " + | |
16 | + "当前状态:" + mcConstruction.getStatusName() + " \n " + | |
17 | + "维护操作:点击链接进入维护页面:[https://schsf.chinagasholdings.com](https://schsf.chinagasholdings.com) \n " + | |
18 | + "---" + | |
19 | + " \n " + | |
20 | + "通知日期: " + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm")) + " \n " + | |
21 | + "温馨提醒: 请按时完成维护,保障业务顺畅。 \n "; | |
22 | + } | |
23 | + | |
24 | +} | ... | ... |
zr-cloud/zr-modules/zr-schsf/src/main/java/com/chinagas/modules/schsf/mapper/McConstructionMapper.java
1 | 1 | package com.chinagas.modules.schsf.mapper; |
2 | 2 | |
3 | 3 | import com.chinagas.modules.schsf.domain.McConstruction; |
4 | +import com.chinagas.modules.schsf.domain.dto.NodeUsersDto; | |
5 | +import org.apache.ibatis.annotations.Param; | |
4 | 6 | |
5 | 7 | import java.util.List; |
6 | 8 | |
... | ... | @@ -63,4 +65,6 @@ public interface McConstructionMapper |
63 | 65 | |
64 | 66 | |
65 | 67 | List<McConstruction> selectMcConstructionByData(McConstruction mcConstruction); |
68 | + | |
69 | + List<NodeUsersDto> selectMcConstructionNodeUserList(@Param("id")String id, @Param("nodeType") String nodeType); | |
66 | 70 | } | ... | ... |
zr-cloud/zr-modules/zr-schsf/src/main/java/com/chinagas/modules/schsf/service/IMcConstructionService.java
... | ... | @@ -2,6 +2,8 @@ package com.chinagas.modules.schsf.service; |
2 | 2 | |
3 | 3 | import com.chinagas.modules.schsf.domain.McBasicCmty; |
4 | 4 | import com.chinagas.modules.schsf.domain.McConstruction; |
5 | +import com.chinagas.modules.schsf.domain.McVisit; | |
6 | +import com.chinagas.modules.schsf.domain.dto.NodeUsersDto; | |
5 | 7 | |
6 | 8 | import java.util.List; |
7 | 9 | |
... | ... | @@ -85,4 +87,20 @@ public interface IMcConstructionService |
85 | 87 | * @throws CloneNotSupportedException |
86 | 88 | */ |
87 | 89 | int updateMcConstructionByOperations(McConstruction mcConstruction) throws CloneNotSupportedException; |
90 | + | |
91 | + | |
92 | + /** | |
93 | + * 根据拜访信息,发送钉钉通知 | |
94 | + * @param mcVisit | |
95 | + */ | |
96 | + void sendMcConstructionNotification(McVisit mcVisit); | |
97 | + | |
98 | + | |
99 | + /** | |
100 | + * 节点处理人 | |
101 | + * | |
102 | + * @param id | |
103 | + * @return | |
104 | + */ | |
105 | + List<NodeUsersDto> selectMcConstructionNodeUserList(Long id); | |
88 | 106 | } | ... | ... |
zr-cloud/zr-modules/zr-schsf/src/main/java/com/chinagas/modules/schsf/service/impl/McConstructionServiceImpl.java
1 | 1 | package com.chinagas.modules.schsf.service.impl; |
2 | 2 | |
3 | +import cn.hutool.core.bean.BeanUtil; | |
3 | 4 | import com.alibaba.fastjson2.JSON; |
5 | +import com.chinagas.common.core.exceptions.ServiceException; | |
4 | 6 | import com.chinagas.common.core.utils.DateUtils; |
5 | 7 | import com.chinagas.common.core.utils.StringUtils; |
6 | 8 | import com.chinagas.common.datascope.annotation.DataScope; |
7 | 9 | import com.chinagas.common.security.utils.SecurityUtils; |
8 | 10 | import com.chinagas.modules.schsf.domain.McBasicCmty; |
9 | 11 | import com.chinagas.modules.schsf.domain.McConstruction; |
12 | +import com.chinagas.modules.schsf.domain.McVisit; | |
13 | +import com.chinagas.modules.schsf.domain.dto.NodeUsersDto; | |
14 | +import com.chinagas.modules.schsf.domain.notice.McConstructionTemplate; | |
15 | +import com.chinagas.modules.schsf.domain.notice.McIgnitionTemplate; | |
10 | 16 | import com.chinagas.modules.schsf.enums.ConstructionStatusEnums; |
17 | +import com.chinagas.modules.schsf.enums.IgnitionStatusEnums; | |
11 | 18 | import com.chinagas.modules.schsf.mapper.McConstructionMapper; |
19 | +import com.chinagas.modules.schsf.service.DingtalkService; | |
12 | 20 | import com.chinagas.modules.schsf.service.IMcConstructionService; |
13 | 21 | import com.chinagas.modules.schsf.service.IMcOperationLogService; |
14 | 22 | import org.springframework.beans.factory.annotation.Autowired; |
... | ... | @@ -16,7 +24,9 @@ import org.springframework.stereotype.Service; |
16 | 24 | import org.springframework.transaction.annotation.Transactional; |
17 | 25 | |
18 | 26 | import java.time.LocalDateTime; |
27 | +import java.util.Collections; | |
19 | 28 | import java.util.List; |
29 | +import java.util.stream.Collectors; | |
20 | 30 | |
21 | 31 | /** |
22 | 32 | * 施工维护Service业务层处理 |
... | ... | @@ -31,6 +41,8 @@ public class McConstructionServiceImpl implements IMcConstructionService { |
31 | 41 | private McConstructionMapper mcConstructionMapper; |
32 | 42 | @Autowired |
33 | 43 | private IMcOperationLogService iMcOperationLogService; |
44 | + @Autowired | |
45 | + private DingtalkService dingtalkService; | |
34 | 46 | |
35 | 47 | /** |
36 | 48 | * 查询施工维护 |
... | ... | @@ -119,10 +131,12 @@ public class McConstructionServiceImpl implements IMcConstructionService { |
119 | 131 | mcConstruction.setGroupName(mcBasicCmty.getGroupName()); |
120 | 132 | mcConstruction.setCompanyCode(mcBasicCmty.getCompanyCode()); |
121 | 133 | mcConstruction.setCompanyName(mcBasicCmty.getCompanyName()); |
122 | - mcConstruction.setProvince(mcBasicCmty.getProvince()); | |
123 | - mcConstruction.setCity(mcBasicCmty.getCity()); | |
124 | - mcConstruction.setDistrict(mcBasicCmty.getDistrict()); | |
125 | - mcConstruction.setStreet(mcBasicCmty.getStreet()); | |
134 | + | |
135 | + mcConstruction.setProvince(mcBasicCmty.getProvince()==null?"":mcBasicCmty.getProvince()); | |
136 | + mcConstruction.setCity(mcBasicCmty.getCity()==null?"":mcBasicCmty.getCity()); | |
137 | + mcConstruction.setDistrict(mcBasicCmty.getDistrict()==null?"":mcBasicCmty.getDistrict()); | |
138 | + mcConstruction.setStreet(mcBasicCmty.getStreet()==null?"":mcBasicCmty.getStreet()); | |
139 | + | |
126 | 140 | mcConstruction.setVlgOrCmty(mcBasicCmty.getVlgOrCmty()); |
127 | 141 | List<McConstruction> mcConstructions = mcConstructionMapper.selectMcConstructionByData(mcConstruction); |
128 | 142 | if (mcConstructions != null && !mcConstructions.isEmpty()) { |
... | ... | @@ -202,6 +216,9 @@ public class McConstructionServiceImpl implements IMcConstructionService { |
202 | 216 | |
203 | 217 | iMcOperationLogService.insertMcOperationLog("mc_construction", mcConstruction_param.getId(), "schsf:mcConstruction:engineering", |
204 | 218 | "工程维护", "1", null, JSON.toJSONString(mcConstruction_old), JSON.toJSONString(mcConstruction_new)); |
219 | + if (i>0){ | |
220 | + this.sendNotification(mcConstruction_param.getId()); | |
221 | + } | |
205 | 222 | return i; |
206 | 223 | } |
207 | 224 | |
... | ... | @@ -242,4 +259,55 @@ public class McConstructionServiceImpl implements IMcConstructionService { |
242 | 259 | "运营维护", "1", null, JSON.toJSONString(mcConstruction_old), JSON.toJSONString(mcConstruction_new)); |
243 | 260 | return i; |
244 | 261 | } |
262 | + | |
263 | + /** | |
264 | + * 发送施工维护通知 | |
265 | + * @param mcVisit | |
266 | + */ | |
267 | + @Override | |
268 | + public void sendMcConstructionNotification(McVisit mcVisit) { | |
269 | + McConstruction mcConstruction = new McConstruction(); | |
270 | + mcConstruction.setRegionName(mcVisit.getRegionName()); | |
271 | + mcConstruction.setGroupName(mcVisit.getGroupName()); | |
272 | + mcConstruction.setCompanyCode(mcVisit.getCompanyCode()); | |
273 | + mcConstruction.setCompanyName(mcVisit.getCompanyName()); | |
274 | +// mcConstruction.setProvince(mcVisit.getProvince()); | |
275 | +// mcConstruction.setCity(mcVisit.getCity()); | |
276 | +// mcConstruction.setDistrict(mcVisit.getDistrict()); | |
277 | +// mcConstruction.setStreet(mcVisit.getStreet()); | |
278 | + mcConstruction.setVlgOrCmty(mcVisit.getVlgOrCmty()); | |
279 | + mcConstruction.setStatusCode(ConstructionStatusEnums.MAINTENANCE_SG.getCode()); | |
280 | + List<McConstruction> mcConstructions = mcConstructionMapper.selectMcConstructionByData(mcConstruction); | |
281 | + for (McConstruction construction : mcConstructions) { | |
282 | + this.sendNotification(construction.getId()); | |
283 | + } | |
284 | + } | |
285 | + | |
286 | + private void sendNotification(Long id) { | |
287 | + McConstruction construction = mcConstructionMapper.selectMcConstructionById(id); | |
288 | + if (BeanUtil.isEmpty(construction)) { | |
289 | + throw new ServiceException("未查询到记录"); | |
290 | + } | |
291 | + List<NodeUsersDto> nodeUsersDtos = this.selectMcConstructionNodeUserList(construction.getId()); | |
292 | + if (nodeUsersDtos != null && nodeUsersDtos.size()>0) { | |
293 | + List<String> userIds = nodeUsersDtos.stream().filter(mcVisitNodeUsersDto -> StringUtils.isNotEmpty(mcVisitNodeUsersDto.getDingTalkUserId())).map(NodeUsersDto::getDingTalkUserId).collect(Collectors.toList()); | |
294 | + dingtalkService.sendMarketFeeNotification(userIds, "市场化收费-施工维护", new McConstructionTemplate(construction).getNoticemarkdown()); | |
295 | + } | |
296 | + } | |
297 | + | |
298 | + @Override | |
299 | + public List<NodeUsersDto> selectMcConstructionNodeUserList(Long id) { | |
300 | + McConstruction mcConstruction = mcConstructionMapper.selectMcConstructionById(id); | |
301 | + if (BeanUtil.isEmpty(mcConstruction)) { | |
302 | + throw new ServiceException("未查询到记录"); | |
303 | + } | |
304 | + if (mcConstruction.getStatusCode().equals(ConstructionStatusEnums.MAINTENANCE_SG.getCode())) { | |
305 | + //待工程维护 schsf:mcConstruction:engineering | |
306 | + return mcConstructionMapper.selectMcConstructionNodeUserList(String.valueOf(id), "schsf:mcConstruction:engineering"); | |
307 | + }else if (mcConstruction.getStatusCode().equals(ConstructionStatusEnums.MAINTENANCE_YY.getCode())){ | |
308 | + //待运营维护 schsf:mcConstruction:operations | |
309 | + return mcConstructionMapper.selectMcConstructionNodeUserList(String.valueOf(id), "schsf:mcConstruction:operations"); | |
310 | + } | |
311 | + return Collections.emptyList(); | |
312 | + } | |
245 | 313 | } | ... | ... |
zr-cloud/zr-modules/zr-schsf/src/main/java/com/chinagas/modules/schsf/service/impl/McVisitServiceImpl.java
... | ... | @@ -63,6 +63,9 @@ public class McVisitServiceImpl implements IMcVisitService { |
63 | 63 | private IMcBasicCmtyService iMcBasicCmtyService; |
64 | 64 | @Autowired |
65 | 65 | private DingtalkService dingtalkService; |
66 | + @Autowired | |
67 | + private IMcConstructionService iMcConstructionService; | |
68 | + | |
66 | 69 | |
67 | 70 | /** |
68 | 71 | * 查询拜访工单 |
... | ... | @@ -411,6 +414,8 @@ public class McVisitServiceImpl implements IMcVisitService { |
411 | 414 | //2:判断是否需要添加至点火记录 |
412 | 415 | if (status.equals(YesNoEnums.Y.getName())) { |
413 | 416 | iMcIgnitionService.insertMcVisitByMcIgnition(mcVisit); |
417 | + //施工维护通知 | |
418 | + iMcConstructionService.sendMcConstructionNotification(mcVisit); | |
414 | 419 | } |
415 | 420 | procRole = "项目公司_财务"; |
416 | 421 | break; | ... | ... |
zr-cloud/zr-modules/zr-schsf/src/main/resources/mapper/McConstructionMapper.xml
... | ... | @@ -223,15 +223,73 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
223 | 223 | |
224 | 224 | <select id="selectMcConstructionByData" resultMap="McConstructionResult" parameterType="com.chinagas.modules.schsf.domain.McConstruction" > |
225 | 225 | <include refid="selectMcConstructionVo"/> |
226 | - where 1=1 | |
227 | - and t.region_name = #{regionName} | |
228 | - and t.group_name = #{groupName} | |
229 | - and t.company_name = #{companyName} | |
230 | - and t.company_code = #{companyCode} | |
231 | - and t.province = #{province} | |
232 | - and t.city = #{city} | |
233 | - and t.district = #{district} | |
234 | - and t.street = #{street} | |
226 | + where 1 = 1 | |
227 | + and t.region_name = #{regionName} | |
228 | + and t.group_name = #{groupName} | |
229 | + and t.company_name = #{companyName} | |
230 | + and t.company_code = #{companyCode} | |
231 | + <if test="province != null"> | |
232 | + and t.province = #{province} | |
233 | + </if> | |
234 | + <if test="city != null"> | |
235 | + and t.city = #{city} | |
236 | + </if> | |
237 | + <if test="district != null"> | |
238 | + and t.district = #{district} | |
239 | + </if> | |
240 | + <if test="street != null"> | |
241 | + and t.street = #{street} | |
242 | + </if> | |
243 | + <if test="statusCode != null"> | |
244 | + and status_code = #{statusCode} | |
245 | + </if> | |
235 | 246 | and t.vlg_or_cmty = #{vlgOrCmty} |
236 | 247 | </select> |
248 | + | |
249 | + <select id="selectMcConstructionNodeUserList" resultType="com.chinagas.modules.schsf.domain.dto.NodeUsersDto" parameterType="String"> | |
250 | + SELECT DISTINCT us.user_name,us.nick_name,un.user_id,un.ding_talk_union_id,un.ding_talk_user_id | |
251 | + FROM sys_menu menu | |
252 | + INNER JOIN sys_role_menu roleMenu on roleMenu.menu_id=menu.menu_id | |
253 | + INNER JOIN sys_role role on role.role_id= roleMenu.role_id | |
254 | + INNER JOIN sys_user_role userRole on userRole.role_id = role.role_id | |
255 | + INNER JOIN sys_user us on us.user_id = userRole.user_id | |
256 | + LEFT JOIN sys_user_unite un on un.user_id=us.user_id | |
257 | + WHERE menu.perms=#{nodeType,jdbcType=VARCHAR} | |
258 | + and role.data_scope='1' | |
259 | + UNION | |
260 | + SELECT DISTINCT us.user_name,us.nick_name,un.user_id,un.ding_talk_union_id,un.ding_talk_user_id | |
261 | + FROM sys_menu menu | |
262 | + INNER JOIN sys_role_menu roleMenu on roleMenu.menu_id=menu.menu_id | |
263 | + INNER JOIN sys_role role on role.role_id= roleMenu.role_id | |
264 | + INNER JOIN sys_user_role userRole on userRole.role_id = role.role_id | |
265 | + INNER JOIN sys_user us on us.user_id = userRole.user_id | |
266 | + INNER JOIN sys_user_dept userDept on userDept.user_id=us.user_id and userDept.dept_id in ( SELECT construction.company_code FROM mc_construction construction WHERE construction.id=#{id}) | |
267 | + LEFT JOIN sys_user_unite un on un.user_id=us.user_id | |
268 | + WHERE menu.perms=#{nodeType,jdbcType=VARCHAR} | |
269 | + and role.data_scope='3' | |
270 | + UNION | |
271 | + SELECT DISTINCT us.user_name,us.nick_name,un.user_id,un.ding_talk_union_id,un.ding_talk_user_id | |
272 | + FROM sys_menu menu | |
273 | + INNER JOIN sys_role_menu roleMenu on roleMenu.menu_id=menu.menu_id | |
274 | + INNER JOIN sys_role role on role.role_id= roleMenu.role_id | |
275 | + INNER JOIN sys_user_role userRole on userRole.role_id = role.role_id | |
276 | + INNER JOIN sys_user us on us.user_id = userRole.user_id | |
277 | + INNER JOIN sys_user_dept userDept on userDept.user_id=us.user_id | |
278 | + INNER JOIN sys_dept dept on dept.dept_id =userDept.dept_id | |
279 | + INNER JOIN sys_dept dept2 on dept2.dept_id in (SELECT a.dept_id FROM sys_dept a WHERE a.dept_id = dept.dept_id or find_in_set( dept.parent_id , ancestors ) ) | |
280 | + and dept2.dept_id = (SELECT construction.company_code FROM mc_construction construction WHERE construction.id=#{id} ) | |
281 | + LEFT JOIN sys_user_unite un on un.user_id=us.user_id | |
282 | + WHERE menu.perms= #{nodeType,jdbcType=VARCHAR} | |
283 | + and role.data_scope='4' | |
284 | + UNION | |
285 | + SELECT DISTINCT us.user_name,us.nick_name,un.user_id,un.ding_talk_union_id,un.ding_talk_user_id | |
286 | + FROM sys_menu menu | |
287 | + INNER JOIN sys_role_menu roleMenu on roleMenu.menu_id=menu.menu_id | |
288 | + INNER JOIN sys_role role on role.role_id= roleMenu.role_id | |
289 | + INNER JOIN sys_user_role userRole on userRole.role_id = role.role_id and userRole.user_id = (SELECT construction.create_by FROM mc_construction construction WHERE construction.id=#{id} ) | |
290 | + INNER JOIN sys_user us on us.user_id = userRole.user_id | |
291 | + LEFT JOIN sys_user_unite un on un.user_id=us.user_id | |
292 | + WHERE menu.perms=#{nodeType,jdbcType=VARCHAR} | |
293 | + and role.data_scope='5' | |
294 | + </select> | |
237 | 295 | </mapper> | ... | ... |
zr-cloud/zr-modules/zr-schsf/src/main/resources/mapper/McIgnitionMapper.xml
... | ... | @@ -207,7 +207,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
207 | 207 | <select id="selectMcIgnitionParamList" parameterType="com.chinagas.modules.schsf.domain.McIgnition" resultMap="McIgnitionResult"> |
208 | 208 | <include refid="selectMcIgnitionVo"/> |
209 | 209 | where 1=1 |
210 | - and t.status_code !='MAINTENANCE' | |
210 | + and t.status_code !='CANCEL' | |
211 | 211 | and t.def_flag ='0' |
212 | 212 | and t.region_name = #{regionName} |
213 | 213 | and t.group_name = #{groupName} | ... | ... |