wangxianzhang 3 years ago
parent
commit
7aeb92ba02
  1. 2
      epmet-admin/epmet-admin-server/deploy/docker-compose-dev.yml
  2. 12
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java
  3. 14
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/NeighborHoodController.java
  4. 4
      epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/form/IcDemandFormDTO.java
  5. 2
      epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/IcEventServiceImpl.java
  6. 27
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java
  7. 21
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java
  8. 2
      epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml

2
epmet-admin/epmet-admin-server/deploy/docker-compose-dev.yml

@ -9,7 +9,7 @@ services:
volumes:
- "/opt/epmet-cloud-logs/dev:/logs"
environment:
RUN_INSTRUCT: "java -Xms32m -Xmx200m -jar ../target/epmet-admin-server.jar"
RUN_INSTRUCT: "java -Xms32m -Xmx200m -jar ./epmet-admin.jar"
restart: "unless-stopped"
logging:
driver: local

12
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java

@ -778,6 +778,18 @@ public class RedisKeys {
return rootPrefix.concat("lock:").concat(methodName);
}
/**
* desc:获取分布式锁key
* @param customerId
* @return
*/
public static String getXiaoquEditLock(String customerId) {
if (StringUtils.isBlank(customerId)){
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"参数错误");
}
return rootPrefix.concat("lock:xiaoquedit").concat(customerId);
}
/**
* desc:获取更新 房屋内有居民数量的key
* @param customerId

14
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/NeighborHoodController.java

@ -21,6 +21,8 @@ import cn.afterturn.easypoi.excel.entity.TemplateExportParams;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.aop.NoRepeatSubmit;
import com.epmet.commons.tools.distributedlock.DistributedLock;
import com.epmet.commons.tools.redis.RedisKeys;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
@ -33,6 +35,7 @@ import com.epmet.entity.IcBuildingEntity;
import com.epmet.service.NeighborHoodService;
import com.epmet.util.ExcelPoiUtils;
import lombok.extern.slf4j.Slf4j;
import org.redisson.api.RLock;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.PostMapping;
@ -44,6 +47,7 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.TimeUnit;
/**
@ -61,6 +65,8 @@ public class NeighborHoodController {
private NeighborHoodService neighborHoodService;
@Resource
private IcBuildingDao icBuildingDao;
@Autowired
private DistributedLock distributedLock;
@PostMapping("neighborhoodlist")
@ -88,7 +94,13 @@ public class NeighborHoodController {
ValidatorUtils.validateEntity(formDTO, IcNeighborHoodAddFormDTO.UpdateShowGroup.class);
String customerId = tokenDTO.getCustomerId();
// String customerId = "123123";
neighborHoodService.updateNeighborhood(customerId,formDTO);
RLock lock = null;
try {
lock = distributedLock.getLock(RedisKeys.getXiaoquEditLock(tokenDTO.getCustomerId()), 120L, 3L, TimeUnit.SECONDS);
neighborHoodService.updateNeighborhood(customerId,formDTO);
} finally {
distributedLock.unLock(lock);
}
return new Result();
}

4
epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/form/IcDemandFormDTO.java

@ -115,7 +115,7 @@ public class IcDemandFormDTO implements Serializable {
/**
* 需求人联系电话
*/
@NotNull(message = "需求人不能为空",groups = AddUserShowGroup.class)
@NotNull(message = "需求人联系电话不能为空",groups = AddUserShowGroup.class)
private String demandUserMobile;
/**
@ -168,7 +168,7 @@ public class IcDemandFormDTO implements Serializable {
/**
* 二级分类Id
*/
@NotBlank(message = "分类id不能为空",groups = AddUserInternalGroup.class)
//@NotBlank(message = "分类id不能为空",groups = AddUserInternalGroup.class)
private String categoryId;
}

2
epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/IcEventServiceImpl.java

@ -173,7 +173,7 @@ public class IcEventServiceImpl extends BaseServiceImpl<IcEventDao, IcEventEntit
//1.参数校验,安全校验
//1-1.判断是否勾选处理方式,勾选了则分类不能为空
//勾选了立项或转需求或已完成时分类必须传
if (((StringUtils.isNotBlank(formDTO.getOperationType()) && !"0".equals(formDTO.getOperationType()))
if (((StringUtils.isNotBlank(formDTO.getOperationType()) && "1".equals(formDTO.getOperationType()))
|| (StringUtils.isNotBlank(formDTO.getStatus()) && "closed_case".equals(formDTO.getStatus()))) && CollectionUtils.isEmpty(formDTO.getCategoryList())) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "事件分类不能为空");
}

27
epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java

