Browse Source

Merge remote-tracking branch 'remotes/origin/dev_ic_platform' into develop

master
jianjun 4 years ago
parent
commit
72be4f984a
  1. 5
      epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/form/CustomerFormQueryDTO.java
  2. 6
      epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/IcFormController.java
  3. 4
      epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/dao/IcFormDao.java
  4. 4
      epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcFormServiceImpl.java
  5. 5
      epmet-module/oper-customize/oper-customize-server/src/main/resources/mapper/IcFormDao.xml
  6. 107
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcResiDemandDictDTO.java
  7. 84
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiDemandDictController.java
  8. 64
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java
  9. 37
      epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiDemandDictDao.java
  10. 10
      epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java
  11. 73
      epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcResiDemandDictEntity.java
  12. 64
      epmet-user/epmet-user-server/src/main/java/com/epmet/handler/ExcelDiceAddressListHandlerImpl.java
  13. 96
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiDemandDictService.java
  14. 2
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserService.java
  15. 99
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiDemandDictServiceImpl.java
  16. 54
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java
  17. 26
      epmet-user/epmet-user-server/src/main/resources/mapper/IcResiDemandDictDao.xml
  18. 23
      epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml

5
epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/form/CustomerFormQueryDTO.java

@ -19,5 +19,10 @@ public class CustomerFormQueryDTO implements Serializable {
@NotBlank(message = "tokenDto获取customerId不能为空",groups =AddUserInternalGroup.class )
private String customerId;
/**
* 是否动态
*/
private Boolean dynamic;
}

6
epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/IcFormController.java

@ -114,6 +114,9 @@ public class IcFormController {
if (StringUtils.isBlank(formDto.getCustomerId())){
formDto.setCustomerId(customerId);
}
if (formDto.getDynamic() == null){
formDto.setDynamic(true);
}
ValidatorUtils.validateEntity(formDto,CustomerFormQueryDTO.AddUserInternalGroup.class);
return new Result<CustomerFormResultDTO>().ok(icFormService.getCustomerForm(formDto));
}
@ -131,6 +134,9 @@ public class IcFormController {
@PostMapping("conditionlist")
public Result<List<ConditionResultDTO>> queryConditionList(@LoginUser TokenDto tokenDto, @RequestBody CustomerFormQueryDTO formDto){
formDto.setCustomerId(tokenDto.getCustomerId());
if (formDto.getDynamic() == null){
formDto.setDynamic(true);
}
ValidatorUtils.validateEntity(formDto,CustomerFormQueryDTO.AddUserInternalGroup.class);
return new Result<List<ConditionResultDTO>>().ok(icFormItemService.queryConditionList(formDto));
}

4
epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/dao/IcFormDao.java

@ -47,7 +47,7 @@ public interface IcFormDao extends BaseDao<IcFormEntity> {
*/
CustomerFormResultDTO selectByCode(@Param("customerId") String customerId, @Param("formCode") String formCode);
List<FormItem> selectItemList(String formId);
List<FormItem> selectItemList(String formId, Boolean dynamic);
List<FormItem> selectItemListByGroupId(String groupId);
List<OptionDTO> selectListOption(String itemId);
@ -55,4 +55,4 @@ public interface IcFormDao extends BaseDao<IcFormEntity> {
List<FormGroupDTO> selectListGroup(String formId);
FormGroupDTO selectChildGroup(String itemId);
}
}

4
epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcFormServiceImpl.java

@ -118,7 +118,7 @@ public class IcFormServiceImpl extends BaseServiceImpl<IcFormDao, IcFormEntity>
if (null == resultDTO) {
throw new RenException(EpmetErrorCode.CUSTOMER_FORM_NOT_EXITS.getCode(),EpmetErrorCode.CUSTOMER_FORM_NOT_EXITS.getMsg());
}
List<FormItem> itemList=baseDao.selectItemList(resultDTO.getFormId());
List<FormItem> itemList=baseDao.selectItemList(resultDTO.getFormId(),formDto.getDynamic());
List<FormGroupDTO> groupList=baseDao.selectListGroup(resultDTO.getFormId());
resultDTO.setItemList(itemList);
@ -126,4 +126,4 @@ public class IcFormServiceImpl extends BaseServiceImpl<IcFormDao, IcFormEntity>
return resultDTO;
}
}
}

5
epmet-module/oper-customize/oper-customize-server/src/main/resources/mapper/IcFormDao.xml

