|
@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.management.platform.entity.*;
|
|
|
import com.management.platform.mapper.*;
|
|
|
+import com.management.platform.service.ExcelExportService;
|
|
|
import com.management.platform.service.FinanceProjectsService;
|
|
|
import com.management.platform.service.ProjectPercentageService;
|
|
|
import com.management.platform.service.WxCorpInfoService;
|
|
@@ -14,15 +15,19 @@ import com.management.platform.util.HttpRespMsg;
|
|
|
import com.management.platform.util.MessageUtils;
|
|
|
import com.taobao.api.internal.util.StringUtils;
|
|
|
import org.apache.poi.EncryptedDocumentException;
|
|
|
+import org.apache.poi.hssf.usermodel.*;
|
|
|
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
|
|
import org.apache.poi.ss.usermodel.*;
|
|
|
+import org.apache.poi.ss.util.CellRangeAddressList;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFCell;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import java.io.*;
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -53,7 +58,11 @@ public class ProjectPercentageServiceImpl extends ServiceImpl<ProjectPercentageM
|
|
|
@Resource
|
|
|
private WxCorpInfoMapper wxCorpInfoMapper;
|
|
|
@Resource
|
|
|
+ private ExcelExportService excelExportService;
|
|
|
+ @Resource
|
|
|
private ProjectPercentageService projectPercentageService;
|
|
|
+ @Value(value = "${upload.path}")
|
|
|
+ private String path;
|
|
|
@Override
|
|
|
public HttpRespMsg saveMonthSetting(String projectCols, String userSettings, String ymonth) {
|
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
@@ -273,7 +282,7 @@ public class ProjectPercentageServiceImpl extends ServiceImpl<ProjectPercentageM
|
|
|
}
|
|
|
//人员存在
|
|
|
User user = userOp.get();
|
|
|
- Integer s = 0;
|
|
|
+ BigDecimal s = new BigDecimal(0);
|
|
|
JSONObject jsonObject=new JSONObject();
|
|
|
jsonObject.put("name",user.getName());
|
|
|
jsonObject.put("id",user.getId());
|
|
@@ -286,7 +295,7 @@ public class ProjectPercentageServiceImpl extends ServiceImpl<ProjectPercentageM
|
|
|
if (StringUtils.isEmpty(stringCellValue)) {
|
|
|
stringCellValue = "0";
|
|
|
}
|
|
|
- s+=Integer.parseInt(stringCellValue);
|
|
|
+ s=s.add(BigDecimal.valueOf(Double.parseDouble(stringCellValue)));
|
|
|
String pid = projectList.get(i-1);
|
|
|
jsonObject.put(pid,stringCellValue);
|
|
|
if (!filterFPList.stream().anyMatch(f->f.getProjectId().equals(pid))) {
|
|
@@ -310,7 +319,7 @@ public class ProjectPercentageServiceImpl extends ServiceImpl<ProjectPercentageM
|
|
|
}else{
|
|
|
dataString+=dataStringOne+"]";
|
|
|
}
|
|
|
- if(s!=100){
|
|
|
+ if(s.doubleValue()!=100){
|
|
|
//msg.setError("人员["+username+"]"+"分摊比例不满足100%,当前比例["+s+"%],请检查");
|
|
|
msg.setError(MessageUtils.message("staff.proportionError",username,s));
|
|
|
return msg;
|
|
@@ -378,4 +387,32 @@ public class ProjectPercentageServiceImpl extends ServiceImpl<ProjectPercentageM
|
|
|
System.out.println(file.delete());
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public HttpRespMsg getTemplate(String ymonth) {
|
|
|
+ HttpRespMsg httpRespMsg=new HttpRespMsg();
|
|
|
+ HttpRespMsg monthSetting = getMonthSetting(ymonth);
|
|
|
+ Map<String,Object> data= (Map<String, Object>) monthSetting.data;
|
|
|
+ List<FinanceProjects> financeProjects = (List<FinanceProjects>) data.get("financeProjects");
|
|
|
+ List<List<String>> dataList=new ArrayList<>();
|
|
|
+ List<Map<String, Object>> userCostSetting = (List<Map<String, Object>>) data.get("userCostSetting");
|
|
|
+ List<String> titleList=new ArrayList<>();
|
|
|
+ titleList.add("姓名");
|
|
|
+ for (FinanceProjects financeProject : financeProjects) {
|
|
|
+ titleList.add(String.valueOf(financeProject.getProjectName()));
|
|
|
+ }
|
|
|
+ dataList.add(titleList);
|
|
|
+ for (Map<String, Object> map : userCostSetting) {
|
|
|
+ List<String> itemList=new ArrayList<>();
|
|
|
+ itemList.add(String.valueOf(map.get("name")));
|
|
|
+ for (FinanceProjects financeProject : financeProjects) {
|
|
|
+ itemList.add(String.valueOf(map.get(String.valueOf(financeProject.getProjectId()))));
|
|
|
+ }
|
|
|
+ dataList.add(itemList);
|
|
|
+ }
|
|
|
+ String fileName = "人员分摊比例导入模板"+"_"+System.currentTimeMillis();
|
|
|
+ ExcelUtil.exportGeneralExcelByTitleAndList(fileName, dataList, path);
|
|
|
+ httpRespMsg.data = "/upload/" + fileName+".xls";
|
|
|
+ return httpRespMsg;
|
|
|
+ }
|
|
|
}
|