|
|
@@ -1,24 +1,26 @@
|
|
|
package com.goafanti.expenseAccount.service.impl;
|
|
|
|
|
|
+import com.goafanti.admin.bo.AdminListBo;
|
|
|
+import com.goafanti.admin.bo.NoticeBo;
|
|
|
+import com.goafanti.common.bo.EmailBo;
|
|
|
import com.goafanti.common.constant.AFTConstants;
|
|
|
import com.goafanti.common.dao.*;
|
|
|
+import com.goafanti.common.enums.NoticeStatus;
|
|
|
+import com.goafanti.common.enums.NoticeTypes;
|
|
|
import com.goafanti.common.error.BusinessException;
|
|
|
-import com.goafanti.common.model.Admin;
|
|
|
-import com.goafanti.common.model.ExpenseAccount;
|
|
|
-import com.goafanti.common.model.ExpenseAccountLog;
|
|
|
-import com.goafanti.common.model.PublicRelease;
|
|
|
+import com.goafanti.common.model.*;
|
|
|
+import com.goafanti.common.utils.AsyncUtils;
|
|
|
import com.goafanti.common.utils.DateUtils;
|
|
|
import com.goafanti.core.mybatis.BaseMybatisDao;
|
|
|
import com.goafanti.core.mybatis.page.Pagination;
|
|
|
import com.goafanti.core.shiro.token.TokenManager;
|
|
|
+import com.goafanti.expenseAccount.Enums.EAProcessStatus;
|
|
|
import com.goafanti.expenseAccount.bo.*;
|
|
|
import com.goafanti.expenseAccount.service.ExpenseAccountService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
|
|
|
@Service
|
|
|
public class ExpenseAccountServiceImpl extends BaseMybatisDao<ExpenseAccountMapper> implements ExpenseAccountService {
|
|
|
@@ -31,6 +33,8 @@ public class ExpenseAccountServiceImpl extends BaseMybatisDao<ExpenseAccountMapp
|
|
|
@Autowired
|
|
|
private ExpenseAccountLogMapper expenseAccountLogMapper;
|
|
|
@Autowired
|
|
|
+ private AsyncUtils asyncUtils;
|
|
|
+ @Autowired
|
|
|
private ExpenseAccountDetailsMapper expenseAccountDetailsMapper;
|
|
|
|
|
|
|
|
|
@@ -122,10 +126,70 @@ public class ExpenseAccountServiceImpl extends BaseMybatisDao<ExpenseAccountMapp
|
|
|
@Override
|
|
|
public int updateExamine(InputExpenseAccount in) {
|
|
|
ExpenseAccount useEa = expenseAccountMapper.selectByPrimaryKey(in.getId());
|
|
|
+ ExpenseAccount newEa=new ExpenseAccount();
|
|
|
+ newEa.setId(useEa.getId());
|
|
|
if (useEa.getStatus()!=1)throw new BusinessException("审核状态错误");
|
|
|
if (useEa.getProcessStatus()!=in.getProcessStatus())throw new BusinessException("审核流程错误");
|
|
|
- //审核通知
|
|
|
- return 0;
|
|
|
+ //审核通知 获取发送人
|
|
|
+ List<Admin> aids=new ArrayList<>();
|
|
|
+ Integer status=1;
|
|
|
+ StringBuffer str=new StringBuffer();
|
|
|
+ str=str.append("您有报销需要审核,请查看并审核。");
|
|
|
+ AdminListBo admin = adminMapper.getDeptNameByAid(useEa.getAid());
|
|
|
+ if(useEa.getProcessStatus()== EAProcessStatus.FQ.getCode()){
|
|
|
+ //获取上级
|
|
|
+ aids.add(adminMapper.selectByPrimaryKey(admin.getSuperiorId()));
|
|
|
+ newEa.setProcessStatus(EAProcessStatus.SJSH.getCode());
|
|
|
+
|
|
|
+ }else if (useEa.getProcessStatus()== EAProcessStatus.SJSH.getCode()){
|
|
|
+ //获取负责人
|
|
|
+ List<Admin> list = adminMapper.listAdminBydepIdAndRoleType(admin.getId(), admin.getDepartmentId());
|
|
|
+ if (!list.isEmpty())aids.addAll(list);
|
|
|
+ newEa.setProcessStatus(EAProcessStatus.ZJLSH.getCode());
|
|
|
+ }else if (useEa.getProcessStatus()== EAProcessStatus.ZJLSH.getCode()){
|
|
|
+ //获取负责人
|
|
|
+ aids.add(adminMapper.selectByPrimaryKey(admin.getDepFinance()));
|
|
|
+ newEa.setProcessStatus(EAProcessStatus.CWSH.getCode());
|
|
|
+ }else if (useEa.getProcessStatus()== EAProcessStatus.CWSH.getCode()){
|
|
|
+ //获取负责人
|
|
|
+ List<Admin> admins = adminMapper.selectAdminByRoleType(AFTConstants.All_CED_AND_CHAIRMAN);
|
|
|
+ if (!admins.isEmpty())aids.addAll(admins);
|
|
|
+ newEa.setProcessStatus(EAProcessStatus.DSZSH.getCode());
|
|
|
+ }else if (useEa.getProcessStatus()== EAProcessStatus.DSZSH.getCode()){
|
|
|
+ //获取负责人
|
|
|
+ status=2;
|
|
|
+ aids.add(adminMapper.selectByPrimaryKey(admin.getId()));
|
|
|
+ newEa.setStatus(status);
|
|
|
+ str=new StringBuffer("您的报销审核已通过,请注意查看。");
|
|
|
+ }
|
|
|
+ addLogAndNoticeAndEmail(useEa,status,str.toString(),aids);
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void addLogAndNoticeAndEmail(ExpenseAccount useEa, Integer status, String str, List<Admin> aids) {
|
|
|
+ addExpenseAccountLog(useEa.getId(),status,str);
|
|
|
+ Date date= new Date();
|
|
|
+ Integer noticeStatus=NoticeStatus.EXPENSE_NOTICE.getCode();
|
|
|
+ if (status==2){
|
|
|
+ noticeStatus=NoticeStatus.EXPENSE_COMPLETE.getCode();
|
|
|
+ }
|
|
|
+ List<Notice> list=new ArrayList<>();
|
|
|
+ if (aids!=null){
|
|
|
+ for (Admin a : aids) {
|
|
|
+ Notice notice=new Notice();
|
|
|
+ notice.setId(UUID.randomUUID().toString());
|
|
|
+ notice.setNoticeType(noticeStatus);
|
|
|
+ notice.setType(NoticeTypes.getType(noticeStatus));
|
|
|
+ notice.setAid(a.getId());
|
|
|
+ notice.setCreateTime(new Date());
|
|
|
+ notice.setContent(str);
|
|
|
+ notice.setReaded(0);
|
|
|
+ list.add(notice);
|
|
|
+ EmailBo emailBo=new EmailBo(NoticeStatus.getValueByCode(noticeStatus),a.getEmail(),str);
|
|
|
+ asyncUtils.send(emailBo);
|
|
|
+ }
|
|
|
+ asyncUtils.addNoticeBatch(list);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|