Browse Source

程序优化

master
sunyuchao 4 years ago
parent
commit
822b61b1a4
  1. 14
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java

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

@ -116,6 +116,7 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
* @Description 党建互联平台--保存居民信息
**/
@Override
@Transactional(rollbackFor = Exception.class)
public void add(TokenDto tokenDto, List<IcResiUserFormDTO> formDTO) {
//循环自动拼接sql语句,往多个表新增数据
//1.先往主表新增数据
@ -123,7 +124,7 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
String resiUserId = UUID.randomUUID().toString().replaceAll("-", "");
formDTO.forEach(d -> {
if ("ic_resi_user".equals(d.getTableName())) {
Map<String, String> map = d.getList().get(0);
LinkedHashMap<String, String> map = d.getList().get(0);
map.put("id", resiUserId);
map.put("customer_id", tokenDto.getCustomerId());
map.put("created_by", tokenDto.getUserId());
@ -143,7 +144,7 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
//2.循环字表新增数据
formDTO.forEach(d -> {
if (!"ic_resi_user".equals(d.getTableName())) {
d.getList().forEach(map -> {
for (LinkedHashMap<String, String> map : d.getList()) {
map.put("id", UUID.randomUUID().toString().replaceAll("-", ""));
map.put("ic_resi_user", resiUserId);
map.put("customer_id", tokenDto.getCustomerId());
@ -151,7 +152,7 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
map.put("updated_by", tokenDto.getUserId());
//字表新增数据
baseDao.add(d.getTableName(), map);
});
}
}
});
@ -162,10 +163,11 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
* @Description 党建互联平台--修改居民信息
**/
@Override
@Transactional(rollbackFor = Exception.class)
public void edit(TokenDto tokenDto, List<IcResiUserFormDTO> formDTO) {
//1.校验主表数据是否存在
String resiUserId = "";
Map<String, String> map = new HashMap<>();
LinkedHashMap<String, String> map = new LinkedHashMap<>();
for (IcResiUserFormDTO d : formDTO) {
if ("ic_resi_user".equals(d.getTableName())) {
map = d.getList().get(0);
@ -192,7 +194,7 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
String finalResiUserId = resiUserId;
formDTO.forEach(d -> {
if (!"ic_resi_user".equals(d.getTableName())) {
d.getList().forEach(hash -> {
for (LinkedHashMap<String, String> hash : d.getList()) {
hash.put("updated_by", tokenDto.getUserId());
if (!hash.containsKey("ID")) {
hash.put("id", UUID.randomUUID().toString().replaceAll("-", ""));
@ -205,7 +207,7 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
//字表更新数据
baseDao.upTable(d.getTableName(), hash.get("ID"), hash);
}
});
}
}
});

Loading…
Cancel
Save