old mode 100644
new mode 100755
| | |
| | | package com.java110.job.adapt.Repair; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.core.factory.WechatFactory; |
| | | import com.java110.dto.CommunityMemberDto; |
| | | import com.java110.dto.basePrivilege.BasePrivilegeDto; |
| | | import com.java110.dto.community.CommunityDto; |
| | | import com.java110.dto.repair.RepairDto; |
| | |
| | | import com.java110.intf.store.ISmallWechatAttrInnerServiceSMO; |
| | | import com.java110.intf.user.IStaffAppAuthInnerServiceSMO; |
| | | import com.java110.job.adapt.DatabusAdaptImpl; |
| | | import com.java110.po.owner.RepairPoolPo; |
| | | import com.java110.utils.cache.MappingCache; |
| | | import com.java110.utils.util.Assert; |
| | | import com.java110.utils.util.StringUtil; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import com.java110.core.log.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.http.ResponseEntity; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.web.client.RestTemplate; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | |
| | | @Override |
| | | public void execute(Business business, List<Business> businesses) { |
| | | JSONObject data = business.getData(); |
| | | JSONArray businessOwnerRepairs = new JSONArray(); |
| | | System.out.println("收到日志:>>>>>>>>>>>>>" + data.toJSONString()); |
| | | if (data.containsKey(RepairPoolPo.class.getSimpleName())) { |
| | | Object bObj = data.get(RepairPoolPo.class.getSimpleName()); |
| | | if (bObj instanceof JSONObject) { |
| | | businessOwnerRepairs.add(bObj); |
| | | } else if (bObj instanceof List) { |
| | | businessOwnerRepairs = JSONArray.parseArray(JSONObject.toJSONString(bObj)); |
| | | } else { |
| | | businessOwnerRepairs = (JSONArray) bObj; |
| | | } |
| | | } else { |
| | | if (data instanceof JSONObject) { |
| | | businessOwnerRepairs.add(data); |
| | | } |
| | | } |
| | | //JSONObject businessOwnerCar = data.getJSONObject("businessOwnerCar"); |
| | | for (int bOwnerRepairIndex = 0; bOwnerRepairIndex < businessOwnerRepairs.size(); bOwnerRepairIndex++) { |
| | | JSONObject businessOwnerRepair = businessOwnerRepairs.getJSONObject(bOwnerRepairIndex); |
| | | doDealOwnerRepair(business, businessOwnerRepair); |
| | | } |
| | | } |
| | | |
| | | private void doDealOwnerRepair(Business business, JSONObject businessOwnerRepair) { |
| | | RepairDto repairDto = new RepairDto(); |
| | | repairDto.setbId(business.getbId()); |
| | | repairDto.setStatusCd("0"); |
| | | repairDto.setRepairId(businessOwnerRepair.getString("repairId")); |
| | | // repairDto.setStatusCd("0"); |
| | | List<RepairDto> repairDtos = repairInnerServiceSMO.queryRepairs(repairDto); |
| | | //获取报修类型 |
| | | String repairTypeName = repairDtos.get(0).getRepairTypeName(); |
| | |
| | | logger.info("推送微信模板,获取accessToken失败:{}", accessToken); |
| | | return; |
| | | } |
| | | //查询小区物业公司 |
| | | CommunityMemberDto communityMemberDto = new CommunityMemberDto(); |
| | | communityMemberDto.setCommunityId(communityDto.getCommunityId()); |
| | | communityMemberDto.setAuditStatusCd(CommunityMemberDto.AUDIT_STATUS_NORMAL); |
| | | communityMemberDto.setMemberTypeCd(CommunityMemberDto.MEMBER_TYPE_PROPERTY); |
| | | List<CommunityMemberDto> communityMemberDtos = communityInnerServiceSMO.getCommunityMembers(communityMemberDto); |
| | | Assert.listOnlyOne(communityMemberDtos, "小区没有 物业公司"); |
| | | // 根据特定权限查询 有该权限的 员工 |
| | | BasePrivilegeDto basePrivilegeDto = new BasePrivilegeDto(); |
| | | basePrivilegeDto.setResource("/wechatRepairRegistration"); |
| | | basePrivilegeDto.setStoreId(communityMemberDtos.get(0).getMemberId()); |
| | | basePrivilegeDto.setCommunityId(communityMemberDtos.get(0).getCommunityId()); |
| | | List<UserDto> userDtos = privilegeInnerServiceSMO.queryPrivilegeUsers(basePrivilegeDto); |
| | | String url = sendMsgUrl + accessToken; |
| | | List<String> userIds = new ArrayList<>(); |
| | | for (UserDto userDto : userDtos) { |
| | | if (userIds.contains(userDto.getUserId())) { |
| | | continue; |
| | | } |
| | | userIds.add(userDto.getUserId()); |
| | | //根据 userId 查询到openId |
| | | StaffAppAuthDto staffAppAuthDto = new StaffAppAuthDto(); |
| | | staffAppAuthDto.setStaffId(userDto.getUserId()); |
| | | staffAppAuthDto.setAppType("WECHAT"); |
| | | List<StaffAppAuthDto> staffAppAuthDtos = staffAppAuthInnerServiceSMO.queryStaffAppAuths(staffAppAuthDto); |
| | | if (staffAppAuthDtos == null || staffAppAuthDtos.size() < 1) { |
| | | continue; |
| | | } |
| | | String openId = staffAppAuthDtos.get(0).getOpenId(); |
| | | Data data = new Data(); |
| | | PropertyFeeTemplateMessage templateMessage = new PropertyFeeTemplateMessage(); |
| | |
| | | data.setKeyword3(new Content(paramIn.getString("context"))); |
| | | data.setRemark(new Content("请您及时确认信息,并安排相关人员进行处理,感谢您的使用!")); |
| | | templateMessage.setData(data); |
| | | String wechatUrl = MappingCache.getValue("OWNER_WECHAT_URL"); |
| | | //获取员工公众号地址 |
| | | String wechatUrl = MappingCache.getValue("STAFF_WECHAT_URL"); |
| | | templateMessage.setUrl(wechatUrl); |
| | | logger.info("发送模板消息内容:{}", JSON.toJSONString(templateMessage)); |
| | | ResponseEntity<String> responseEntity = outRestTemplate.postForEntity(url, JSON.toJSONString(templateMessage), String.class); |