Browse Source

日程列表、导出

dev
sunyuchao 3 years ago
parent
commit
379b845f6f
  1. 70
      epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/dto/partyOrg/result/IcScheduleListDTO.java
  2. 61
      epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partyOrg/controller/IcScheduleController.java
  3. 3
      epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partyOrg/dao/IcScheduleDao.java
  4. 26
      epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partyOrg/excel/IcScheduleListExcel.java
  5. 6
      epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partyOrg/service/IcScheduleService.java
  6. 7
      epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partyOrg/service/impl/IcScheduleServiceImpl.java
  7. 5
      epmet-module/resi-partymember/resi-partymember-server/src/main/resources/mapper/partyOrg/IcScheduleDao.xml

70
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;
}

61
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<PageData<IcScheduleDTO>> list(@LoginUser TokenDto tokenDto, @RequestBody IcScheduleFormDTO formDTO){
public Result<PageData<IcScheduleListDTO>> list(@LoginUser TokenDto tokenDto, @RequestBody IcScheduleFormDTO formDTO){
formDTO.setCustomerId(tokenDto.getCustomerId());
formDTO.setStaffId(tokenDto.getUserId());
return new Result<PageData<IcScheduleDTO>>().ok(icScheduleService.list(formDTO));
return new Result<PageData<IcScheduleListDTO>>().ok(icScheduleService.list(formDTO));
}
@RequestMapping(value = "{id}",method = {RequestMethod.POST,RequestMethod.GET})
@ -100,4 +120,41 @@ public class IcScheduleController {
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<IcScheduleListDTO> data = null;
List<IcScheduleListExcel> 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<Object> 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();
}
}
}
}

3
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<IcScheduleEntity> {
List<ActAndScheduleListResultDTO.ScheduleListDTO> getScheduleList(ActAndScheduleListFormDTO formDTO);
List<IcScheduleDTO> selectScheduleList(IcScheduleFormDTO formDTO);
List<IcScheduleListDTO> selectScheduleList(IcScheduleFormDTO formDTO);
}

26
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;
}

6
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<IcScheduleEntity> {
* @author generator
* @date 2022-08-18
*/
PageData<IcScheduleDTO> list(IcScheduleFormDTO formDTO);
PageData<IcScheduleListDTO> list(IcScheduleFormDTO formDTO);
/**
* 单条查询

7
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<IcScheduleDao, IcSche
@Override
public PageData<IcScheduleDTO> list(IcScheduleFormDTO formDTO) {
public PageData<IcScheduleListDTO> 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<IcScheduleDao, IcSche
}
formDTO.setAgencyId(staffInfo.getAgencyId());
List<IcScheduleDTO> list = baseDao.selectScheduleList(formDTO);
PageInfo<IcScheduleDTO> pageInfo = new PageInfo<>(list);
List<IcScheduleListDTO> list = baseDao.selectScheduleList(formDTO);
PageInfo<IcScheduleListDTO> pageInfo = new PageInfo<>(list);
return new PageData<>(list, pageInfo.getTotal());
}

5
epmet-module/resi-partymember/resi-partymember-server/src/main/resources/mapper/partyOrg/IcScheduleDao.xml

@ -69,14 +69,16 @@
order by REMIND_TIME desc
</select>
<select id="selectScheduleList" resultType="com.epmet.resi.partymember.dto.IcScheduleDTO">
<select id="selectScheduleList" resultType="com.epmet.resi.partymember.dto.partyOrg.result.IcScheduleListDTO">
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
</select>
</mapper>
Loading…
Cancel
Save