From a80d56ef9f4d2fd3f1bc08dda23771c652021014 Mon Sep 17 00:00:00 2001
From: luoxinwu <934743099@qq.com>
Date: 星期四, 21 十二月 2023 17:05:52 +0800
Subject: [PATCH] 累计积分
---
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComStreetServiceImpl.java | 232 +++++++++++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 214 insertions(+), 18 deletions(-)
diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComStreetServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComStreetServiceImpl.java
index 1f9b4c0..7251db7 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComStreetServiceImpl.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComStreetServiceImpl.java
@@ -1,12 +1,39 @@
package com.panzhihua.service_community.service.impl;
+import java.util.ArrayList;
+import java.util.Comparator;
import java.util.List;
+import java.util.TreeSet;
+import java.util.stream.Collectors;
+
import javax.annotation.Resource;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.panzhihua.common.model.dtos.community.building.BuildingDto;
+import com.panzhihua.common.model.vos.StreetVO;
+import com.panzhihua.common.model.vos.area.StreetAndBuildVO;
+import com.panzhihua.common.model.vos.community.bigscreen.ScreenStatics;
+import com.panzhihua.common.model.vos.community.screen.event.EventPopulationSpecialStatisticsVO;
+import com.panzhihua.common.model.vos.neighbor.ActivityAnalysisVO;
+import com.panzhihua.common.model.vos.neighbor.UnitActivityAnalysisVO;
+import com.panzhihua.common.model.vos.user.AdministratorsUserVO;
+import com.panzhihua.common.service.community.CommunityService;
+import com.panzhihua.common.service.user.UserService;
+import com.panzhihua.common.utlis.Snowflake;
+import com.panzhihua.service_community.dao.*;
+
+import com.panzhihua.service_community.entity.ComEvent;
+
+import com.panzhihua.service_community.service.ComAreaTownCommunityService;
+import com.panzhihua.service_community.util.MyAESUtil;
+import com.panzhihua.service_community.util.WxDataUtil;
import org.springframework.beans.BeanUtils;
-import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@@ -19,8 +46,6 @@
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.model.vos.community.ComActVO;
import com.panzhihua.common.model.vos.community.ComStreetVO;
-import com.panzhihua.service_community.dao.ComActDAO;
-import com.panzhihua.service_community.dao.ComStreetDAO;
import com.panzhihua.service_community.model.dos.ComActDO;
import com.panzhihua.service_community.model.dos.ComStreetDO;
import com.panzhihua.service_community.service.ComStreetService;
@@ -37,6 +62,15 @@
@Resource
private ComStreetDAO comStreetDAO;
+ @Resource
+ private UserService userService;
+
+ @Resource
+ private ComEventMapper comEventMapper;
+
+ @Autowired
+ private CommunityService communityService;
+
/**
* 新增社区
*
@@ -45,10 +79,8 @@
* @return 新增结果
*/
@Override
- public R addStreet(ComStreetVO comStreetVO) {
- String password = comStreetVO.getPassword();
- String encode = new BCryptPasswordEncoder().encode(password);
- comStreetVO.setPassword(encode);
+ @Transactional
+ public R<ComStreetVO> addStreet(ComStreetVO comStreetVO) {
ComStreetDO comStreetDO = new ComStreetDO();
LambdaQueryWrapper<ComStreetDO> param = new QueryWrapper<ComStreetDO>().lambda();
param.eq(ComStreetDO::getName, comStreetVO.getName());
@@ -59,14 +91,31 @@
if (integer > 0) {
return R.fail(500, "街道已经存在");
}
- BeanUtils.copyProperties(comStreetVO, comStreetDO);
- int insert = comStreetDAO.insert(comStreetDO);
- if (insert > 0) {
- ComStreetDO comStreetDO1 = comStreetDAO.selectOne(param);
- BeanUtils.copyProperties(comStreetDO1, comStreetVO);
- return R.ok(comStreetVO);
+ AdministratorsUserVO administratorsUserVO=new AdministratorsUserVO();
+ administratorsUserVO.setType(3);
+ administratorsUserVO.setAccount(comStreetVO.getAccount());
+ administratorsUserVO.setPassword(comStreetVO.getPassword());
+ administratorsUserVO.setSocialType(1);
+ administratorsUserVO.setRoleId(777777777L);
+ administratorsUserVO.setStreetId(0L);
+ administratorsUserVO.setName(comStreetVO.getName());
+ administratorsUserVO.setUserId(Snowflake.getId());
+ R r=userService.addUserBackstageProperty(administratorsUserVO);
+ if(R.isOk(r)){
+ BeanUtils.copyProperties(comStreetVO, comStreetDO);
+ int insert = comStreetDAO.insert(comStreetDO);
+ if (insert > 0) {
+ AdministratorsUserVO administratorsUserVO1=new AdministratorsUserVO();
+ administratorsUserVO1.setUserId(Long.parseLong(r.getData().toString()));
+ administratorsUserVO1.setStreetId(comStreetDO.getStreetId());
+ userService.updateStreet(administratorsUserVO1);
+ ComStreetDO comStreetDO1 = comStreetDAO.selectOne(param);
+ BeanUtils.copyProperties(comStreetDO1, comStreetVO);
+ return R.ok(comStreetVO);
+ }
+ return R.fail(500, "");
}
- return R.fail(500, "");
+ return R.fail("账号已存在");
}
/**
@@ -111,10 +160,10 @@
if (ObjectUtils.isEmpty(comStreetDO)) {
return R.fail();
}
- ComActVO comActVO = new ComActVO();
- BeanUtils.copyProperties(comStreetDO, comActVO);
- comActVO.setAreaName(comActDAO.selectAreaName(comActVO.getAreaCode()));
- return R.ok(comActVO);
+ ComStreetVO comStreetVO = new ComStreetVO();
+ BeanUtils.copyProperties(comStreetDO, comStreetVO);
+ comStreetVO.setAdministrativeRegions(comStreetDAO.retrieveRegions(comStreetVO.getAreaCode().toString()));
+ return R.ok(comStreetVO);
}
/**
@@ -140,6 +189,9 @@
LambdaQueryWrapper<ComStreetDO> userLambdaQueryWrapper = Wrappers.lambdaQuery();
if (pageComStreetDTO.getName() != null) {
userLambdaQueryWrapper.like(ComStreetDO::getName, pageComStreetDTO.getName());
+ }
+ if (pageComStreetDTO.getAreaCode() != null) {
+ userLambdaQueryWrapper.like(ComStreetDO::getAreaCode, pageComStreetDTO.getAreaCode());
}
Page userPage = new Page(pageNum, pageSize);
IPage<ComStreetDO> doPager =
@@ -170,4 +222,148 @@
return R.fail();
}
+
+ /**
+ * 修改街道信息
+ * @param comStreetVO 街道信息
+ * */
+ @Override
+ public R update(ComStreetVO comStreetVO) {
+ ComStreetDO comStreetDO=new ComStreetDO();
+ BeanUtils.copyProperties(comStreetVO,comStreetDO );
+ return R.ok(comStreetDAO.updateById(comStreetDO));
+ }
+
+ /**
+ * 删除街道
+ * */
+ @Override
+ public R remove(Long id) {
+ //是否有未结事件
+ List<Long> longs = comActDAO.selectCommunityByStreetId(id);
+ List<ComEvent> comEvents = comEventMapper.selectList(new QueryWrapper<ComEvent>().lambda().in(ComEvent::getEventProcessStatus, (4), (6), (7), (8)).in(ComEvent::getRequestUserCommunity, longs));
+ if (comEvents.size()!=0){
+ return R.fail("有未结事件不可删除");
+ }
+ comStreetDAO.deleteById(id);
+ return R.ok();
+ }
+
+ @Override
+ public R removeCommunity(Long id) {
+ //是否有未结案件
+ List<ComEvent> comEvents = comEventMapper.selectList(new QueryWrapper<ComEvent>().lambda().in(ComEvent::getEventProcessStatus, (4), (6), (7), (8)).eq(ComEvent::getRequestUserCommunity, id));
+ if (comEvents.size()!=0){
+ return R.fail("有未结事件不可删除");
+ }
+ comActDAO.deleteById(id);
+ return R.ok();
+ }
+
+ @Override
+ public R repassCommunity(ComActVO comActVO) {
+ ComActDO comActDO=new ComActDO();
+ try {
+ comActDO.setPassword(MyAESUtil.Encrypt(comActVO.getPassword(),"Ryo7M3n8loC5Abcd" ));
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ comActDO.setCommunityId(comActVO.getCommunityId());
+ return R.ok(comActDAO.updateById(comActDO));
+ }
+
+ @Override
+ public R repssStreet(ComStreetVO comActVO) {
+ ComStreetDO comStreetDO=new ComStreetDO();
+ try {
+ comStreetDO.setPassword(MyAESUtil.Encrypt(comActVO.getPassword(),"Ryo7M3n8loC5Abcd" ));
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ comStreetDO.setStreetId(comActVO.getStreetId());
+ return R.ok(comStreetDAO.updateById(comStreetDO));
+ }
+
+ @Override
+ public R panzhihuaMap(String areaCode) {
+
+ List<ComActVO> comActVOS = comActDAO.panzhihuaMap(areaCode);
+ return R.ok(comActVOS);
+ }
+
+ @Override
+ public R searchStreet(BuildingDto buildingDto) {
+ QueryWrapper<ComStreetDO> wrapper = new QueryWrapper<>();
+ wrapper.eq(buildingDto.getAreaCode()!= null,"area_code",buildingDto.getAreaCode());
+ wrapper.eq("app_id","wx118de8a734d269f0");
+ List<ComStreetDO> comStreetDOS = comStreetDAO.selectList(wrapper);
+// ArrayList<ComStreetDO> collect = comStreetDOS.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(
+// Comparator.comparing(ComStreetDO::getAreaCode))), ArrayList::new));
+ List<StreetVO> list = comStreetDOS.stream().map(v -> {
+ StreetVO vo = new StreetVO();
+ vo.setStreetId(String.valueOf(v.getStreetId()));
+ vo.setName(v.getName());
+ return vo;
+ }).collect(Collectors.toList());
+ return R.ok(list);
+ }
+
+ @Override
+ public R oneTagThreeReal(Long street) {
+ List<StreetAndBuildVO> streetAndBuildVOS = comActDAO.oneTagThreeReal(street);
+ return R.ok(streetAndBuildVOS);
+ }
+
+ @Override
+ public R getScreenStatics() {
+ ScreenStatics screenStatics = comActDAO.getScreenStatics();
+ WxDataUtil wxDataUtil=new WxDataUtil();
+ screenStatics.setDayUser(wxDataUtil.getDayUser());
+ screenStatics.setCountUser(wxDataUtil.getMonthUser());
+ return R.ok(screenStatics);
+ }
+
+ @Override
+ public R populationStatics(Long streetId) {
+ StreetAndBuildVO vo = new StreetAndBuildVO();
+ List<StreetAndBuildVO> list = comActDAO.oneTagThreeReal(streetId);
+ if(list != null){
+ for (StreetAndBuildVO basics : list) {
+ vo.setPeopleNum(vo.getPeopleNum() + basics.getPeopleNum());
+ vo.setVillageNum(vo.getVillageNum() + basics.getVillageNum());
+ vo.setBuildNum(vo.getBuildNum() + basics.getBuildNum());
+ }
+ }
+ EventPopulationSpecialStatisticsVO populationSpecial = comActDAO.getPopulationSpecial(streetId);
+ if(populationSpecial != null){
+ populationSpecial.setOtherTotal(populationSpecial.getZjTotal() + populationSpecial.getSfTotal()
+ + populationSpecial.getXsTotal() + populationSpecial.getXjTotal()
+ + populationSpecial.getJzTotal() + populationSpecial.getXdTotal());
+ populationSpecial.setLnTotal(comActDAO.getPopulationAge(streetId,60));
+ populationSpecial.setGlTotal(comActDAO.getPopulationAge(streetId,80));
+ vo.setSpecialStatisticsVo(populationSpecial);
+ }
+ vo.setSpecialStatisticsVo(populationSpecial);
+ return R.ok(vo);
+ }
+
+ @Override
+ public R probably(Integer year,String belongTo) {
+ ActivityAnalysisVO activityVO=new ActivityAnalysisVO();
+// String beginTime=null;
+// String endTime=null;
+// if (null != year){
+// //设置开始,截止时间
+// beginTime=year.toString().concat("-01-01");
+// endTime=year.toString().concat("-12-31");
+// }
+ activityVO.setUnitCount(comActDAO.arriveUnit(belongTo));
+ R r = communityService.institutionalUnitServiceAnalysis(year, null, null, null, null, null, belongTo, null, null);
+ Object data = r.getData();
+ String jsonString = JSON.toJSONString(data);
+ ActivityAnalysisVO activityAnalysisVO = JSON.parseObject(jsonString, ActivityAnalysisVO.class);
+ activityVO.setUnitServiceTotalTime(activityAnalysisVO.getUnitServiceTotalTime());
+ return R.ok(activityVO);
+ }
+
}
--
Gitblit v1.7.1