Commit f3466a3a by jianshuqin

优化导入计划单

parent d84cd37f
...@@ -5,6 +5,8 @@ import com.bailuntec.common.SpringContextUtil; ...@@ -5,6 +5,8 @@ import com.bailuntec.common.SpringContextUtil;
import com.bailuntec.common.exception.BizException; import com.bailuntec.common.exception.BizException;
import com.blt.other.common.exception.BizRuntimeException; import com.blt.other.common.exception.BizRuntimeException;
import com.blt.other.database.model.CostCompanyDomain; import com.blt.other.database.model.CostCompanyDomain;
import com.blt.other.database.model.UserDomain;
import com.blt.other.module.auth.dao.UserDao;
import com.blt.other.module.cost.dao.CostDao; import com.blt.other.module.cost.dao.CostDao;
import com.blt.other.module.cost.dao.CostPlanDao; import com.blt.other.module.cost.dao.CostPlanDao;
import com.blt.other.module.cost.dao.CostTypeDao; import com.blt.other.module.cost.dao.CostTypeDao;
...@@ -34,6 +36,8 @@ import javax.annotation.Resource; ...@@ -34,6 +36,8 @@ import javax.annotation.Resource;
import java.io.*; import java.io.*;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import static com.blt.other.common.wrapper.ThrowingConsumer.handlingConsumerWrapper; import static com.blt.other.common.wrapper.ThrowingConsumer.handlingConsumerWrapper;
...@@ -108,6 +112,10 @@ public class CostPlanServiceFactory { ...@@ -108,6 +112,10 @@ public class CostPlanServiceFactory {
return SpringContextUtil.getBean(DefaultCostPlanServiceImpl.class); return SpringContextUtil.getBean(DefaultCostPlanServiceImpl.class);
} }
private static UserDao getUserDao() {
return SpringContextUtil.getBean(UserDao.class);
}
/** /**
* 根据上传的文件构建 * 根据上传的文件构建
* *
...@@ -174,6 +182,7 @@ public class CostPlanServiceFactory { ...@@ -174,6 +182,7 @@ public class CostPlanServiceFactory {
Map<Integer, Map<CostPlanDomain, List<AddItemReq>>> costPlanAndItemMap = new HashMap<>(); Map<Integer, Map<CostPlanDomain, List<AddItemReq>>> costPlanAndItemMap = new HashMap<>();
//公司主体映射 //公司主体映射
Map<String, CostCompanyDomain> costCompanyDomainMap = getCostCompanyService().costCompanyMap(); Map<String, CostCompanyDomain> costCompanyDomainMap = getCostCompanyService().costCompanyMap();
UserDao userDao = getUserDao();
for (int i = 1; i < sheet.getLastRowNum(); i++) { for (int i = 1; i < sheet.getLastRowNum(); i++) {
Row row = sheet.getRow(i); Row row = sheet.getRow(i);
...@@ -187,7 +196,13 @@ public class CostPlanServiceFactory { ...@@ -187,7 +196,13 @@ public class CostPlanServiceFactory {
if (costPlanField.equals("costRemark") && sheetName.equals("付款") && (row.getCell(j) == null || row.getCell(j).toString().trim().equals(""))) { if (costPlanField.equals("costRemark") && sheetName.equals("付款") && (row.getCell(j) == null || row.getCell(j).toString().trim().equals(""))) {
throw new BizException("付款单备注为必填项"); throw new BizException("付款单备注为必填项");
} }
jsonObject.put(costPlanField, row.getCell(j) == null ? null : row.getCell(j).toString()); String value = row.getCell(j) == null ? null : row.getCell(j).toString();
if (costPlanField.equals("projectDate")) {
DateFormat fmt = new SimpleDateFormat("yyyy-MM");
jsonObject.put(costPlanField, fmt.parse(value));
} else {
jsonObject.put(costPlanField, value);
}
} }
} }
CostPlanDomain costPlanDomain = jsonObject.toJavaObject(CostPlanDomain.class); CostPlanDomain costPlanDomain = jsonObject.toJavaObject(CostPlanDomain.class);
...@@ -214,6 +229,14 @@ public class CostPlanServiceFactory { ...@@ -214,6 +229,14 @@ public class CostPlanServiceFactory {
//设置用户编号 //设置用户编号
costPlanDomain.setCreateUsercode(userCode); costPlanDomain.setCreateUsercode(userCode);
UserDomain user = null;
if (costPlanDomain.getCreateUserid() == null) {
user = userDao.select(userCode);
if (user != null) {
costPlanDomain.setCreateUserid(user.getUserid());
costPlanDomain.setCreateUsername(user.getUsername());
}
}
//设置付款/收款主体 //设置付款/收款主体
CostCompanyDomain costCompanyDomain = costCompanyDomainMap.get(costPlanDomain.getCompanyName()); CostCompanyDomain costCompanyDomain = costCompanyDomainMap.get(costPlanDomain.getCompanyName());
......
...@@ -82,6 +82,22 @@ public enum CostPlanEnumVo { ...@@ -82,6 +82,22 @@ public enum CostPlanEnumVo {
put("收款", "项目"); put("收款", "项目");
} }
}), }),
project(new HashMap<String, String>() {
{
put("付款", "所属项目");
put("收款", "所属项目");
put("借支", "所属项目");
put("借还", "所属项目");
}
}),
projectDate(new HashMap<String, String>() {
{
put("付款", "所属账期");
put("收款", "所属账期");
put("借支", "所属账期");
put("借还", "所属账期");
}
}),
payCounteract(new HashMap<String, String>() { payCounteract(new HashMap<String, String>() {
{ {
put("借还", "冲销金额"); put("借还", "冲销金额");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment