后台程序

This commit is contained in:
liuh
2022-07-12 23:36:49 +08:00
parent de010e9822
commit 9335be85f8
9 changed files with 196 additions and 12 deletions

View File

@ -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 {

View File

@ -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<Boolean> sendStyleOrProject(@RequestParam String id) {
return BaseResponse.success(eventStyleService.sendStyleOrProject(id));
public BaseResponse<Boolean> sendStyleOrProject(@RequestParam("id") String id,@RequestParam("status") String status) {
return BaseResponse.success(eventStyleService.sendStyleOrProject(id, status));
}
@ApiOperation("删除风采或项目")
@GetMapping("/styleProject/delete")
public BaseResponse<Boolean> deleteStyleOrProject(@RequestParam String id) {
public BaseResponse<Boolean> deleteStyleOrProject(@RequestParam("id") String id) {
return BaseResponse.success(eventStyleService.deleteStyleOrProject(id));
}
@ApiOperation("后台查询列表")
@PostMapping("/suggestion/list")
public BaseResponse<List<EventContactSuggestion>> querySuggestion(@RequestBody EventMaintainInVO inVO) {
return BaseResponse.success(eventContactSuggestionService.querySuggestion(inVO));
}
@GetMapping(value = "/suggestion/export/")
public BaseResponse<Boolean> export(@RequestParam("ids") List<String> 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);
}
}
}
}

View File

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

View File

@ -102,6 +102,11 @@ public class EventMaintainOutVO implements Serializable {
@ApiModelProperty(value = "发布人")
private String createBy;
/**
* 正文图片id
*/
@ApiModelProperty(value = "正文图片id")
private String contentImageId;
}

View File

@ -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<EventContactSugg
Boolean submitSuggestion(EventContactSuggestion suggestion);
List<EventContactSuggestion> querySuggestion(EventMaintainInVO inVO);
ExcelTable export(List<String> ids);
}

View File

@ -24,7 +24,7 @@ public interface EventStyleService extends IService<EventStyle>{
boolean saveStyleOrProject(EventMaintainOutVO inVO);
boolean sendStyleOrProject(String id);
boolean sendStyleOrProject(String id,String status);
boolean deleteStyleOrProject(String id);
}

View File

@ -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<EventContactS
}
return this.save(suggestion);
}
@Override
public List<EventContactSuggestion> querySuggestion(EventMaintainInVO inVO) {
LambdaQueryWrapper<EventContactSuggestion> 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<String> ids) {
LambdaQueryWrapper<EventContactSuggestion> query = Wrappers.lambdaQuery();
if (ids != null) {
query.in(EventContactSuggestion::getId, ids);
}
List<EventContactSuggestion> list = this.list(query);
Map<String, String> 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<Map<String, Object>> 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;
}
}

View File

@ -56,6 +56,7 @@ public class EventStyleServiceImpl extends ServiceImpl<EventStyleMapper, EventSt
} else {
query.eq(EventStyle::getBanner, "0").eq(EventStyle::getStatus, "1").orderByAsc(EventStyle::getSort);
}
query.ne(EventStyle::getDeleteFlag, "1");
list = this.list(query);
List<String> imageIdList = list.stream().map(EventStyle::getImage).distinct().collect(Collectors.toList());
BaseResponse<List<DocumentDataVO>> queryReturn = documentCenterService.queryReturn(imageIdList);
@ -187,6 +188,7 @@ public class EventStyleServiceImpl extends ServiceImpl<EventStyleMapper, EventSt
subject.setStatus("0");
subject.setCreateTime(LocalDateTime.now());
subject.setCreateBy(inVO.getCreateBy());
subject.setContentImageId(inVO.getContentImageId());
return eventSubjectService.saveOrUpdate(subject);
}
EventStyle style = new EventStyle();
@ -203,22 +205,22 @@ public class EventStyleServiceImpl extends ServiceImpl<EventStyleMapper, EventSt
style.setStatus("0");
style.setCreateTime(LocalDateTime.now());
style.setCreateBy(inVO.getCreateBy());
style.setContentImageId(inVO.getContentImageId());
return this.saveOrUpdate(style);
}
@Override
public boolean sendStyleOrProject(String id) {
public boolean sendStyleOrProject(String id, String status) {
EventSubject subject = eventSubjectService.getById(id);
if (ObjectUtil.isNotNull(subject) && StrUtil.isNotBlank(subject.getId())) {
subject.setStatus("1");
subject.setStatus(status);
subject.setSendTime(LocalDateTime.now());
return eventSubjectService.updateById(subject);
}
EventStyle style = this.getById(id);
if (ObjectUtil.isNotNull(style) && StrUtil.isNotBlank(style.getId())) {
style.setStatus("1");
style.setStatus(status);
style.setSendTime(LocalDateTime.now());
return this.updateById(style);
}

View File

@ -46,6 +46,7 @@ public class EventSubjectServiceImpl extends ServiceImpl<EventSubjectMapper, Eve
if (ObjectUtil.isNotNull(inVO)) {
query.like(StrUtil.isNotBlank(inVO.getParam()), EventSubject::getTitle, inVO.getParam());
}
query.ne(EventSubject::getDeleteFlag, "1");
query.orderByDesc(EventSubject::getCreateTime);
// List<EventSubject> list = this.list(query);
// List<String> subjectIdList = list.stream().map(EventSubject::getId).collect(Collectors.toList());