@ -106,6 +106,9 @@
WHERE
fi.DEL_FLAG = '0'
AND fi.FORM_ID = #{formId}
<if test="dynamic != null">
fi.DYNAMIC = #{dynamic}
</if>
AND fi.ITEM_GROUP_ID = '0'
ORDER BY
fi.SORT ASC
@ -196,4 +199,4 @@
g.SORT ASC
</select>
</mapper>
</mapper>

107
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcResiDemandDictDTO.java

@ -0,0 +1,107 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.dto;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 居民需求字典表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2021-10-27
*/
@Data
public class IcResiDemandDictDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 唯一标识
*/
private String id;
/**
* 客户Id customer.id
*/
private String customerId;
/**
* 父级
*/
private String parentCode;
/**
* 字典值
*/
private String categoryCode;
/**
* 字典描述
*/
private String categoryName;
/**
* 级别
*/
private String level;
/**
* 备注
*/
private String remark;
/**
* 排序
*/
private Integer sort;
/**
* 删除标识0.未删除 1.已删除
*/
private Integer delFlag;
/**
* 乐观锁
*/
private Integer revision;
/**
* 创建人
*/
private String createdBy;
/**
* 创建时间
*/
private Date createdTime;
/**
* 更新人
*/
private String updatedBy;
/**
* 更新时间
*/
private Date updatedTime;
}

84
epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiDemandDictController.java

@ -0,0 +1,84 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.controller;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.AssertUtils;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.commons.tools.validator.group.AddGroup;
import com.epmet.commons.tools.validator.group.DefaultGroup;
import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.dto.IcResiDemandDictDTO;
import com.epmet.service.IcResiDemandDictService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
/**
* 居民需求字典表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2021-10-27
*/
@RestController
@RequestMapping("icresidemanddict")
public class IcResiDemandDictController {
@Autowired
private IcResiDemandDictService icResiDemandDictService;
@GetMapping("page")
public Result<PageData<IcResiDemandDictDTO>> page(@RequestParam Map<String, Object> params){
PageData<IcResiDemandDictDTO> page = icResiDemandDictService.page(params);
return new Result<PageData<IcResiDemandDictDTO>>().ok(page);
}
@GetMapping("{id}")
public Result<IcResiDemandDictDTO> get(@PathVariable("id") String id){
IcResiDemandDictDTO data = icResiDemandDictService.get(id);
return new Result<IcResiDemandDictDTO>().ok(data);
}
@PostMapping
public Result save(@RequestBody IcResiDemandDictDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
icResiDemandDictService.save(dto);
return new Result();
}
@PutMapping
public Result update(@RequestBody IcResiDemandDictDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
icResiDemandDictService.update(dto);
return new Result();
}
@DeleteMapping
public Result delete(@RequestBody String[] ids){
//效验数据
AssertUtils.isArrayEmpty(ids, "id");
icResiDemandDictService.delete(ids);
return new Result();
}
}

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

