diff --git a/src/main/java/com/chinaunicom/mall/ebtp/extend/BizServiceEbtpExtendApplication.java b/src/main/java/com/chinaunicom/mall/ebtp/extend/BizServiceEbtpExtendApplication.java index 05651ce..e799bce 100644 --- a/src/main/java/com/chinaunicom/mall/ebtp/extend/BizServiceEbtpExtendApplication.java +++ b/src/main/java/com/chinaunicom/mall/ebtp/extend/BizServiceEbtpExtendApplication.java @@ -23,7 +23,6 @@ import org.springframework.scheduling.annotation.EnableAsync; @EnableEurekaClient @MapperScan({"com.chinaunicom.mall.ebtp.extend.**.dao"}) @ComponentScan("com.chinaunicom.mall.ebtp.*") -@EnableApolloConfig @EnableAsync public class BizServiceEbtpExtendApplication { diff --git a/src/main/java/com/chinaunicom/mall/ebtp/extend/partyMemberEvent/controller/PartyEventMaintainController.java b/src/main/java/com/chinaunicom/mall/ebtp/extend/partyMemberEvent/controller/PartyEventMaintainController.java index 5d06e37..67f80b0 100644 --- a/src/main/java/com/chinaunicom/mall/ebtp/extend/partyMemberEvent/controller/PartyEventMaintainController.java +++ b/src/main/java/com/chinaunicom/mall/ebtp/extend/partyMemberEvent/controller/PartyEventMaintainController.java @@ -2,19 +2,25 @@ package com.chinaunicom.mall.ebtp.extend.partyMemberEvent.controller; import com.chinaunicom.mall.ebtp.common.base.entity.BaseResponse; +import com.chinaunicom.mall.ebtp.common.poiExport.constant.ExportConstant; +import com.chinaunicom.mall.ebtp.common.poiExport.entity.ExcelTable; import com.chinaunicom.mall.ebtp.extend.partyMemberEvent.entity.*; import com.chinaunicom.mall.ebtp.extend.partyMemberEvent.service.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; +import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.*; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import java.io.*; import java.util.List; -import java.util.Map; @RestController @Api(tags = "活动运维接口") +@Slf4j @RequestMapping("/v1/eventmaintain") public class PartyEventMaintainController { @@ -28,6 +34,8 @@ public class PartyEventMaintainController { private EventSubjectService eventSubjectService; @Resource private EventContactService eventContactService; + @Resource + private EventContactSuggestionService eventContactSuggestionService; @@ -92,12 +100,68 @@ public class PartyEventMaintainController { @ApiOperation("发送风采或项目") @GetMapping("/styleProject/send") - public BaseResponse sendStyleOrProject(@RequestParam String id) { - return BaseResponse.success(eventStyleService.sendStyleOrProject(id)); + public BaseResponse sendStyleOrProject(@RequestParam("id") String id,@RequestParam("status") String status) { + return BaseResponse.success(eventStyleService.sendStyleOrProject(id, status)); } @ApiOperation("删除风采或项目") @GetMapping("/styleProject/delete") - public BaseResponse deleteStyleOrProject(@RequestParam String id) { + public BaseResponse deleteStyleOrProject(@RequestParam("id") String id) { return BaseResponse.success(eventStyleService.deleteStyleOrProject(id)); } + + + @ApiOperation("后台查询列表") + @PostMapping("/suggestion/list") + public BaseResponse> querySuggestion(@RequestBody EventMaintainInVO inVO) { + return BaseResponse.success(eventContactSuggestionService.querySuggestion(inVO)); + } + + @GetMapping(value = "/suggestion/export/") + public BaseResponse export(@RequestParam("ids") List ids) { + ExcelTable table = eventContactSuggestionService.export(ids); + ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); + HttpServletResponse response = requestAttributes.getResponse(); + this.exportGetlist(response, table); + return BaseResponse.success(true); + } + + public void exportGetlist(HttpServletResponse response, ExcelTable table) { + + OutputStream out = null; + InputStream is = null; + File file = null; + try { + file = ExportConstant.generateExcelByTable(table); + response.addHeader("content-disposition", "attachment;filename=" + + java.net.URLEncoder.encode(file.getName(), "utf-8")); + out = response.getOutputStream(); + is = new FileInputStream(file); + + byte[] b = new byte[4096]; + int size = is.read(b); + while (size > 0) { + out.write(b, 0, size); + size = is.read(b); + } + out.close(); + is.close(); + } catch (Exception e) { + log.error("error: {}, {}", table.toString(), e.getMessage()); + } finally { + try { + if (is != null) { + is.close(); + } + if (out != null) { + out.close(); + } + } catch (IOException e) { + log.error("error: {}, {}", table.toString(), e.getMessage()); + } + if (file != null) { + boolean delete = file.delete(); + log.info("delete:{}", delete); + } + } + } } diff --git a/src/main/java/com/chinaunicom/mall/ebtp/extend/partyMemberEvent/entity/EventContactSuggestion.java b/src/main/java/com/chinaunicom/mall/ebtp/extend/partyMemberEvent/entity/EventContactSuggestion.java index cca10c1..b008dcf 100644 --- a/src/main/java/com/chinaunicom/mall/ebtp/extend/partyMemberEvent/entity/EventContactSuggestion.java +++ b/src/main/java/com/chinaunicom/mall/ebtp/extend/partyMemberEvent/entity/EventContactSuggestion.java @@ -12,6 +12,7 @@ import lombok.experimental.Accessors; import org.springframework.format.annotation.DateTimeFormat; import java.io.Serializable; +import java.time.LocalDateTime; /** * 实体类 EventContactSuggestion @@ -107,7 +108,7 @@ public class EventContactSuggestion implements Serializable { @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") @TableField(typeHandler = CustomLocalDateTimeTypeHandler.class) - private java.time.LocalDateTime createTime; + private LocalDateTime createTime; } diff --git a/src/main/java/com/chinaunicom/mall/ebtp/extend/partyMemberEvent/entity/EventMaintainOutVO.java b/src/main/java/com/chinaunicom/mall/ebtp/extend/partyMemberEvent/entity/EventMaintainOutVO.java index 99c3840..c557e5d 100644 --- a/src/main/java/com/chinaunicom/mall/ebtp/extend/partyMemberEvent/entity/EventMaintainOutVO.java +++ b/src/main/java/com/chinaunicom/mall/ebtp/extend/partyMemberEvent/entity/EventMaintainOutVO.java @@ -102,6 +102,11 @@ public class EventMaintainOutVO implements Serializable { @ApiModelProperty(value = "发布人") private String createBy; + /** + * 正文图片id + */ + @ApiModelProperty(value = "正文图片id") + private String contentImageId; } diff --git a/src/main/java/com/chinaunicom/mall/ebtp/extend/partyMemberEvent/service/EventContactSuggestionService.java b/src/main/java/com/chinaunicom/mall/ebtp/extend/partyMemberEvent/service/EventContactSuggestionService.java index e8ff99a..29cf17a 100644 --- a/src/main/java/com/chinaunicom/mall/ebtp/extend/partyMemberEvent/service/EventContactSuggestionService.java +++ b/src/main/java/com/chinaunicom/mall/ebtp/extend/partyMemberEvent/service/EventContactSuggestionService.java @@ -1,7 +1,11 @@ package com.chinaunicom.mall.ebtp.extend.partyMemberEvent.service; import com.baomidou.mybatisplus.extension.service.IService; +import com.chinaunicom.mall.ebtp.common.poiExport.entity.ExcelTable; import com.chinaunicom.mall.ebtp.extend.partyMemberEvent.entity.EventContactSuggestion; +import com.chinaunicom.mall.ebtp.extend.partyMemberEvent.entity.EventMaintainInVO; + +import java.util.List; /** * 对数据表 event_contact_suggestion 操作的 service @@ -13,4 +17,7 @@ public interface EventContactSuggestionService extends IService querySuggestion(EventMaintainInVO inVO); + + ExcelTable export(List ids); } diff --git a/src/main/java/com/chinaunicom/mall/ebtp/extend/partyMemberEvent/service/EventStyleService.java b/src/main/java/com/chinaunicom/mall/ebtp/extend/partyMemberEvent/service/EventStyleService.java index aed3aae..838ad6d 100644 --- a/src/main/java/com/chinaunicom/mall/ebtp/extend/partyMemberEvent/service/EventStyleService.java +++ b/src/main/java/com/chinaunicom/mall/ebtp/extend/partyMemberEvent/service/EventStyleService.java @@ -24,7 +24,7 @@ public interface EventStyleService extends IService{ boolean saveStyleOrProject(EventMaintainOutVO inVO); - boolean sendStyleOrProject(String id); + boolean sendStyleOrProject(String id,String status); boolean deleteStyleOrProject(String id); } diff --git a/src/main/java/com/chinaunicom/mall/ebtp/extend/partyMemberEvent/service/impl/EventContactSuggestionServiceImpl.java b/src/main/java/com/chinaunicom/mall/ebtp/extend/partyMemberEvent/service/impl/EventContactSuggestionServiceImpl.java index 7ce1a54..ca43644 100644 --- a/src/main/java/com/chinaunicom/mall/ebtp/extend/partyMemberEvent/service/impl/EventContactSuggestionServiceImpl.java +++ b/src/main/java/com/chinaunicom/mall/ebtp/extend/partyMemberEvent/service/impl/EventContactSuggestionServiceImpl.java @@ -1,18 +1,35 @@ package com.chinaunicom.mall.ebtp.extend.partyMemberEvent.service.impl; +import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.chinaunicom.mall.ebtp.common.base.entity.BaseCacheUser; import com.chinaunicom.mall.ebtp.common.base.service.IBaseCacheUserService; +import com.chinaunicom.mall.ebtp.common.poiExport.entity.ExcelTable; +import com.chinaunicom.mall.ebtp.common.poiExport.entity.ExcelTd; +import com.chinaunicom.mall.ebtp.common.poiExport.entity.ExcelTr; import com.chinaunicom.mall.ebtp.common.util.PropertyUtils; import com.chinaunicom.mall.ebtp.extend.partyMemberEvent.dao.EventContactSuggestionMapper; import com.chinaunicom.mall.ebtp.extend.partyMemberEvent.entity.EventContactSuggestion; +import com.chinaunicom.mall.ebtp.extend.partyMemberEvent.entity.EventMaintainInVO; +import com.chinaunicom.mall.ebtp.extend.partyMemberEvent.entity.EventSubject; import com.chinaunicom.mall.ebtp.extend.partyMemberEvent.service.EventContactSuggestionService; import org.springframework.stereotype.Service; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import javax.annotation.Resource; +import java.text.DateFormat; +import java.text.SimpleDateFormat; import java.time.LocalDateTime; +import java.util.Date; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.atomic.AtomicInteger; /** * 对数据表 event_contact_suggestion 操作的 serviceImpl @@ -38,4 +55,92 @@ public class EventContactSuggestionServiceImpl extends ServiceImpl querySuggestion(EventMaintainInVO inVO) { + LambdaQueryWrapper query = Wrappers.lambdaQuery(); + if (ObjectUtil.isNotNull(inVO.getStartTime())) { + query.gt(EventContactSuggestion::getCreateTime, inVO.getStartTime()); + } + + if (ObjectUtil.isNotNull(inVO.getEndTime())) { + query.lt(EventContactSuggestion::getCreateTime, inVO.getEndTime()); + } + if (StrUtil.isNotBlank(inVO.getType())) { + query.eq(EventContactSuggestion::getSuggestionType, inVO.getType()); + } + return this.list(query); + } + + + @Override + public ExcelTable export(List ids) { + LambdaQueryWrapper query = Wrappers.lambdaQuery(); + if (ids != null) { + query.in(EventContactSuggestion::getId, ids); + } + List list = this.list(query); + Map titleMap = new LinkedHashMap<>(16); + titleMap.put("num", "num"); + titleMap.put("contact_name", "联系人名称"); + titleMap.put("suggestion_type", "意见类型"); + titleMap.put("suggestion_content", "意见内容"); + titleMap.put("instructions", "补充说明"); + titleMap.put("suggestion_sponsor", "意见提出人"); + titleMap.put("suggestion_sponsor_id", "意见提出人id"); + titleMap.put("suggestion_sponsor_unit", "意见提出人组织机构"); + titleMap.put("remark", "备注"); + titleMap.put("create_time", "创建时间"); + titleMap.put("company", "公司"); + //制作表格 + ExcelTable table = new ExcelTable("第一页"); + DateFormat df = new SimpleDateFormat("yyyyMMddhhmmss"); + table.setFileName("表" + df.format(new Date())); + /*第0行*/ + ExcelTr tr0 = new ExcelTr(); + tr0.setHeight(800); + tr0.add(new ExcelTd().setTdValue("表").setIsRowMerge(true).setRowMergeNum(8).setCellStyleKey("name")); + table.add(tr0); + /*第一行*/ + ExcelTr tr1 = new ExcelTr(); + tr1.setHeight(480); + tr1.add(new ExcelTd().setTdValue("序号").setCellStyleKey("title1")); + tr1.add(new ExcelTd().setTdValue("联系人名称").setCellStyleKey("title1")); + tr1.add(new ExcelTd().setTdValue("意见类型").setCellStyleKey("title1")); + tr1.add(new ExcelTd().setTdValue("意见内容").setCellStyleKey("title1")); + tr1.add(new ExcelTd().setTdValue("补充说明").setCellStyleKey("title1")); + tr1.add(new ExcelTd().setTdValue("意见提出人").setCellStyleKey("title1")); + tr1.add(new ExcelTd().setTdValue("意见提出人公司").setCellStyleKey("title1")); + tr1.add(new ExcelTd().setTdValue("意见提出人组织机构").setCellStyleKey("title1")); + tr1.add(new ExcelTd().setTdValue("备注").setCellStyleKey("title1")); + tr1.add(new ExcelTd().setTdValue("创建时间").setCellStyleKey("title1")); + + table.add(tr1); + + /*第4行开始投递数据表头*/ + ExcelTr tr4 = new ExcelTr(); + tr4.setHeight(480); + for (String key : titleMap.keySet()) { + tr4.add(new ExcelTd().setTdValue(titleMap.get(key)).setCellStyleKey("title1").setWidth(6000)); + } + table.add(tr4); + AtomicInteger num = new AtomicInteger(1); + List> mapList = JSON.parseObject(JSON.toJSONString(list), List.class); + mapList.forEach(info -> { + ExcelTr tr5 = new ExcelTr(); + for (String key : titleMap.keySet()) { + String tValue = ""; + if ("num".equals(key)) { + tValue = num.toString(); + } else { + tValue = info.get(key) != null ? String.valueOf(info.get(key)) : ""; + } + tr5.add(new ExcelTd().setTdValue(tValue).setCellStyleKey("title1").setWidth(6000)); + } + num.addAndGet(1); + table.add(tr5); + }); + + return table; + } } diff --git a/src/main/java/com/chinaunicom/mall/ebtp/extend/partyMemberEvent/service/impl/EventStyleServiceImpl.java b/src/main/java/com/chinaunicom/mall/ebtp/extend/partyMemberEvent/service/impl/EventStyleServiceImpl.java index 2ed3b09..3b0d204 100644 --- a/src/main/java/com/chinaunicom/mall/ebtp/extend/partyMemberEvent/service/impl/EventStyleServiceImpl.java +++ b/src/main/java/com/chinaunicom/mall/ebtp/extend/partyMemberEvent/service/impl/EventStyleServiceImpl.java @@ -56,6 +56,7 @@ public class EventStyleServiceImpl extends ServiceImpl imageIdList = list.stream().map(EventStyle::getImage).distinct().collect(Collectors.toList()); BaseResponse> queryReturn = documentCenterService.queryReturn(imageIdList); @@ -187,6 +188,7 @@ public class EventStyleServiceImpl extends ServiceImpl list = this.list(query); // List subjectIdList = list.stream().map(EventSubject::getId).collect(Collectors.toList());