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