@ -30,6 +30,7 @@ import com.epmet.commons.tools.constant.AppClientConstant;
import com.epmet.commons.tools.constant.Constant;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.distributedlock.DistributedLock;
import com.epmet.commons.tools.dto.form.mq.MqBaseFormDTO;
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult;
import com.epmet.commons.tools.dto.result.OptionDataResultDTO;
@ -48,7 +49,6 @@ import com.epmet.commons.tools.security.user.LoginUserUtil;
import com.epmet.commons.tools.utils.*;
import com.epmet.commons.tools.utils.poi.excel.handler.FreezeAndFilter;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.constant.OrgInfoConstant;
import com.epmet.constant.SystemMessageType;
import com.epmet.constants.ImportTaskConstants;
import com.epmet.dto.IcResiUserDTO;
@ -76,6 +76,7 @@ import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.poifs.filesystem.OfficeXmlFileException;
import org.jetbrains.annotations.NotNull;
import org.redisson.api.RLock;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@ -90,6 +91,7 @@ import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
@ -139,6 +141,8 @@ public class IcResiUserController implements ResultDataResolver {
private RequestInterceptor requestInterceptor;
@Autowired
private ExecutorService executorService;
@Autowired
private DistributedLock distributedLock;
/**
* 模板枚举
@ -247,11 +251,17 @@ public class IcResiUserController implements ResultDataResolver {
@NoRepeatSubmit
@PostMapping("edit")
public Result edit(@LoginUser TokenDto tokenDto, @RequestBody List<IcResiUserFormDTO> formDTO) {
String resiUserId = icResiUserService.edit(tokenDto, formDTO);
//推送MQ事件
editResiMq(tokenDto.getCustomerId(), resiUserId);
RLock lock = null;
try {
lock = distributedLock.getLock(RedisKeys.getXiaoquEditLock(tokenDto.getCustomerId()), 120L, 3L, TimeUnit.SECONDS);
String resiUserId = icResiUserService.edit(tokenDto, formDTO);
//推送MQ事件
editResiMq(tokenDto.getCustomerId(), resiUserId);
this.sendVolunteerMsg(tokenDto.getCustomerId(), resiUserId);
this.sendVolunteerMsg(tokenDto.getCustomerId(), resiUserId);
} finally {
distributedLock.unLock(lock);
}
return new Result();
}
@ -599,7 +609,9 @@ public class IcResiUserController implements ResultDataResolver {
// 三.异步执行导入
executorService.execute(() -> {
boolean isAllSuccess = false;
RLock lock = null;
try {
lock = distributedLock.getLock(RedisKeys.getXiaoquEditLock(customerId), 120L, 3L, TimeUnit.SECONDS);
List<FormItemResult> formItemList = icResiUserService.listFormItems(customerId, IcFormCodeEnum.RESI_BASE_INFO.getCode());
isAllSuccess = icResiUserImportService.importIcResiInfoFromExcel(importTaskId, formItemList, importTempFileSavePath.toString(), response, IC_RESI_UPLOAD_DIR);
} catch (Throwable e) {
@ -638,6 +650,11 @@ public class IcResiUserController implements ResultDataResolver {
form.setMessageType(SystemMessageType.IC_RESI_USER_ADD);
form.setContent(mqMsg);
epmetMessageOpenFeignClient.sendSystemMsgByMQ(form);
//解锁
if (lock != null) {
lock.unlock();
}
}
});

21
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java

@ -26,6 +26,7 @@ import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.epmet.bean.ResiExportBaseInfoData;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.*;
import com.epmet.commons.tools.distributedlock.DistributedLock;
import com.epmet.commons.tools.dto.form.DictListFormDTO;
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult;
import com.epmet.commons.tools.dto.result.DictListResultDTO;
@ -153,6 +154,8 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
private UserBaseInfoDao userBaseInfoDao;
@Autowired
private EpmetUserOpenFeignClient epmetUserOpenFeignClient;
@Autowired
private DistributedLock distributedLock;
@ -2213,7 +2216,19 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
@Transactional(rollbackFor = Exception.class)
@Override
public List<String> changeIcResiUserBelongTo(TokenDto tokenDto, IcUserBelongToChangedFormDTO formDTO) {
List<String> resiUserIdList = baseDao.listUserIds(formDTO.getCustomerId(), formDTO.getSourceGridId());
if (StringUtils.isBlank(formDTO.getCustomerId()) || StringUtils.isBlank(formDTO.getSourceGridId())
||StringUtils.isBlank(formDTO.getTargetGridId())){
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"参数错误","参数错误");
}
IcResiUserEntity entity = new IcResiUserEntity();
entity.setGridId(formDTO.getTargetGridId());
LambdaQueryWrapper<IcResiUserEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(IcResiUserEntity::getGridId,formDTO.getSourceGridId())
.eq(IcResiUserEntity::getCustomerId,formDTO.getCustomerId());
baseDao.update(entity,wrapper);
//不调用原来的更新居民了 太慢
/*List<String> resiUserIdList = baseDao.listUserIds(formDTO.getCustomerId(), formDTO.getSourceGridId());
if (CollectionUtils.isEmpty(resiUserIdList)) {
return null;
}
@ -2232,8 +2247,8 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
map.put(FieldConstant.ID, userId);
this.edit(tokenDto, icResiUserFormDTOS);
});
return resiUserIdList;
*/
return null;
}
/**

2
epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml

@ -206,8 +206,8 @@
)
</if>
</where>
group by IC_RESI_USER.id
<if test="null != groupByTables and groupByTables.size() > 0">
group by IC_RESI_USER.id
<foreach item="groupTableName" collection="groupByTables" open="," separator="," close="">
${groupTableName}.ID
</foreach>

Loading…
Cancel
Save