package com.example.demo.service.impl;
import com.example.demo.entity.*;
import com.example.demo.mapper.*;
import com.example.demo.service.Budget;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.sql.Date;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
/**
* Created with IntelliJ IDEA.
*
* @Author: tlj
* @Date: 2023/04/23/16:14
* @Description:
*/
@Service
public class BudgetImpl implements Budget {
@Autowired
SysMemberInformationMapper membersMapper;
@Autowired
AchievementMapper achievementMapper;
@Autowired
ProjectConclusionMapper conclusionMapper;
@Autowired
ThesisMapper thesisMapper;
@Autowired
AuthorshipMapper authorshipMapper;
@Autowired
PatentMapper patentMapper;
@Autowired
SoftwareMapper softwareMapper;
@Autowired
BudgetMapper budgetMapper;
@Override
public List<ResearchFunding> researchFunding(String name, Long work) {
//科研项目结题的数据,找到用户所参与的科研项目
List<SysMemberInformation> memberApplication = membersMapper.getMemberApplication(name, work);
//与项目结题数据进行比对
List<ResearchFunding> researchFundings=new ArrayList<>();
for(int i=0;i<memberApplication.size();i++){
String itemNumber = memberApplication.get(i).getItemNumber();
SysProjectConclusion close = conclusionMapper.getClose(itemNumber);
if(close!=null){
String projectName = close.getProjectName();
String projectLeader = close.getProjectLeader();
String academy = close.getAcademy();
String closeItemNumber = close.getItemNumber();
ResearchFunding funding=new ResearchFunding();
funding.setName(projectName);
funding.setLeader(projectLeader);
funding.setAcademy(academy);
funding.setItemNumber(closeItemNumber);
funding.setType("科研项目");
//判断项目是否申请
AchieveBudget budget = budgetMapper.havaItemNumber(closeItemNumber);
if(budget!=null){
String budgetArabic = budget.getBudgetArabic();
Integer academyAudit = budget.getAcademyAudit();
Integer budgetAudit = budget.getBudgetAudit();
String rejectReason = budget.getRejectReason();
String commentsBudget = budget.getCommentsBudget();
String newFunds = budget.getNewFunds();
funding.setBudgetArabic(budgetArabic);
funding.setAcademyAudit(academyAudit);
funding.setBudgetAudit(budgetAudit);
funding.setAuditReason(rejectReason);
funding.setCommentsBudget(commentsBudget);
funding.setNewFunds(newFunds);
researchFundings.add(funding);
}else {
funding.setBudgetArabic(null);
funding.setAcademyAudit(null);
funding.setBudgetAudit(null);
funding.setAuditReason(null);
funding.setCommentsBudget(null);
researchFundings.add(funding);
}
}
}
//论文成果类
List<SysAchievementMember> thesis = achievementMapper.getThesis(name, work);
for(int i=0;i<thesis.size();i++){
//取审核通过的
String itemNumber = thesis.get(i).getItemNumber();
SysThesisAchieve thesisBudgetFunding = thesisMapper.getThesisBudgetFunding(itemNumber);
if(thesisBudgetFunding!=null){
//存在已审核通过的论文成果
String thesisName = thesisBudgetFunding.getThesisName();
String firstAuthor = thesisBudgetFunding.getFirstAuthor();
String academy = thesisBudgetFunding.getAcademy();
String thesisItemNumber = thesisBudgetFunding.getItemNumber();
ResearchFunding funding=new ResearchFunding();
funding.setName(thesisName);
funding.setLeader(firstAuthor);
funding.setAcademy(academy);
funding.setItemNumber(thesisItemNumber);
funding.setType("论文成果");
//判断论文成果是否申请经费
AchieveBudget budget = budgetMapper.havaItemNumber(thesisItemNumber);
if(budget!=null){
String budgetArabic = budget.getBudgetArabic();
Integer academyAudit = budget.getAcademyAudit();
Integer budgetAudit = budget.getBudgetAudit();
String auditReason = budget.getRejectReason();
String commentsBudget = budget.getCommentsBudget();
funding.setBudgetArabic(budgetArabic);
funding.setAcademyAudit(academyAudit);
funding.setBudgetAudit(budgetAudit);
funding.setAuditReason(auditReason);
funding.setCommentsBudget(commentsBudget);
researchFundings.add(funding);
}else {
funding.setBudgetArabic(null);
funding.setAcademyAudit(null);
funding.setBudgetAudit(null);
funding.setAuditReason(null);
funding.setCommentsBudget(null);
researchFundings.add(funding);
}
}
}
//著作类
List<SysAchievementMember> authorship = achievementMapper.getAuthorship(name, work);
for(int i=0;i<authorship.size();i++){
String itemNumber = authorship.get(i).getItemNumber();
SysAuthorshipAchieve authorship1 = authorshipMapper.getAuthorship(itemNumber);
if(authorship1!=null){
String titleWork = authorship1.getTitleWork();
String firstAuthor = authorship1.getFirstAuthor();
String academy = authorship1.getAcademy();
String authorshipItemNumber = authorship1.getItemNumber();
ResearchFunding funding=new ResearchFunding();
funding.setName(titleWork);
funding.setLeader(firstAuthor);
funding.setAcademy(academy);
funding.setItemNumber(authorshipItemNumber);
funding.setType("著作成果");
AchieveBudget budget = budgetMapper.havaItemNumber(authorshipItemNumber);
if(budget!=null){
String budgetArabic = budget.getBudgetArabic();
Integer academyAudit = budget.getAcademyAudit();
Integer budgetAudit = budget.getBudgetAudit();
String auditReason = budget.getRejectReason();
String commentsBudget = budget.getCommentsBudget();
funding.setBudgetArabic(budgetArabic);
funding.setAcademyAudit(academyAudit);
funding.setBudgetAudit(budgetAudit);
funding.setAuditReason(auditReason);
funding.setCommentsBudget(commentsBudget);
researchFundings.add(funding);
}else {
funding.setBudgetArabic(null);
funding.setAcademyAudit(null);
funding.setBudgetAudit(null);
funding.setAuditReason(null);
funding.setCommentsBudget(null);
researchFundings.add