Commit bf5d4b07 by danmo

1、任务宝新增bug修复

2、海报bug修复
1 parent 305b72d9
package com.linkwechat.web.controller.wecom;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.linkwechat.common.core.controller.BaseController;
import com.linkwechat.common.core.domain.AjaxResult;
......@@ -45,21 +46,13 @@ public class WePosterController extends BaseController {
@PostMapping(value = "insert")
@ApiOperation("创建海报")
// @PreAuthorize("@ss.hasAnyPermi('wecom:poster:insert')")
@Transactional(rollbackFor = RuntimeException.class)
public AjaxResult insert(@RequestBody WePoster poster) {
wePosterService.generateSimpleImg(poster);
poster.setId(SnowFlakeUtil.nextId());
poster.setDelFlag(0);
poster.setMediaType(MediaType.POSTER.getType());
/*if(poster.getCategoryId() == null){
return AjaxResult.error("请选择海报分类");
}*/
wePosterService.saveOrUpdate(poster);
if(!CollectionUtils.isEmpty(poster.getPosterSubassemblyList())) {
if(CollectionUtil.isNotEmpty(poster.getPosterSubassemblyList())) {
poster.getPosterSubassemblyList().forEach(wePosterSubassembly -> {
wePosterSubassembly.setDelFlag(0);
wePosterSubassembly.setId(SnowFlakeUtil.nextId());
wePosterSubassembly.setPosterId(poster.getId());
});
wePosterSubassemblyService.saveBatch(poster.getPosterSubassemblyList());
......@@ -86,9 +79,7 @@ public class WePosterController extends BaseController {
List<WePosterSubassembly> updateList = new ArrayList<>();
poster.getPosterSubassemblyList().forEach(wePosterSubassembly -> {
if (wePosterSubassembly.getId() == null) {
wePosterSubassembly.setId(SnowFlakeUtil.nextId());
wePosterSubassembly.setPosterId(poster.getId());
wePosterSubassembly.setDelFlag(0);
insertList.add(wePosterSubassembly);
} else {
posterSubassemblyMap.remove(wePosterSubassembly.getId());
......@@ -109,17 +100,7 @@ public class WePosterController extends BaseController {
return AjaxResult.success("修改成功");
}
/*@GetMapping(value = "list")
@ApiOperation("列表查询海报")
public AjaxResult list(Long categoryId,String name){
List<WePoster> fontList = wePosterService.lambdaQuery()
.eq(WePoster::getDelFlag,0)
.eq(categoryId != null,WePoster::getCategoryId,categoryId)
.like(StringUtils.isNotBlank(name),WePoster::getTitle,name)
.orderByDesc(WePoster::getCreateTime)
.list();
return AjaxResult.success(fontList);
}*/
@GetMapping(value = "entity/{id}")
// @PreAuthorize("@ss.hasAnyPermi('wecom:poster:entity')")
......
......@@ -31,8 +31,6 @@ public class WePosterFontController extends BaseController {
@ApiOperation("创建海报字体")
@Transactional(rollbackFor = RuntimeException.class)
public AjaxResult insertPosterFont(@RequestBody WePosterFont posterFont) {
posterFont.setId(SnowFlakeUtil.nextId());
posterFont.setDelFlag(0);
posterFont.setMediaType(MediaType.POSTER_FONT.getType());
wePosterFontService.save(posterFont);
return AjaxResult.success("创建成功");
......
......@@ -130,13 +130,8 @@ public class WeTaskFissionController extends BaseController {
@Log(title = "任务宝", businessType = BusinessType.INSERT)
@PostMapping("/add")
public AjaxResult add(@RequestBody WeTaskFission weTaskFission) {
Long fissionTaskId = weTaskFissionService.insertWeTaskFission(weTaskFission);
if (fissionTaskId != null) {
JSONObject json = new JSONObject();
json.put("id", fissionTaskId);
return AjaxResult.success(json.toJSONString());
}
return AjaxResult.error();
weTaskFissionService.insertWeTaskFission(weTaskFission);
return AjaxResult.success();
}
/**
......@@ -183,14 +178,13 @@ public class WeTaskFissionController extends BaseController {
/**
* 发送裂变任务
*/
@ApiOperation(value = "发送裂变任务", httpMethod = "GET")
// @PreAuthorize("@ss.hasPermi('wecom:fission:send')")
/*@ApiOperation(value = "发送裂变任务", httpMethod = "GET")
@Log(title = "发送裂变任务", businessType = BusinessType.OTHER)
@GetMapping("/send/{id}")
public AjaxResult send(@PathVariable Long id) throws Exception {
weTaskFissionService.sendWeTaskFission(id);
return AjaxResult.success();
}
}*/
/**
* 添加群裂变完成记录
......
package com.linkwechat.wecom.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
......@@ -8,10 +9,12 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.List;
/**
* 海报
*
* @author ws
*/
@EqualsAndHashCode(callSuper = true)
......@@ -20,7 +23,7 @@ import java.util.List;
@ApiModel(value = "海报")
public class WePoster extends BaseEntity {
@TableId
@TableId(type = IdType.AUTO)
@ApiModelProperty(value = "id")
private Long id;
......@@ -53,10 +56,6 @@ public class WePoster extends BaseEntity {
private Long type;
@TableField
@ApiModelProperty(value = "海报状态 0 启用 1 关闭")
private Integer delFlag;
@TableField
@ApiModelProperty(value = "海报背景宽度")
private Integer width;
......@@ -76,11 +75,16 @@ public class WePoster extends BaseEntity {
@ApiModelProperty("其他字段")
private String otherField;
@ApiModelProperty("状态 0-启用 1-不启用")
private Integer status;
@ApiModelProperty(value = "删除状态 0-正常 1-删除")
private Integer delFlag;
/**
* 海报组件数组
*/
@TableField(exist = false)
private List<WePosterSubassembly> posterSubassemblyList;
}
package com.linkwechat.wecom.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
......@@ -22,7 +23,7 @@ public class WePosterFont extends BaseEntity {
/**
* id
*/
@TableId
@TableId(type = IdType.AUTO)
@ApiModelProperty(value = "id")
private Long id;
......
package com.linkwechat.wecom.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
......@@ -19,7 +20,7 @@ import lombok.EqualsAndHashCode;
@ApiModel(value = "海报组成部件")
public class WePosterSubassembly extends BaseEntity {
@TableId
@TableId(type = IdType.AUTO)
@ApiModelProperty(value = "id")
private Long id;
......
......@@ -41,7 +41,7 @@ public interface IWeTaskFissionService extends IService<WeTaskFission> {
* @param weTaskFission 任务宝
* @return 结果
*/
public Long insertWeTaskFission(WeTaskFission weTaskFission);
public void insertWeTaskFission(WeTaskFission weTaskFission);
/**
* 修改任务宝
......@@ -70,9 +70,9 @@ public interface IWeTaskFissionService extends IService<WeTaskFission> {
/**
* 发送任务
*
* @param id 任务id
* @param weTaskFission 任务
*/
public void sendWeTaskFission(Long id) throws Exception;
public void sendWeTaskFission(WeTaskFission weTaskFission) throws Exception;
/**
* 生成裂变任务海报
......
package com.linkwechat.wecom.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.linkwechat.common.config.CosConfig;
import com.linkwechat.common.config.RuoYiConfig;
import com.linkwechat.common.config.ServerConfig;
import com.linkwechat.common.exception.wecom.WeComException;
import com.linkwechat.common.utils.file.FileUploadUtils;
import com.linkwechat.common.utils.img.ImageUtils;
import com.linkwechat.common.utils.img.NetFileUtils;
......@@ -12,24 +12,20 @@ import com.linkwechat.wecom.domain.WePoster;
import com.linkwechat.wecom.domain.WePosterFont;
import com.linkwechat.wecom.domain.WePosterSubassembly;
import com.linkwechat.wecom.mapper.WePosterMapper;
import com.linkwechat.wecom.service.IWeCategoryService;
import com.linkwechat.wecom.service.IWePosterFontService;
import com.linkwechat.wecom.service.IWePosterService;
import com.linkwechat.wecom.service.IWePosterSubassemblyService;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.net.URL;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
......@@ -72,22 +68,15 @@ public class WePosterServiceImpl extends ServiceImpl<WePosterMapper, WePoster> i
*/
@Override
public WePoster selectOne(Long id) {
WePoster poster = this.lambdaQuery()
.eq(WePoster::getId, id)
.eq(WePoster::getDelFlag, 0)
.list().get(0);
if (poster == null) {
return null;
}
poster.setPosterSubassemblyList(posterSubassemblyService.lambdaQuery().eq(WePosterSubassembly::getPosterId, poster.getId()).list());
if (!CollectionUtils.isEmpty(poster.getPosterSubassemblyList())) {
List<Long> fontIdList = poster.getPosterSubassemblyList().stream().filter(wePosterSubassembly -> wePosterSubassembly.getFontId() != null).map(WePosterSubassembly::getFontId).distinct().collect(Collectors.toList());
if (!CollectionUtils.isEmpty(fontIdList)) {
WePoster poster = this.getById(id);
List<WePosterSubassembly> subassemblyList = posterSubassemblyService.lambdaQuery().eq(WePosterSubassembly::getPosterId, id).list();
if (CollectionUtil.isNotEmpty(subassemblyList)) {
List<Long> fontIdList = subassemblyList.stream().filter(wePosterSubassembly -> wePosterSubassembly.getFontId() != null).map(WePosterSubassembly::getFontId).distinct().collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(fontIdList)) {
List<WePosterFont> fontList = posterFontService.lambdaQuery().in(WePosterFont::getId, fontIdList).list();
if (!CollectionUtils.isEmpty(fontList)) {
if (CollectionUtil.isNotEmpty(fontList)) {
Map<Long, WePosterFont> fontMap = fontList.stream().collect(Collectors.toMap(WePosterFont::getId, f -> f));
poster.getPosterSubassemblyList().stream().filter(wePosterSubassembly -> wePosterSubassembly.getFontId() != null).forEach(wePosterSubassembly -> {
subassemblyList.stream().filter(wePosterSubassembly -> wePosterSubassembly.getFontId() != null).forEach(wePosterSubassembly -> {
WePosterFont font = fontMap.get(wePosterSubassembly.getFontId());
if (font != null) {
wePosterSubassembly.setFont(font);
......@@ -95,11 +84,8 @@ public class WePosterServiceImpl extends ServiceImpl<WePosterMapper, WePoster> i
});
}
}
poster.setPosterSubassemblyList(subassemblyList);
}
/*if(poster.getCategoryId() != null){
weCategoryService.findWeCategoryById(poster.getId());
}*/
return poster;
}
......@@ -147,27 +133,14 @@ public class WePosterServiceImpl extends ServiceImpl<WePosterMapper, WePoster> i
.collect(Collectors.toMap(wePosterSubassembly -> {
return wePosterSubassembly.getFontId() + "_" + wePosterSubassembly.getFontSize() + "_" + wePosterSubassembly.getFontStyle();
}, wePosterSubassembly -> posterFontService.getFont(wePosterSubassembly.getFontId(), wePosterSubassembly.getFontSize(), wePosterSubassembly.getFontStyle())));
Map<String, NetFileUtils.FileCallable> fileCallableMap = poster.getPosterSubassemblyList().stream().map(WePosterSubassembly::getImgPath).filter(StringUtils::isNotBlank).distinct().collect(Collectors.toMap(s -> s, NetFileUtils::getNetFile));
if (CollectionUtils.isEmpty(fileCallableMap)) {
fileCallableMap = new HashMap<>();
}
fileCallableMap.put(poster.getBackgroundImgPath(), NetFileUtils.getNetFile(poster.getBackgroundImgPath()));
Map<String, BufferedImage> bufferedImageMap = fileCallableMap.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, stringFileCallableEntry -> {
try {
ByteArrayOutputStream byteArrayOutputStream = NetFileUtils.getByteArrayOutputStream(stringFileCallableEntry.getValue(), false);
return ImageUtils.copyBufferedImage(ImageIO.read(new ByteArrayInputStream(Objects.requireNonNull(byteArrayOutputStream).toByteArray())),
BufferedImage.TYPE_INT_ARGB);
} catch (IOException e) {
......@@ -176,15 +149,11 @@ public class WePosterServiceImpl extends ServiceImpl<WePosterMapper, WePoster> i
}
}));
BufferedImage backgroundImg = bufferedImageMap.get(poster.getBackgroundImgPath());
poster.setWidth(backgroundImg.getWidth());
poster.setHeight(backgroundImg.getHeight());
poster.getPosterSubassemblyList().forEach(wePosterSubassembly -> {
if (wePosterSubassembly.getType().equals(1)) {
Font font = fontMap.get(wePosterSubassembly.getFontId() + "_" + wePosterSubassembly.getFontSize() + "_" + wePosterSubassembly.getFontStyle());
......@@ -233,12 +202,12 @@ public class WePosterServiceImpl extends ServiceImpl<WePosterMapper, WePoster> i
return poster.getSampleImgPath();
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException("图片生成错误");
throw new WeComException("图片生成错误");
}
}
@Override
public List<WeMaterial> findWePosterToWeMaterial(String categoryId,String name) {
public List<WeMaterial> findWePosterToWeMaterial(String categoryId, String name) {
return this.baseMapper.findWePosterToWeMaterial(categoryId, name);
}
}
......@@ -125,8 +125,8 @@ public class WeTaskFissionServiceImpl extends ServiceImpl<WeTaskFissionMapper, W
* @return 结果
*/
@Override
@Transactional
public Long insertWeTaskFission(WeTaskFission weTaskFission) {
@Transactional(rollbackFor = {Exception.class,WeComException.class})
public void insertWeTaskFission(WeTaskFission weTaskFission) {
weTaskFission.setCreateBy(SecurityUtils.getUsername());
weTaskFission.setCreateTime(DateUtils.getNowDate());
groupQrcodeHandler(weTaskFission);
......@@ -140,8 +140,12 @@ public class WeTaskFissionServiceImpl extends ServiceImpl<WeTaskFissionMapper, W
weTaskFissionStaffService.insertWeTaskFissionStaffList(weTaskFission.getTaskFissionStaffs());
}
}
try {
sendWeTaskFission(weTaskFission);
} catch (Exception e) {
throw new WeComException(e.getMessage());
}
}
return weTaskFission.getId();
}
/**
......@@ -197,15 +201,13 @@ public class WeTaskFissionServiceImpl extends ServiceImpl<WeTaskFissionMapper, W
@Override
public void sendWeTaskFission(Long id) throws Exception {
WeTaskFission weTaskFission = selectWeTaskFissionById(id);
public void sendWeTaskFission(WeTaskFission weTaskFission) throws Exception {
//海报路径
String postersPath = weTaskFission.getPostersUrl();
//目标员工id
String fissStaffId = weTaskFission.getFissionTargetId();
//H5生成海报页面路径
String pageUrlStr = StringUtils.format(pageUrl,id,fissStaffId,weTaskFission.getPostersId());
String pageUrlStr = StringUtils.format(pageUrl,weTaskFission.getId(),fissStaffId,weTaskFission.getPostersId());
WeAddGroupMessageQuery messageQuery = new WeAddGroupMessageQuery();
messageQuery.setChatType(1);
......@@ -219,16 +221,13 @@ public class WeTaskFissionServiceImpl extends ServiceImpl<WeTaskFissionMapper, W
weMessageTemplate.setPicUrl(postersPath);
messageQuery.setAttachmentsList(ListUtil.toList(weMessageTemplate));
if (weTaskFission.getStartTime() != null && weTaskFission.getStartTime().getTime() <= System.currentTimeMillis()) {
messageQuery.setIsTask(0);
}else {
messageQuery.setIsTask(1);
messageQuery.setSendTime(weTaskFission.getStartTime());
}
//查询发起成员
List<WeTaskFissionStaff> weTaskFissionStaffList = weTaskFissionStaffService.selectWeTaskFissionStaffByTaskId(id);
List<WeTaskFissionStaff> weTaskFissionStaffList = weTaskFission.getTaskFissionStaffs();
//获取部门id
String departmentIds = Optional.ofNullable(weTaskFissionStaffList).orElseGet(ArrayList::new).stream().filter(weTaskFissionStaff ->
WeConstans.USE_SCOP_BUSINESSID_TYPE_ORG.equals(weTaskFissionStaff.getStaffType()))
......
......@@ -11,14 +11,15 @@
id
FROM
we_poster
where
del_flag=0
where 1=1
<if test="categoryId !=null and categoryId !=''">
AND category_id = #{categoryId}
</if>
<if test="name !=null and name !=''">
AND title like concat('%',#{name,jdbcType=VARCHAR},'%')
</if>
and status = 0
and del_flag=0
ORDER BY create_time DESC
</select>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!