|
@ -1,22 +1,31 @@ |
|
|
package com.epmet.service.impl; |
|
|
package com.epmet.service.impl; |
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
import com.epmet.commons.tools.constant.FieldConstant; |
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
|
|
import com.epmet.constant.MemoConstant; |
|
|
import com.epmet.dao.MemoConcernDao; |
|
|
import com.epmet.dao.MemoConcernDao; |
|
|
|
|
|
import com.epmet.dto.MemoAttachmentDTO; |
|
|
|
|
|
import com.epmet.dto.MemoAttrDTO; |
|
|
import com.epmet.dto.MemoConcernDTO; |
|
|
import com.epmet.dto.MemoConcernDTO; |
|
|
|
|
|
import com.epmet.dto.form.MemoConcernFormDTO; |
|
|
|
|
|
import com.epmet.entity.MemoAttachmentEntity; |
|
|
import com.epmet.entity.MemoConcernEntity; |
|
|
import com.epmet.entity.MemoConcernEntity; |
|
|
|
|
|
import com.epmet.service.MemoAttachmentService; |
|
|
|
|
|
import com.epmet.service.MemoAttrService; |
|
|
import com.epmet.service.MemoConcernService; |
|
|
import com.epmet.service.MemoConcernService; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import com.github.pagehelper.PageHelper; |
|
|
|
|
|
import com.github.pagehelper.PageInfo; |
|
|
|
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
import java.util.Arrays; |
|
|
import java.util.Arrays; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
import java.util.Map; |
|
|
import java.util.concurrent.atomic.AtomicInteger; |
|
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 备忘录-人文关怀 |
|
|
* 备忘录-人文关怀 |
|
@ -27,36 +36,47 @@ import java.util.Map; |
|
|
@Service |
|
|
@Service |
|
|
public class MemoConcernServiceImpl extends BaseServiceImpl<MemoConcernDao, MemoConcernEntity> implements MemoConcernService { |
|
|
public class MemoConcernServiceImpl extends BaseServiceImpl<MemoConcernDao, MemoConcernEntity> implements MemoConcernService { |
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
private MemoAttrService memoAttrService; |
|
|
|
|
|
@Resource |
|
|
|
|
|
private MemoAttachmentService memoAttachmentService; |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public PageData<MemoConcernDTO> page(Map<String, Object> params) { |
|
|
public PageData<MemoConcernDTO> page(MemoConcernFormDTO formDTO) { |
|
|
IPage<MemoConcernEntity> page = baseDao.selectPage( |
|
|
PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize()); |
|
|
getPage(params, FieldConstant.CREATED_TIME, false), |
|
|
List<MemoConcernDTO> list = baseDao.getPage(formDTO); |
|
|
getWrapper(params) |
|
|
PageInfo<MemoConcernDTO> pageInfo = new PageInfo<>(list); |
|
|
); |
|
|
return new PageData<>(list, pageInfo.getTotal()); |
|
|
return getPageData(page, MemoConcernDTO.class); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public List<MemoConcernDTO> list(Map<String, Object> params) { |
|
|
public List<MemoConcernDTO> list(MemoConcernFormDTO formDTO) { |
|
|
List<MemoConcernEntity> entityList = baseDao.selectList(getWrapper(params)); |
|
|
List<MemoConcernDTO> list = baseDao.getPage(formDTO); |
|
|
|
|
|
return list; |
|
|
return ConvertUtils.sourceToTarget(entityList, MemoConcernDTO.class); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private QueryWrapper<MemoConcernEntity> getWrapper(Map<String, Object> params){ |
|
|
|
|
|
String id = (String)params.get(FieldConstant.ID_HUMP); |
|
|
|
|
|
|
|
|
|
|
|
QueryWrapper<MemoConcernEntity> wrapper = new QueryWrapper<>(); |
|
|
|
|
|
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); |
|
|
|
|
|
|
|
|
|
|
|
return wrapper; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public MemoConcernDTO get(String id) { |
|
|
public MemoConcernDTO get(MemoConcernFormDTO formDTO) { |
|
|
MemoConcernEntity entity = baseDao.selectById(id); |
|
|
MemoConcernEntity entity = baseDao.selectById(formDTO.getId()); |
|
|
return ConvertUtils.sourceToTarget(entity, MemoConcernDTO.class); |
|
|
MemoConcernDTO dto = ConvertUtils.sourceToTarget(entity, MemoConcernDTO.class); |
|
|
|
|
|
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(); |
|
|
|
|
|
memoAttrDTO.setId(formDTO.getId()); |
|
|
|
|
|
memoAttrDTO.setReadFlag(NumConstant.ONE); |
|
|
|
|
|
memoAttrService.update(memoAttrDTO); |
|
|
|
|
|
} |
|
|
|
|
|
return dto; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
@ -64,6 +84,28 @@ public class MemoConcernServiceImpl extends BaseServiceImpl<MemoConcernDao, Memo |
|
|
public void save(MemoConcernDTO dto) { |
|
|
public void save(MemoConcernDTO dto) { |
|
|
MemoConcernEntity entity = ConvertUtils.sourceToTarget(dto, MemoConcernEntity.class); |
|
|
MemoConcernEntity entity = ConvertUtils.sourceToTarget(dto, MemoConcernEntity.class); |
|
|
insert(entity); |
|
|
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 |
|
|
@Override |
|
@ -71,6 +113,30 @@ public class MemoConcernServiceImpl extends BaseServiceImpl<MemoConcernDao, Memo |
|
|
public void update(MemoConcernDTO dto) { |
|
|
public void update(MemoConcernDTO dto) { |
|
|
MemoConcernEntity entity = ConvertUtils.sourceToTarget(dto, MemoConcernEntity.class); |
|
|
MemoConcernEntity entity = ConvertUtils.sourceToTarget(dto, MemoConcernEntity.class); |
|
|
updateById(entity); |
|
|
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 |
|
|
@Override |
|
@ -78,6 +144,13 @@ public class MemoConcernServiceImpl extends BaseServiceImpl<MemoConcernDao, Memo |
|
|
public void delete(String[] ids) { |
|
|
public void delete(String[] ids) { |
|
|
// 逻辑删除(@TableLogic 注解)
|
|
|
// 逻辑删除(@TableLogic 注解)
|
|
|
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|
|
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|
|
|
|
|
List<String> list = Arrays.asList(ids); |
|
|
|
|
|
baseDao.deleteBatchIds(list); |
|
|
|
|
|
memoAttrService.delete(ids); |
|
|
|
|
|
list.forEach(id -> { |
|
|
|
|
|
//删除附件
|
|
|
|
|
|
memoAttachmentService.deleteByMemoId(id); |
|
|
|
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |