Browse Source

工作日志

dev
zhaoqifeng 4 years ago
parent
commit
dbe98fab02
  1. 12
      epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/constant/MemoConstant.java
  2. 7
      epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/controller/MemoWorkDiaryController.java
  3. 75
      epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/MemoWorkDiaryServiceImpl.java

12
epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/constant/MemoConstant.java

@ -0,0 +1,12 @@
package com.epmet.constant;
/**
* @Description
* @Author zhaoqifeng
* @Date 2022/3/15 16:56
*/
public interface MemoConstant {
String WORK_DIARY = "work_diary";
String CONCERN = "concern";
String DIFFICULTY = "difficulty";
}

7
epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/controller/MemoWorkDiaryController.java

@ -59,18 +59,21 @@ public class MemoWorkDiaryController {
@NoRepeatSubmit
@PostMapping("save")
public Result save(@RequestBody MemoWorkDiaryDTO dto){
public Result save(@LoginUser TokenDto tokenDto, @RequestBody MemoWorkDiaryDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
dto.setCustomerId(tokenDto.getCustomerId());
dto.setCreatedBy(tokenDto.getUserId());
memoWorkDiaryService.save(dto);
return new Result();
}
@NoRepeatSubmit
@PostMapping("update")
public Result update(@RequestBody MemoWorkDiaryDTO dto){
public Result update(@LoginUser TokenDto tokenDto, @RequestBody MemoWorkDiaryDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
dto.setCustomerId(tokenDto.getCustomerId());
memoWorkDiaryService.update(dto);
return new Result();
}

75
epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/MemoWorkDiaryServiceImpl.java

@ -4,22 +4,28 @@ import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.constant.MemoConstant;
import com.epmet.dao.MemoWorkDiaryDao;
import com.epmet.dto.MemoAttachmentDTO;
import com.epmet.dto.MemoAttrDTO;
import com.epmet.dto.MemoWorkDiaryDTO;
import com.epmet.dto.form.MemoWorkDiaryFormDTO;
import com.epmet.entity.MemoAttachmentEntity;
import com.epmet.entity.MemoWorkDiaryEntity;
import com.epmet.service.MemoAttachmentService;
import com.epmet.service.MemoAttrService;
import com.epmet.service.MemoWorkDiaryService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
/**
* 备忘录-工作日志
@ -46,7 +52,6 @@ public class MemoWorkDiaryServiceImpl extends BaseServiceImpl<MemoWorkDiaryDao,
@Override
public List<MemoWorkDiaryDTO> list(MemoWorkDiaryFormDTO formDTO) {
List<MemoWorkDiaryDTO> list = baseDao.getPage(formDTO);
return list;
}
@ -54,12 +59,16 @@ public class MemoWorkDiaryServiceImpl extends BaseServiceImpl<MemoWorkDiaryDao,
public MemoWorkDiaryDTO get(MemoWorkDiaryFormDTO formDTO) {
MemoWorkDiaryEntity entity = baseDao.selectById(formDTO.getId());
MemoWorkDiaryDTO dto = ConvertUtils.sourceToTarget(entity, MemoWorkDiaryDTO.class);
//获取提醒时间
MemoAttrDTO memoAttr = memoAttrService.get(formDTO.getId());
if (null != memoAttr && null != dto) {
dto.setRemindTime(memoAttr.getRemindTime());
if (null != dto) {
//获取提醒时间
MemoAttrDTO memoAttr = memoAttrService.get(formDTO.getId());
if (null != memoAttr) {
dto.setRemindTime(memoAttr.getRemindTime());
}
//获取附件列表
List<MemoAttachmentDTO> attachmentList = memoAttachmentService.getListByMemoId(formDTO.getId());
dto.setAttachmentList(attachmentList);
}
//获取附件列表
//更新阅读状态
if (NumConstant.ONE_STR.equals(formDTO.getReadFlag())) {
MemoAttrDTO memoAttrDTO = new MemoAttrDTO();
@ -75,6 +84,28 @@ public class MemoWorkDiaryServiceImpl extends BaseServiceImpl<MemoWorkDiaryDao,
public void save(MemoWorkDiaryDTO dto) {
MemoWorkDiaryEntity entity = ConvertUtils.sourceToTarget(dto, MemoWorkDiaryEntity.class);
insert(entity);
//保存属性
MemoAttrDTO attr = ConvertUtils.sourceToTarget(dto, MemoAttrDTO.class);;
attr.setType(MemoConstant.WORK_DIARY);
attr.setReadFlag(NumConstant.ZERO);
attr.setReceiver(dto.getCreatedBy());
memoAttrService.save(attr);
//删除原来的附件
memoAttachmentService.deleteByMemoId(entity.getId());
//保存新的照片
if (CollectionUtils.isNotEmpty(dto.getAttachmentList())) {
AtomicInteger i = new AtomicInteger(NumConstant.ZERO);
List<MemoAttachmentEntity> list = dto.getAttachmentList().stream().map(item -> {
MemoAttachmentEntity e = ConvertUtils.sourceToTarget(item, MemoAttachmentEntity.class);
e.setCustomerId(dto.getCustomerId());
e.setRemindMsgId(entity.getId());
e.setSort(i.getAndIncrement());
return e;
}).collect(Collectors.toList());
memoAttachmentService.insertBatch(list);
}
}
@Override
@ -82,13 +113,43 @@ public class MemoWorkDiaryServiceImpl extends BaseServiceImpl<MemoWorkDiaryDao,
public void update(MemoWorkDiaryDTO dto) {
MemoWorkDiaryEntity entity = ConvertUtils.sourceToTarget(dto, MemoWorkDiaryEntity.class);
updateById(entity);
//时间有变动时保存属性,readFlag变为0
MemoAttrDTO attr = memoAttrService.get(dto.getId());
if (dto.getRemindTime() != attr.getRemindTime()) {
attr.setRemindTime(dto.getRemindTime());
attr.setReadFlag(NumConstant.ZERO);
attr.setUpdatedTime(null);
memoAttrService.update(attr);
}
//删除原来的附件
memoAttachmentService.deleteByMemoId(entity.getId());
//保存新的照片
if (CollectionUtils.isNotEmpty(dto.getAttachmentList())) {
AtomicInteger i = new AtomicInteger(NumConstant.ZERO);
List<MemoAttachmentEntity> list = dto.getAttachmentList().stream().map(item -> {
MemoAttachmentEntity e = ConvertUtils.sourceToTarget(item, MemoAttachmentEntity.class);
e.setCustomerId(dto.getCustomerId());
e.setRemindMsgId(dto.getId());
e.setSort(i.getAndIncrement());
return e;
}).collect(Collectors.toList());
memoAttachmentService.insertBatch(list);
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(String[] ids) {
// 逻辑删除(@TableLogic 注解)
baseDao.deleteBatchIds(Arrays.asList(ids));
List<String> list = Arrays.asList(ids);
baseDao.deleteBatchIds(list);
memoAttrService.delete(ids);
list.forEach(id -> {
//删除附件
memoAttachmentService.deleteByMemoId(id);
});
}
}
Loading…
Cancel
Save