@ -39,14 +39,19 @@ import com.epmet.dto.form.IcResiUserFormDTO;
import com.epmet.dto.result.CustomerFormResultDTO;
import com.epmet.excel.IcResiUserExcel;
import com.epmet.feign.OperCustomizeOpenFeignClient;
import com.epmet.handler.ExcelDiceAddressListHandlerImpl;
import com.epmet.service.IcResiUserService;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.io.FileOutputStream;
import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
@ -121,8 +126,8 @@ public class IcResiUserController {
* @Description 党建互联平台--修改居民信息
**/
@PostMapping("edit")
public Result edit(@LoginUser TokenDto tokenDto, @RequestBody IcResiUserFormDTO formDTO) {
icResiUserService.edit(formDTO);
public Result edit(@LoginUser TokenDto tokenDto, @RequestBody List<IcResiUserFormDTO> formDTO) {
icResiUserService.edit(tokenDto, formDTO);
return new Result();
}
@ -137,18 +142,52 @@ public class IcResiUserController {
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode());
}
System.out.println(JSON.toJSONString(resultForm.getData()));
List<ExcelExportEntity> colList = new ArrayList<>();
List<ExcelExportEntity> firstHeaderList = new ArrayList<>();
resultForm.getData().getItemList().forEach(item->{
ExcelExportEntity header = new ExcelExportEntity(item.getLabel(),item.getColumnName().concat(String.valueOf(item.getColumnNum())));
header.setNeedMerge(true);
firstHeaderList.add(header);
String baseTableName = "resi_base_info";
if (item.getChildGroup() != null){
//baseTableName单独的一个sheet
if (baseTableName.equals(item.getTableName())){
header = new ExcelExportEntity(item.getChildGroup().getLabel(),item.getChildGroup().getTableName());
header.setNeedMerge(true);
}else{
header = new ExcelExportEntity(item.getChildGroup().getLabel(),item.getChildGroup().getTableName());
header.setNeedMerge(true);
}
if (item.getColumnName().equals("GENDER")){
header.setReplace(new String[]{"男_1","女_2"});
}
List<ExcelExportEntity> secondHeaderList = new ArrayList<>();
item.getChildGroup().getItemList().forEach(item2->{
ExcelExportEntity secondHeader = new ExcelExportEntity(item2.getLabel(),item2.getColumnName().concat(String.valueOf(item2.getColumnNum())));
secondHeader.setNeedMerge(true);
secondHeaderList.add(secondHeader);
if (CollectionUtils.isNotEmpty(item2.getOptions())){
List<ExcelExportEntity> thirdHeaderList = new ArrayList<>();
item2.getOptions().forEach(child->{
ExcelExportEntity thirdHeader = new ExcelExportEntity(child.getLabel());
thirdHeader.setNeedMerge(true);
thirdHeaderList.add(thirdHeader);
});
secondHeader.setList(thirdHeaderList);
}
});
header.setList(secondHeaderList);
firstHeaderList.add(header);
}
});
ExcelExportEntity desginGroup = new ExcelExportEntity("表头名称","键");
/* ExcelExportEntity desginGroup = new ExcelExportEntity("表头名称","键");
desginGroup.setNeedMerge(true);
List<ExcelExportEntity> paramCols = new ArrayList<>();
List<String> headerList = Arrays.asList("头1","头2","头3");
@ -157,15 +196,16 @@ public class IcResiUserController {
});
desginGroup.setList(paramCols);
colList.add(desginGroup);
colList.add(desginGroup);*/
List<Map<String, String>> dataList =new ArrayList<>();
Map<String,String> dataMap = new HashMap<>();
dataMap.put("头1","1");
dataMap.put("头2","2");
dataMap.put("头3","3");
dataMap.put("GENDER0","1");
dataMap.put("ID_CARD0","371888991");
dataList.add(dataMap);
ExportParams entity = new ExportParams();
Workbook workbook = ExcelExportUtil.exportExcel(entity, colList, dataList);
ExportParams exportParams = new ExportParams();
exportParams.setDictHandler(new ExcelDiceAddressListHandlerImpl());
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, firstHeaderList, dataList);
//ExcelExportUtil.exportExcel
FileOutputStream fos = new FileOutputStream("//Users/liujianjun/Downloads/基础信息表/Dow.tt.xls");
workbook.write(fos);

37
epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiDemandDictDao.java

@ -0,0 +1,37 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.commons.tools.dto.result.OptionResultDTO;
import com.epmet.entity.IcResiDemandDictEntity;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* 居民需求字典表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2021-10-27
*/
@Mapper
public interface IcResiDemandDictDao extends BaseDao<IcResiDemandDictEntity> {
List<OptionResultDTO> selectDemandOptions(String customerId);
List<OptionResultDTO> selectChildDemands(String parentCode);
}

10
epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java

@ -33,5 +33,15 @@ import java.util.Map;
@Mapper
public interface IcResiUserDao extends BaseDao<IcResiUserEntity> {
/**
* @Author sun
* @Description 居民信息各表新增数据
**/
void add(@Param("tableName") String tableName, @Param("map") Map<String, String> map);
/**
* @Author sun
* @Description 更新或新增居民信息各表数据
**/
void upTable(@Param("tableName") String tableName, @Param("id") String id, @Param("map") Map<String, String> map);
}

73
epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcResiDemandDictEntity.java

@ -0,0 +1,73 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.epmet.commons.mybatis.entity.BaseEpmetEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 居民需求字典表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2021-10-27
*/
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("ic_resi_demand_dict")
public class IcResiDemandDictEntity extends BaseEpmetEntity {
private static final long serialVersionUID = 1L;
/**
* 客户Id customer.id
*/
private String customerId;
/**
* 父级
*/
private String parentCode;
/**
* 字典值
*/
private String categoryCode;
/**
* 字典描述
*/
private String categoryName;
/**
* 级别
*/
private String level;
/**
* 备注
*/
private String remark;
/**
* 排序
*/
private Integer sort;
}

64
epmet-user/epmet-user-server/src/main/java/com/epmet/handler/ExcelDiceAddressListHandlerImpl.java

