diff --git a/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/dto/partyOrg/result/IcScheduleListDTO.java b/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/dto/partyOrg/result/IcScheduleListDTO.java new file mode 100644 index 0000000000..b048b49357 --- /dev/null +++ b/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/dto/partyOrg/result/IcScheduleListDTO.java @@ -0,0 +1,70 @@ +package com.epmet.resi.partymember.dto.partyOrg.result; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + + +/** + * 日程表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-08-18 + */ +@Data +public class IcScheduleListDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * ID + */ + private String id; + + /** + * 客户ID + */ + private String customerId; + + /** + * 当前登录用户userId + */ + private String staffId; + + /** + * 日程标题(35字) + */ + private String title; + + /** + * 提醒时间;其实就是日程所属日期 + */ + private Date remindTime; + + /** + * 提醒时间;其实就是日程所属日期 + */ + private String remindTimeName; + + /** + * 是否公开,0:仅自己可见;1:组织内其他人可见 + */ + private String isPublic; + + /** + * 是否公开,0:是 1:否 + */ + private String isPublicName; + + /** + * 备注(500字) + */ + private String remark; + + /** + * 创建时间 + */ + private Date createdTime; + +} \ No newline at end of file diff --git a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partyOrg/controller/IcScheduleController.java b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partyOrg/controller/IcScheduleController.java index 582c331c50..cc45d2e7bf 100644 --- a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partyOrg/controller/IcScheduleController.java +++ b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partyOrg/controller/IcScheduleController.java @@ -1,22 +1,41 @@ package com.epmet.modules.partyOrg.controller; +import com.alibaba.excel.EasyExcel; +import com.alibaba.excel.ExcelWriter; +import com.alibaba.excel.write.metadata.WriteSheet; +import com.alibaba.fastjson.JSON; import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.aop.NoRepeatSubmit; +import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.EpmetException; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.utils.DateUtils; +import com.epmet.commons.tools.utils.ExcelUtils; import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.utils.poi.excel.handler.FreezeAndFilter; 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.modules.partyOrg.excel.IcScheduleListExcel; import com.epmet.modules.partyOrg.service.IcScheduleService; import com.epmet.resi.partymember.dto.IcScheduleDTO; import com.epmet.resi.partymember.dto.partyOrg.form.AddOrEditScheduleFormDTO; import com.epmet.resi.partymember.dto.partyOrg.form.IcScheduleFormDTO; +import com.epmet.resi.partymember.dto.partyOrg.result.IcScheduleListDTO; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.PrintWriter; +import java.util.Date; import java.util.List; @@ -28,16 +47,17 @@ import java.util.List; */ @RestController @RequestMapping("icSchedule") +@Slf4j public class IcScheduleController { @Autowired private IcScheduleService icScheduleService; @RequestMapping(value = "list",method = {RequestMethod.POST,RequestMethod.GET}) - public Result> list(@LoginUser TokenDto tokenDto, @RequestBody IcScheduleFormDTO formDTO){ + public Result> list(@LoginUser TokenDto tokenDto, @RequestBody IcScheduleFormDTO formDTO){ formDTO.setCustomerId(tokenDto.getCustomerId()); formDTO.setStaffId(tokenDto.getUserId()); - return new Result>().ok(icScheduleService.list(formDTO)); + return new Result>().ok(icScheduleService.list(formDTO)); } @RequestMapping(value = "{id}",method = {RequestMethod.POST,RequestMethod.GET}) @@ -99,5 +119,42 @@ public class IcScheduleController { icScheduleService.delSchedule(scheduleIds); return new Result(); } + + @PostMapping("export") + public void export(@LoginUser TokenDto tokenDto, @RequestBody IcScheduleFormDTO formDTO, HttpServletResponse response) throws IOException { + formDTO.setCustomerId(tokenDto.getCustomerId()); + formDTO.setStaffId(tokenDto.getUserId()); + formDTO.setIsPage(false); + ExcelWriter excelWriter = null; + formDTO.setPageNo(NumConstant.ONE); + formDTO.setPageSize(NumConstant.TEN_THOUSAND); + try { + String fileName = "日程列表" + DateUtils.format(new Date()) + ".xlsx"; + excelWriter = EasyExcel.write(ExcelUtils.getOutputStreamForExcel(fileName, response), IcScheduleListExcel.class).build(); + WriteSheet writeSheet = EasyExcel.writerSheet("Sheet1").registerWriteHandler(new FreezeAndFilter()).build(); + PageData data = null; + List list = null; + do { + data = icScheduleService.list(formDTO); + list = ConvertUtils.sourceToTarget(data.getList(), IcScheduleListExcel.class); + formDTO.setPageNo(formDTO.getPageNo() + NumConstant.ONE); + excelWriter.write(list, writeSheet); + } while (CollectionUtils.isNotEmpty(list) && list.size() == formDTO.getPageSize()); + } catch (EpmetException e) { + response.reset(); + response.setCharacterEncoding("UTF-8"); + response.setHeader("content-type", "application/json; charset=UTF-8"); + PrintWriter printWriter = response.getWriter(); + Result result = new Result<>().error(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),e.getMsg()); + printWriter.write(JSON.toJSONString(result)); + printWriter.close(); + } catch (Exception e) { + log.error("export exception", e); + } finally { + if (excelWriter != null) { + excelWriter.finish(); + } + } + } } diff --git a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partyOrg/dao/IcScheduleDao.java b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partyOrg/dao/IcScheduleDao.java index f91dd25d78..a433a07392 100644 --- a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partyOrg/dao/IcScheduleDao.java +++ b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partyOrg/dao/IcScheduleDao.java @@ -9,6 +9,7 @@ import com.epmet.resi.partymember.dto.partyOrg.form.HomeMonthTotalFormDTO; import com.epmet.resi.partymember.dto.partyOrg.form.IcScheduleFormDTO; import com.epmet.resi.partymember.dto.partyOrg.result.ActAndScheduleListResultDTO; import com.epmet.resi.partymember.dto.partyOrg.result.HomeMonthTotalResultDTO; +import com.epmet.resi.partymember.dto.partyOrg.result.IcScheduleListDTO; import org.apache.ibatis.annotations.Mapper; import java.util.List; @@ -28,5 +29,5 @@ public interface IcScheduleDao extends BaseDao { List getScheduleList(ActAndScheduleListFormDTO formDTO); - List selectScheduleList(IcScheduleFormDTO formDTO); + List selectScheduleList(IcScheduleFormDTO formDTO); } \ No newline at end of file diff --git a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partyOrg/excel/IcScheduleListExcel.java b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partyOrg/excel/IcScheduleListExcel.java new file mode 100644 index 0000000000..72e0a4002b --- /dev/null +++ b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partyOrg/excel/IcScheduleListExcel.java @@ -0,0 +1,26 @@ +package com.epmet.modules.partyOrg.excel; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.annotation.write.style.ColumnWidth; +import lombok.Data; + +@Data +public class IcScheduleListExcel { + + @ExcelProperty(value = "日程标题") + @ColumnWidth(20) + private String title; + + @ExcelProperty(value = "提醒时间") + @ColumnWidth(20) + private String remindTimeName; + + @ExcelProperty(value = "是否公开") + @ColumnWidth(20) + private String isPublicName; + + @ExcelProperty(value = "备注") + @ColumnWidth(25) + private String remark; + +} diff --git a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partyOrg/service/IcScheduleService.java b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partyOrg/service/IcScheduleService.java index c38bb4fece..ebd7f6f6dd 100644 --- a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partyOrg/service/IcScheduleService.java +++ b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partyOrg/service/IcScheduleService.java @@ -3,14 +3,12 @@ package com.epmet.modules.partyOrg.service; import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.tools.page.PageData; import com.epmet.modules.partyOrg.entity.IcScheduleEntity; -import com.epmet.resi.partymember.dto.IcPartyActSignInRecordDTO; import com.epmet.resi.partymember.dto.IcScheduleDTO; import com.epmet.resi.partymember.dto.partyOrg.form.AddOrEditScheduleFormDTO; import com.epmet.resi.partymember.dto.partyOrg.form.IcScheduleFormDTO; -import com.epmet.resi.partymember.dto.partyOrg.form.PartyActSignFormDTO; +import com.epmet.resi.partymember.dto.partyOrg.result.IcScheduleListDTO; import java.util.List; -import java.util.Map; /** * 日程表 @@ -28,7 +26,7 @@ public interface IcScheduleService extends BaseService { * @author generator * @date 2022-08-18 */ - PageData list(IcScheduleFormDTO formDTO); + PageData list(IcScheduleFormDTO formDTO); /** * 单条查询 diff --git a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partyOrg/service/impl/IcScheduleServiceImpl.java b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partyOrg/service/impl/IcScheduleServiceImpl.java index 0893676ed4..96a952c5cd 100644 --- a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partyOrg/service/impl/IcScheduleServiceImpl.java +++ b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partyOrg/service/impl/IcScheduleServiceImpl.java @@ -20,6 +20,7 @@ import com.epmet.modules.partyOrg.service.IcScheduleService; import com.epmet.resi.partymember.dto.IcScheduleDTO; import com.epmet.resi.partymember.dto.partyOrg.form.AddOrEditScheduleFormDTO; import com.epmet.resi.partymember.dto.partyOrg.form.IcScheduleFormDTO; +import com.epmet.resi.partymember.dto.partyOrg.result.IcScheduleListDTO; import com.epmet.send.SendMqMsgUtil; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; @@ -43,7 +44,7 @@ public class IcScheduleServiceImpl extends BaseServiceImpl list(IcScheduleFormDTO formDTO) { + public PageData list(IcScheduleFormDTO formDTO) { PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize(), formDTO.getIsPage()); //获取工作人员所属组织信息 CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getStaffId()); @@ -52,8 +53,8 @@ public class IcScheduleServiceImpl extends BaseServiceImpl list = baseDao.selectScheduleList(formDTO); - PageInfo pageInfo = new PageInfo<>(list); + List list = baseDao.selectScheduleList(formDTO); + PageInfo pageInfo = new PageInfo<>(list); return new PageData<>(list, pageInfo.getTotal()); } diff --git a/epmet-module/resi-partymember/resi-partymember-server/src/main/resources/mapper/partyOrg/IcScheduleDao.xml b/epmet-module/resi-partymember/resi-partymember-server/src/main/resources/mapper/partyOrg/IcScheduleDao.xml index 5a470bd672..8d6c2295a4 100644 --- a/epmet-module/resi-partymember/resi-partymember-server/src/main/resources/mapper/partyOrg/IcScheduleDao.xml +++ b/epmet-module/resi-partymember/resi-partymember-server/src/main/resources/mapper/partyOrg/IcScheduleDao.xml @@ -69,14 +69,16 @@ order by REMIND_TIME desc - SELECT id, customer_id, staff_id, title, remind_time, + DATE_FORMAT(remind_time,'%Y-%m-%d %H:%i:%s')remindTimeName, is_public, + IF (is_public = '0', '仅自己可见', '组织内其他人可见') "isPublicName", remark, created_time FROM @@ -108,4 +110,5 @@ order by remind_time desc + \ No newline at end of file