diff --git a/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/form/CustomerFormQueryDTO.java b/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/form/CustomerFormQueryDTO.java index e2bafc12df..55e1160110 100644 --- a/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/form/CustomerFormQueryDTO.java +++ b/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; } diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/IcFormController.java b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/IcFormController.java index f6e0d66c98..708bc42093 100644 --- a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/IcFormController.java +++ b/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().ok(icFormService.getCustomerForm(formDto)); } @@ -131,6 +134,9 @@ public class IcFormController { @PostMapping("conditionlist") public Result> 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>().ok(icFormItemService.queryConditionList(formDto)); } diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/dao/IcFormDao.java b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/dao/IcFormDao.java index bed3566120..846e59ad72 100644 --- a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/dao/IcFormDao.java +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/dao/IcFormDao.java @@ -47,7 +47,7 @@ public interface IcFormDao extends BaseDao { */ CustomerFormResultDTO selectByCode(@Param("customerId") String customerId, @Param("formCode") String formCode); - List selectItemList(String formId); + List selectItemList(String formId, Boolean dynamic); List selectItemListByGroupId(String groupId); List selectListOption(String itemId); @@ -55,4 +55,4 @@ public interface IcFormDao extends BaseDao { List selectListGroup(String formId); FormGroupDTO selectChildGroup(String itemId); -} \ No newline at end of file +} diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcFormServiceImpl.java b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcFormServiceImpl.java index 03b03ffaf8..6a4d8a426c 100644 --- a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcFormServiceImpl.java +++ b/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 if (null == resultDTO) { throw new RenException(EpmetErrorCode.CUSTOMER_FORM_NOT_EXITS.getCode(),EpmetErrorCode.CUSTOMER_FORM_NOT_EXITS.getMsg()); } - List itemList=baseDao.selectItemList(resultDTO.getFormId()); + List itemList=baseDao.selectItemList(resultDTO.getFormId(),formDto.getDynamic()); List groupList=baseDao.selectListGroup(resultDTO.getFormId()); resultDTO.setItemList(itemList); @@ -126,4 +126,4 @@ public class IcFormServiceImpl extends BaseServiceImpl return resultDTO; } -} \ No newline at end of file +} diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/resources/mapper/IcFormDao.xml b/epmet-module/oper-customize/oper-customize-server/src/main/resources/mapper/IcFormDao.xml index 536fe55472..9612996019 100644 --- a/epmet-module/oper-customize/oper-customize-server/src/main/resources/mapper/IcFormDao.xml +++ b/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} + + fi.DYNAMIC = #{dynamic} + AND fi.ITEM_GROUP_ID = '0' ORDER BY fi.SORT ASC @@ -196,4 +199,4 @@ g.SORT ASC - \ No newline at end of file + diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcResiDemandDictDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcResiDemandDictDTO.java new file mode 100644 index 0000000000..ccdb6f5752 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcResiDemandDictDTO.java @@ -0,0 +1,107 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +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; + +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiDemandDictController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiDemandDictController.java new file mode 100644 index 0000000000..4d87ffc779 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiDemandDictController.java @@ -0,0 +1,84 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +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> page(@RequestParam Map params){ + PageData page = icResiDemandDictService.page(params); + return new Result>().ok(page); + } + + @GetMapping("{id}") + public Result get(@PathVariable("id") String id){ + IcResiDemandDictDTO data = icResiDemandDictService.get(id); + return new Result().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(); + } + +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java index 0fdf14cf48..4e49766a21 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java +++ b/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 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 colList = new ArrayList<>(); + List 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 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 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 paramCols = new ArrayList<>(); List headerList = Arrays.asList("头1","头2","头3"); @@ -157,15 +196,16 @@ public class IcResiUserController { }); desginGroup.setList(paramCols); - colList.add(desginGroup); + colList.add(desginGroup);*/ List> dataList =new ArrayList<>(); Map 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); diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiDemandDictDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiDemandDictDao.java new file mode 100644 index 0000000000..a618f7c71e --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiDemandDictDao.java @@ -0,0 +1,37 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +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 { + List selectDemandOptions(String customerId); + List selectChildDemands(String parentCode); +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java index 7b45e51552..3ddc71fec4 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java +++ b/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 { + /** + * @Author sun + * @Description 居民信息各表新增数据 + **/ void add(@Param("tableName") String tableName, @Param("map") Map map); + + /** + * @Author sun + * @Description 更新或新增居民信息各表数据 + **/ + void upTable(@Param("tableName") String tableName, @Param("id") String id, @Param("map") Map map); } \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcResiDemandDictEntity.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcResiDemandDictEntity.java new file mode 100644 index 0000000000..5e01dd2b14 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcResiDemandDictEntity.java @@ -0,0 +1,73 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +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; + +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/handler/ExcelDiceAddressListHandlerImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/handler/ExcelDiceAddressListHandlerImpl.java new file mode 100644 index 0000000000..b03634c761 --- /dev/null +++ b/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 getList(String dict) { + List list = new ArrayList<>(); + Map 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; + } +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiDemandDictService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiDemandDictService.java new file mode 100644 index 0000000000..80519d996c --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiDemandDictService.java @@ -0,0 +1,96 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +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 { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2021-10-27 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2021-10-27 + */ + List list(Map 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); + +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserService.java index f4bc23b00f..fe66ec72e6 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserService.java @@ -105,5 +105,5 @@ public interface IcResiUserService extends BaseService { * @Author sun * @Description 党建互联平台--修改居民信息 **/ - void edit(IcResiUserFormDTO formDTO); + void edit(TokenDto tokenDto, List formDTO); } \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiDemandDictServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiDemandDictServiceImpl.java new file mode 100644 index 0000000000..0cf9fba9d1 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiDemandDictServiceImpl.java @@ -0,0 +1,99 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +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 implements IcResiDemandDictService { + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, IcResiDemandDictDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, IcResiDemandDictDTO.class); + } + + private QueryWrapper getWrapper(Map params){ + String id = (String)params.get(FieldConstant.ID_HUMP); + + QueryWrapper 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)); + } + +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java index 2bc1390f19..e255ee7309 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java +++ b/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 formDTO) { + //1.校验主表数据是否存在 + String resiUserId = ""; + Map 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); + } + }); + } + }); } diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiDemandDictDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiDemandDictDao.xml new file mode 100644 index 0000000000..d2a96e6e66 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiDemandDictDao.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml index 2631d213fd..a80df030b9 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml @@ -15,15 +15,24 @@ ,UPDATED_TIME ) values ( - - #{value} - - ,'0' - ,'0' - ,NOW() - ,NOW() + + #{value} + + ,'0' + ,'0' + ,NOW() + ,NOW() ) + + UPDATE ${tableName} + SET + + ${key} = #{value} + + ,UPDATED_TIME = NOW() + WHERE id = #{id} + \ No newline at end of file