@ -0,0 +1,64 @@
package com.epmet.handler;
import cn.afterturn.easypoi.handler.inter.IExcelDictHandler;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 模拟使用,生产请用真实字典
*
* @author jueyue on 20-4-26.
*/
public class ExcelDiceAddressListHandlerImpl implements IExcelDictHandler {
/**
* 返回字典所有值
* key: dictKey
*
* @param dict 字典Key
* @return
*/
public List<Map> getList(String dict) {
List<Map> list = new ArrayList<>();
Map<String, String> dictMap = new HashMap<>();
dictMap.put("dictKey", "1");
dictMap.put("dictValue", "男");
list.add(dictMap);
dictMap = new HashMap<>();
dictMap.put("dictKey", "2");
dictMap.put("dictValue", "女");
list.add(dictMap);
return list;
}
@Override
public String toName(String dict, Object obj, String name, Object value) {
if ("level".equals(dict)) {
int level = Integer.parseInt(value.toString());
switch (level) {
case 1:
return "男";
case 2:
return "女";
}
}
return null;
}
@Override
public String toValue(String dict, Object obj, String name, Object value) {
if ("level".equals(dict)) {
int level = Integer.parseInt(value.toString());
switch (level) {
case 1:
return "男";
case 2:
return "女";
}
}
return null;
}
}

96
epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiDemandDictService.java

@ -0,0 +1,96 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.service;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData;
import com.epmet.dto.IcResiDemandDictDTO;
import com.epmet.entity.IcResiDemandDictEntity;
import java.util.List;
import java.util.Map;
/**
* 居民需求字典表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2021-10-27
*/
public interface IcResiDemandDictService extends BaseService<IcResiDemandDictEntity> {
/**
* 默认分页
*
* @param params
* @return PageData<IcResiDemandDictDTO>
* @author generator
* @date 2021-10-27
*/
PageData<IcResiDemandDictDTO> page(Map<String, Object> params);
/**
* 默认查询
*
* @param params
* @return java.util.List<IcResiDemandDictDTO>
* @author generator
* @date 2021-10-27
*/
List<IcResiDemandDictDTO> list(Map<String, Object> params);
/**
* 单条查询
*
* @param id
* @return IcResiDemandDictDTO
* @author generator
* @date 2021-10-27
*/
IcResiDemandDictDTO get(String id);
/**
* 默认保存
*
* @param dto
* @return void
* @author generator
* @date 2021-10-27
*/
void save(IcResiDemandDictDTO dto);
/**
* 默认更新
*
* @param dto
* @return void
* @author generator
* @date 2021-10-27
*/
void update(IcResiDemandDictDTO dto);
/**
* 批量删除
*
* @param ids
* @return void
* @author generator
* @date 2021-10-27
*/
void delete(String[] ids);
}

2
epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserService.java

@ -105,5 +105,5 @@ public interface IcResiUserService extends BaseService<IcResiUserEntity> {
* @Author sun
* @Description 党建互联平台--修改居民信息
**/
void edit(IcResiUserFormDTO formDTO);
void edit(TokenDto tokenDto, List<IcResiUserFormDTO> formDTO);
}

99
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiDemandDictServiceImpl.java

