diff --git a/esua-epdc/epdc-module/epdc-custom/epdc-custom-client/src/main/java/com/elink/esua/epdc/dto/ArchivesDeptDTO.java b/esua-epdc/epdc-module/epdc-custom/epdc-custom-client/src/main/java/com/elink/esua/epdc/dto/ArchivesDeptDTO.java new file mode 100644 index 00000000..add85a92 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-custom/epdc-custom-client/src/main/java/com/elink/esua/epdc/dto/ArchivesDeptDTO.java @@ -0,0 +1,86 @@ +/** + * 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.elink.esua.epdc.dto; + +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + + +/** + * 档案部门排序表 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2020-07-30 + */ +@Data +public class ArchivesDeptDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + private String id; + + /** + * 归属部门 + */ + private String dept; + + /** + * 排序 + */ + private Integer deptOrder; + + /** + * 归属部门ID + */ + private Long deptId; + + /** + * 删除标识 0-否,1-是 + */ + private String 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/esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/java/com/elink/esua/epdc/modules/archives/service/impl/ArchivesServiceImpl.java b/esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/java/com/elink/esua/epdc/modules/archives/service/impl/ArchivesServiceImpl.java index 5c17a5c5..d2cff7f2 100644 --- a/esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/java/com/elink/esua/epdc/modules/archives/service/impl/ArchivesServiceImpl.java +++ b/esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/java/com/elink/esua/epdc/modules/archives/service/impl/ArchivesServiceImpl.java @@ -43,6 +43,7 @@ import com.elink.esua.epdc.modules.archives.entity.ArchivesEntity; import com.elink.esua.epdc.modules.archives.excel.ArchivesExcel; import com.elink.esua.epdc.modules.archives.redis.ArchivesRedis; import com.elink.esua.epdc.modules.archives.service.ArchivesService; +import com.elink.esua.epdc.modules.archivesdept.service.ArchivesDeptService; import com.elink.esua.epdc.modules.feign.AdminFeignClient; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -71,6 +72,9 @@ public class ArchivesServiceImpl extends BaseServiceImpl page(Map params) { IPage page = baseDao.selectPage( @@ -87,8 +91,8 @@ public class ArchivesServiceImpl extends BaseServiceImpl getWrapper(Map params){ - String id = (String)params.get(FieldConstant.ID_HUMP); + 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); @@ -99,8 +103,8 @@ public class ArchivesServiceImpl extends BaseServiceImpl parentAndAllDept = adminFeignClient.getParentAndAllDept(dto.getDeptId()); - if(!parentAndAllDept.success() || parentAndAllDept.getData() == null){ + if (!parentAndAllDept.success() || parentAndAllDept.getData() == null) { throw new RenException("获取归属部门信息失败"); } //判断档号 - if(baseDao.getArchivesDTOByArchivesNum("",dto.getArchivesNum())){ + if (baseDao.getArchivesDTOByArchivesNum("", dto.getArchivesNum())) { throw new RenException("档号不能重复"); } //判断日期 - if(dto.getArchiveTime().length()!=4 && dto.getArchiveTime().length()!=6 && dto.getArchiveTime().length()!=8) { + if (dto.getArchiveTime().length() != 4 && dto.getArchiveTime().length() != 6 && dto.getArchiveTime().length() != 8) { throw new RenException("日期格式错误"); } ParentAndAllDeptDTO parentAndAllDeptDTO = parentAndAllDept.getData(); @@ -133,25 +137,27 @@ public class ArchivesServiceImpl extends BaseServiceImpl parentAndAllDept = adminFeignClient.getParentAndAllDept(dto.getDeptId()); - if(!parentAndAllDept.success() || parentAndAllDept.getData() == null){ + if (!parentAndAllDept.success() || parentAndAllDept.getData() == null) { throw new RenException("获取归属部门信息失败"); } //判断档号 - if(baseDao.getArchivesDTOByArchivesNum(dto.getId(),dto.getArchivesNum())){ + if (baseDao.getArchivesDTOByArchivesNum(dto.getId(), dto.getArchivesNum())) { throw new RenException("档号不能重复"); } //判断日期 - if(dto.getArchiveTime().length()!=4 && dto.getArchiveTime().length()!=6 && dto.getArchiveTime().length()!=8) { + if (dto.getArchiveTime().length() != 4 && dto.getArchiveTime().length() != 6 && dto.getArchiveTime().length() != 8) { throw new RenException("日期格式错误"); } ParentAndAllDeptDTO parentAndAllDeptDTO = parentAndAllDept.getData(); @@ -162,6 +168,8 @@ public class ArchivesServiceImpl extends BaseServiceImpl parentAndAllDept = adminFeignClient.getParentAndAllDept(Long.parseLong(deptId)); - if(!parentAndAllDept.success() || parentAndAllDept.getData() == null){ + if (!parentAndAllDept.success() || parentAndAllDept.getData() == null) { throw new RenException("获取归属部门信息失败"); } ParentAndAllDeptDTO parentAndAllDeptDTO = parentAndAllDept.getData(); @@ -212,10 +220,10 @@ public class ArchivesServiceImpl extends BaseServiceImpl archivesExcelList = ExcelImportUtil.importExcel(f, ArchivesExcel.class, importParams); // 校验数据 List epdcArchivesErroyResultDTOS = this.checkExcel(archivesExcelList); - if(epdcArchivesErroyResultDTOS.size()>0){ + if (epdcArchivesErroyResultDTOS.size() > 0) { return new Result().ok(epdcArchivesErroyResultDTOS); } - saveList(archivesExcelList,parentAndAllDeptDTO); + saveList(archivesExcelList, parentAndAllDeptDTO); for (ArchivesExcel archivesExcel : archivesExcelList) { System.out.println("从Excel导入数据到数据库的详细为 :{}" + JSON.toJSONString(archivesExcel)); } @@ -231,7 +239,7 @@ public class ArchivesServiceImpl extends BaseServiceImpl listArchiveDeptInfo = this.baseDao.selectListArchiveDeptInfo(formDTO); + List listArchiveDeptInfo = this.baseDao.selectListArchiveDeptInfo(formDTO); return new Result().ok(listArchiveDeptInfo); } @@ -240,7 +248,7 @@ public class ArchivesServiceImpl extends BaseServiceImpl listArchiveInfo = this.baseDao.selectListArchiveInfo(formDTO); + List listArchiveInfo = this.baseDao.selectListArchiveInfo(formDTO); return new Result().ok(listArchiveInfo); } @@ -258,10 +266,10 @@ public class ArchivesServiceImpl extends BaseServiceImpl partyList, ParentAndAllDeptDTO parentAndAllDeptDTO) { List archivesEntityList = new ArrayList<>(); - for(ArchivesExcel archivesExcel : partyList){ + for (ArchivesExcel archivesExcel : partyList) { ArchivesEntity archivesEntity = ConvertUtils.sourceToTarget(archivesExcel, ArchivesEntity.class); - if(archivesExcel.getArchiveTime().length()!=4 && archivesExcel.getArchiveTime().length()!=6 && archivesExcel.getArchiveTime().length()!=8) { + if (archivesExcel.getArchiveTime().length() != 4 && archivesExcel.getArchiveTime().length() != 6 && archivesExcel.getArchiveTime().length() != 8) { throw new RenException("日期格式错误"); } archivesEntity.setAllDeptIds(parentAndAllDeptDTO.getAllDeptIds()); @@ -273,6 +281,10 @@ public class ArchivesServiceImpl extends BaseServiceImpl checkExcel(List archivesList) { List archivesEntityList = baseDao.selectList(new QueryWrapper()); - List errorLineinfoList=new ArrayList<>(); + List errorLineinfoList = new ArrayList<>(); EpdcArchivesErroyResultDTO errorLineinfoDto; for (int i = 0; i < archivesList.size(); i++) { ArchivesExcel archivesExcel = archivesList.get(i); @@ -296,47 +308,47 @@ public class ArchivesServiceImpl extends BaseServiceImpl + * 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.elink.esua.epdc.modules.archivesdept.controller; + +import com.elink.esua.epdc.commons.tools.page.PageData; +import com.elink.esua.epdc.commons.tools.utils.ExcelUtils; +import com.elink.esua.epdc.commons.tools.utils.Result; +import com.elink.esua.epdc.commons.tools.validator.AssertUtils; +import com.elink.esua.epdc.commons.tools.validator.ValidatorUtils; +import com.elink.esua.epdc.commons.tools.validator.group.AddGroup; +import com.elink.esua.epdc.commons.tools.validator.group.UpdateGroup; +import com.elink.esua.epdc.commons.tools.validator.group.DefaultGroup; +import com.elink.esua.epdc.dto.ArchivesDeptDTO; +import com.elink.esua.epdc.modules.archivesdept.excel.ArchivesDeptExcel; +import com.elink.esua.epdc.modules.archivesdept.service.ArchivesDeptService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; +import java.util.Map; + + +/** + * 档案部门排序表 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2020-07-30 + */ +@RestController +@RequestMapping("archivesdept") +public class ArchivesDeptController { + + @Autowired + private ArchivesDeptService archivesDeptService; + + @GetMapping("page") + public Result> page(@RequestParam Map params){ + PageData page = archivesDeptService.page(params); + return new Result>().ok(page); + } + + @GetMapping("{id}") + public Result get(@PathVariable("id") String id){ + ArchivesDeptDTO data = archivesDeptService.get(id); + return new Result().ok(data); + } + + @PostMapping + public Result save(@RequestBody ArchivesDeptDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + archivesDeptService.save(dto); + return new Result(); + } + + @PutMapping + public Result update(@RequestBody ArchivesDeptDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + archivesDeptService.update(dto); + return new Result(); + } + + @DeleteMapping + public Result delete(@RequestBody String[] ids){ + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + archivesDeptService.delete(ids); + return new Result(); + } + + @GetMapping("export") + public void export(@RequestParam Map params, HttpServletResponse response) throws Exception { + List list = archivesDeptService.list(params); + ExcelUtils.exportExcelToTarget(response, null, list, ArchivesDeptExcel.class); + } + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/java/com/elink/esua/epdc/modules/archivesdept/dao/ArchivesDeptDao.java b/esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/java/com/elink/esua/epdc/modules/archivesdept/dao/ArchivesDeptDao.java new file mode 100644 index 00000000..a7b9e15d --- /dev/null +++ b/esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/java/com/elink/esua/epdc/modules/archivesdept/dao/ArchivesDeptDao.java @@ -0,0 +1,33 @@ +/** + * 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.elink.esua.epdc.modules.archivesdept.dao; + +import com.elink.esua.epdc.commons.mybatis.dao.BaseDao; +import com.elink.esua.epdc.modules.archivesdept.entity.ArchivesDeptEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 档案部门排序表 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2020-07-30 + */ +@Mapper +public interface ArchivesDeptDao extends BaseDao { + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/java/com/elink/esua/epdc/modules/archivesdept/entity/ArchivesDeptEntity.java b/esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/java/com/elink/esua/epdc/modules/archivesdept/entity/ArchivesDeptEntity.java new file mode 100644 index 00000000..7398406e --- /dev/null +++ b/esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/java/com/elink/esua/epdc/modules/archivesdept/entity/ArchivesDeptEntity.java @@ -0,0 +1,56 @@ +/** + * 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.elink.esua.epdc.modules.archivesdept.entity; + +import com.baomidou.mybatisplus.annotation.TableName; + +import com.elink.esua.epdc.commons.mybatis.entity.BaseEpdcEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * 档案部门排序表 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2020-07-30 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("epdc_archives_dept") +public class ArchivesDeptEntity extends BaseEpdcEntity { + + private static final long serialVersionUID = 1L; + + /** + * 归属部门 + */ + private String dept; + + /** + * 归属部门ID + */ + private Long deptId; + + /** + * 排序 + */ + private Integer deptOrder; + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/java/com/elink/esua/epdc/modules/archivesdept/excel/ArchivesDeptExcel.java b/esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/java/com/elink/esua/epdc/modules/archivesdept/excel/ArchivesDeptExcel.java new file mode 100644 index 00000000..f12a39de --- /dev/null +++ b/esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/java/com/elink/esua/epdc/modules/archivesdept/excel/ArchivesDeptExcel.java @@ -0,0 +1,62 @@ +/** + * 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.elink.esua.epdc.modules.archivesdept.excel; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import lombok.Data; + +import java.util.Date; + +/** + * 档案部门排序表 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2020-07-30 + */ +@Data +public class ArchivesDeptExcel { + + @Excel(name = "主键") + private String id; + + @Excel(name = "归属部门") + private String dept; + + @Excel(name = "归属部门ID") + private Long deptId; + + @Excel(name = "删除标识 0-否,1-是") + private String delFlag; + + @Excel(name = "乐观锁") + private Integer revision; + + @Excel(name = "创建人") + private String createdBy; + + @Excel(name = "创建时间") + private Date createdTime; + + @Excel(name = "更新人") + private String updatedBy; + + @Excel(name = "更新时间") + private Date updatedTime; + + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/java/com/elink/esua/epdc/modules/archivesdept/redis/ArchivesDeptRedis.java b/esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/java/com/elink/esua/epdc/modules/archivesdept/redis/ArchivesDeptRedis.java new file mode 100644 index 00000000..c438827f --- /dev/null +++ b/esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/java/com/elink/esua/epdc/modules/archivesdept/redis/ArchivesDeptRedis.java @@ -0,0 +1,47 @@ +/** + * 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.elink.esua.epdc.modules.archivesdept.redis; + +import com.elink.esua.epdc.commons.tools.redis.RedisUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * 档案部门排序表 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2020-07-30 + */ +@Component +public class ArchivesDeptRedis { + @Autowired + private RedisUtils redisUtils; + + public void delete(Object[] ids) { + + } + + public void set(){ + + } + + public String get(String id){ + return null; + } + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/java/com/elink/esua/epdc/modules/archivesdept/service/ArchivesDeptService.java b/esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/java/com/elink/esua/epdc/modules/archivesdept/service/ArchivesDeptService.java new file mode 100644 index 00000000..812b9093 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/java/com/elink/esua/epdc/modules/archivesdept/service/ArchivesDeptService.java @@ -0,0 +1,105 @@ +/** + * 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.elink.esua.epdc.modules.archivesdept.service; + +import com.elink.esua.epdc.commons.mybatis.service.BaseService; +import com.elink.esua.epdc.commons.tools.page.PageData; +import com.elink.esua.epdc.dto.ArchivesDeptDTO; +import com.elink.esua.epdc.modules.archivesdept.entity.ArchivesDeptEntity; +import java.util.List; +import java.util.Map; + +/** + * 档案部门排序表 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2020-07-30 + */ +public interface ArchivesDeptService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2020-07-30 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2020-07-30 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return ArchivesDeptDTO + * @author generator + * @date 2020-07-30 + */ + ArchivesDeptDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2020-07-30 + */ + void save(ArchivesDeptDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2020-07-30 + */ + void update(ArchivesDeptDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2020-07-30 + */ + void delete(String[] ids); + + + /*** + * 新增或修改 + * @param deptId + * @return com.elink.esua.epdc.dto.ArchivesDeptDTO + * @author qushutong + * @date 2020/7/30 13:31 + */ + boolean modifyArchives(Long deptId,String dept); + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/java/com/elink/esua/epdc/modules/archivesdept/service/impl/ArchivesDeptServiceImpl.java b/esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/java/com/elink/esua/epdc/modules/archivesdept/service/impl/ArchivesDeptServiceImpl.java new file mode 100644 index 00000000..f43ef553 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/java/com/elink/esua/epdc/modules/archivesdept/service/impl/ArchivesDeptServiceImpl.java @@ -0,0 +1,120 @@ +/** + * 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.elink.esua.epdc.modules.archivesdept.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.toolkit.SqlHelper; +import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl; +import com.elink.esua.epdc.commons.tools.page.PageData; +import com.elink.esua.epdc.commons.tools.utils.ConvertUtils; +import com.elink.esua.epdc.commons.tools.constant.FieldConstant; +import com.elink.esua.epdc.modules.archivesdept.dao.ArchivesDeptDao; +import com.elink.esua.epdc.dto.ArchivesDeptDTO; +import com.elink.esua.epdc.modules.archivesdept.entity.ArchivesDeptEntity; +import com.elink.esua.epdc.modules.archivesdept.redis.ArchivesDeptRedis; +import com.elink.esua.epdc.modules.archivesdept.service.ArchivesDeptService; +import org.apache.commons.lang3.StringUtils; +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; + +/** + * 档案部门排序表 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2020-07-30 + */ +@Service +public class ArchivesDeptServiceImpl extends BaseServiceImpl implements ArchivesDeptService { + + @Autowired + private ArchivesDeptRedis archivesDeptRedis; + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, ArchivesDeptDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, ArchivesDeptDTO.class); + } + + private QueryWrapper getWrapper(Map params) { + String id = (String) params.get(FieldConstant.ID_HUMP); + String dept = (String) params.get("dept"); + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.like(StringUtils.isNotBlank(dept), "dept", dept); + wrapper.orderByAsc("DEPT_ORDER"); + return wrapper; + } + + @Override + public ArchivesDeptDTO get(String id) { + ArchivesDeptEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, ArchivesDeptDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(ArchivesDeptDTO dto) { + ArchivesDeptEntity entity = ConvertUtils.sourceToTarget(dto, ArchivesDeptEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(ArchivesDeptDTO dto) { + ArchivesDeptEntity entity = ConvertUtils.sourceToTarget(dto, ArchivesDeptEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + @Override + public boolean modifyArchives(Long deptId,String dept) { + QueryWrapper wrapper = new QueryWrapper(); + wrapper.eq("DEPT_ID", deptId); + ArchivesDeptEntity archivesDeptEntity = baseDao.selectOne(wrapper); + if(archivesDeptEntity==null){ + // 没有新增一条 + ArchivesDeptEntity archivesDept =new ArchivesDeptEntity(); + archivesDept.setDept(dept); + archivesDept.setDeptId(deptId); + return insert(archivesDept); + } + return true; + } + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/resources/mapper/archives/ArchivesDao.xml b/esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/resources/mapper/archives/ArchivesDao.xml index 49777e6e..e8b1e0b0 100644 --- a/esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/resources/mapper/archives/ArchivesDao.xml +++ b/esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/resources/mapper/archives/ArchivesDao.xml @@ -76,7 +76,16 @@