@ -0,0 +1,99 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.dao.IcResiDemandDictDao;
import com.epmet.dto.IcResiDemandDictDTO;
import com.epmet.entity.IcResiDemandDictEntity;
import com.epmet.service.IcResiDemandDictService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
* 居民需求字典表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2021-10-27
*/
@Service
public class IcResiDemandDictServiceImpl extends BaseServiceImpl<IcResiDemandDictDao, IcResiDemandDictEntity> implements IcResiDemandDictService {
@Override
public PageData<IcResiDemandDictDTO> page(Map<String, Object> params) {
IPage<IcResiDemandDictEntity> page = baseDao.selectPage(
getPage(params, FieldConstant.CREATED_TIME, false),
getWrapper(params)
);
return getPageData(page, IcResiDemandDictDTO.class);
}
@Override
public List<IcResiDemandDictDTO> list(Map<String, Object> params) {
List<IcResiDemandDictEntity> entityList = baseDao.selectList(getWrapper(params));
return ConvertUtils.sourceToTarget(entityList, IcResiDemandDictDTO.class);
}
private QueryWrapper<IcResiDemandDictEntity> getWrapper(Map<String, Object> params){
String id = (String)params.get(FieldConstant.ID_HUMP);
QueryWrapper<IcResiDemandDictEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id);
return wrapper;
}
@Override
public IcResiDemandDictDTO get(String id) {
IcResiDemandDictEntity entity = baseDao.selectById(id);
return ConvertUtils.sourceToTarget(entity, IcResiDemandDictDTO.class);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void save(IcResiDemandDictDTO dto) {
IcResiDemandDictEntity entity = ConvertUtils.sourceToTarget(dto, IcResiDemandDictEntity.class);
insert(entity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(IcResiDemandDictDTO dto) {
IcResiDemandDictEntity entity = ConvertUtils.sourceToTarget(dto, IcResiDemandDictEntity.class);
updateById(entity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(String[] ids) {
// 逻辑删除(@TableLogic 注解)
baseDao.deleteBatchIds(Arrays.asList(ids));
}
}

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

@ -21,6 +21,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.dto.TokenDto;
@ -34,6 +35,7 @@ import com.epmet.entity.IcResiUserEntity;
import com.epmet.feign.GovOrgOpenFeignClient;
import com.epmet.redis.IcResiUserRedis;
import com.epmet.service.IcResiUserService;
import oracle.sql.NUMBER;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@ -41,10 +43,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.*;
/**
* 用户基础信息
@ -163,7 +162,52 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
* @Description 党建互联平台--修改居民信息
**/
@Override
public void edit(IcResiUserFormDTO formDTO) {
public void edit(TokenDto tokenDto, List<IcResiUserFormDTO> formDTO) {
//1.校验主表数据是否存在
String resiUserId = "";
Map<String, String> map = new HashMap<>();
for (IcResiUserFormDTO d : formDTO) {
if ("ic_resi_user".equals(d.getTableName())) {
map = d.getList().get(0);
if (!map.containsKey("ID")) {
throw new RenException(String.format("居民信息修改-居民信息表主键值为空"));
}
resiUserId = map.get("ID");
}
}
if (null == map) {
throw new RenException(String.format("居民信息修改,参数错误,未传入基础信息Id"));
}
IcResiUserEntity entity = baseDao.selectById(resiUserId);
if (null == entity) {
throw new RenException(String.format("居民信息修改,获取基础信息失败,基础信息Id->", resiUserId));
}
//2.更新主表数据
if (map.size() > NumConstant.ONE) {
map.put("updated_by", tokenDto.getUserId());
baseDao.upTable("ic_resi_user", resiUserId, map);
}
//3.循环更新或新增字表数据
String finalResiUserId = resiUserId;
formDTO.forEach(d -> {
if (!"ic_resi_user".equals(d.getTableName())) {
d.getList().forEach(hash -> {
hash.put("updated_by", tokenDto.getUserId());
if (!hash.containsKey("ID")) {
hash.put("id", UUID.randomUUID().toString().replaceAll("-", ""));
hash.put("ic_resi_user", finalResiUserId);
hash.put("customer_id", tokenDto.getCustomerId());
hash.put("created_by", tokenDto.getUserId());
//字表新增数据
baseDao.add(d.getTableName(), hash);
} else {
//字表更新数据
baseDao.upTable(d.getTableName(), hash.get("ID"), hash);
}
});
}
});
}

26
epmet-user/epmet-user-server/src/main/resources/mapper/IcResiDemandDictDao.xml

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.epmet.dao.IcResiDemandDictDao">
<resultMap type="com.epmet.entity.IcResiDemandDictEntity" id="icResiDemandDictMap">
<result property="id" column="ID"/>
<result property="customerId" column="CUSTOMER_ID"/>
<result property="parentCode" column="PARENT_CODE"/>
<result property="categoryCode" column="CATEGORY_CODE"/>
<result property="categoryName" column="CATEGORY_NAME"/>
<result property="level" column="LEVEL"/>
<result property="remark" column="REMARK"/>
<result property="sort" column="SORT"/>
<result property="delFlag" column="DEL_FLAG"/>
<result property="revision" column="REVISION"/>
<result property="createdBy" column="CREATED_BY"/>
<result property="createdTime" column="CREATED_TIME"/>
<result property="updatedBy" column="UPDATED_BY"/>
<result property="updatedTime" column="UPDATED_TIME"/>
</resultMap>
<select id="selectDemandOptions" resultType="com.epmet.commons.tools.dto.result.OptionResultDTO"> </select>
<select id="selectChildDemands" resultType="com.epmet.commons.tools.dto.result.OptionResultDTO"> </select>
</mapper>

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

@ -15,15 +15,24 @@
,UPDATED_TIME
) values
(
<foreach collection="map.entrySet()" index="key" item="value" separator=",">
#{value}
</foreach>
,'0'
,'0'
,NOW()
,NOW()
<foreach collection="map.entrySet()" index="key" item="value" separator=",">
#{value}
</foreach>
,'0'
,'0'
,NOW()
,NOW()
)
</insert>
<update id="upTable">
UPDATE ${tableName}
SET
<foreach collection="map.entrySet()" index="key" item="value" separator=",">
${key} = #{value}
</foreach>
,UPDATED_TIME = NOW()
WHERE id = #{id}
</update>
</mapper>
Loading…
Cancel
Save