|
@@ -21,10 +21,7 @@ import com.gree.mall.manager.enums.workorder.SettleExpenseStatusEnum;
|
|
|
import com.gree.mall.manager.exception.RemoteServiceException;
|
|
|
import com.gree.mall.manager.logic.common.CommonLogic;
|
|
|
import com.gree.mall.manager.plus.entity.*;
|
|
|
-import com.gree.mall.manager.plus.service.SettleExpenseItemService;
|
|
|
-import com.gree.mall.manager.plus.service.SettleExpenseService;
|
|
|
-import com.gree.mall.manager.plus.service.SettleMonthWagesWorkerService;
|
|
|
-import com.gree.mall.manager.plus.service.UserService;
|
|
|
+import com.gree.mall.manager.plus.service.*;
|
|
|
import com.gree.mall.manager.zfire.bean.QueryParamBean;
|
|
|
import com.gree.mall.manager.zfire.bean.ZfireParamBean;
|
|
|
import com.gree.mall.manager.zfire.util.FieldUtils;
|
|
@@ -54,6 +51,7 @@ public class WorkerSettleExpenseLogic {
|
|
|
private final UserService userService;
|
|
|
private final SettleMonthWagesWorkerService settleMonthWagesWorkerService;
|
|
|
private final CountMapper countMapper;
|
|
|
+ private final AdminWebsitService adminWebsitService;
|
|
|
|
|
|
public IPage<SettleExpenseVO> gatherList(ZfireParamBean zfireParamBean) {
|
|
|
AdminUserCom adminUser = commonLogic.getAdminUser();
|
|
@@ -85,10 +83,11 @@ public class WorkerSettleExpenseLogic {
|
|
|
|
|
|
}
|
|
|
|
|
|
- public void importData(AdminUserCom adminUser, InputStream inputStream, HttpServletRequest request,String createWebsitId, String createWebsitName) throws Exception {
|
|
|
+ public void importData(AdminUserCom adminUser, InputStream inputStream, HttpServletRequest request) throws Exception {
|
|
|
|
|
|
//读取excel数据
|
|
|
ExcelReader reader = ExcelUtil.getReader(inputStream);
|
|
|
+ reader.addHeaderAlias("网点编号", "websitId");
|
|
|
reader.addHeaderAlias("网点名称", "importWebsitName");
|
|
|
reader.addHeaderAlias("发放月份", "sendMonth");
|
|
|
reader.addHeaderAlias("费用类型", "typeName");
|
|
@@ -131,14 +130,25 @@ public class WorkerSettleExpenseLogic {
|
|
|
|
|
|
Map<String, User> userMap = this.getUserMap(companyWechatId);
|
|
|
|
|
|
+ List<AdminWebsit> websitList = adminWebsitService.lambdaQuery()
|
|
|
+ .in(AdminWebsit::getWebsitId, adminUser.getAdminWebsitIds())
|
|
|
+ .list();
|
|
|
+
|
|
|
+ final Map<String, AdminWebsit> websitMap = websitList.stream()
|
|
|
+ .collect(Collectors.toMap(AdminWebsit::getWebsitId, Function.identity()));
|
|
|
+
|
|
|
Set<String> byCount = new HashSet<>();
|
|
|
BigDecimal settleAmount = BigDecimal.ZERO;
|
|
|
for (int i = 0; i < itemList.size(); i++) {
|
|
|
final ImportSettleExpenseItem item = itemList.get(i);
|
|
|
+ if (websitMap.containsKey(item.getWebsitId())) {
|
|
|
+ throw new RemoteServiceException("账号没有导入 " + item.getWebsitId() + " 网点权限");
|
|
|
+ }
|
|
|
+ final AdminWebsit websit = websitMap.get(item.getWebsitId());
|
|
|
+
|
|
|
item.setCompanyWechatId(companyWechatId)
|
|
|
.setCompanyWechatName(companyWechatName)
|
|
|
- .setWebsitId(createWebsitId)
|
|
|
- .setWebsitName(createWebsitName)
|
|
|
+ .setWebsitName(websit.getName())
|
|
|
.setTypeName(StrUtil.trim(item.getTypeName()))
|
|
|
.setCategory(StrUtil.trim(item.getCategory()));
|
|
|
|
|
@@ -154,98 +164,103 @@ public class WorkerSettleExpenseLogic {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // 检查当前导入内容安装是否有重复品类相同内机条码
|
|
|
- final Map<String, List<ImportSettleExpenseItem>> groupInsideCodeMap = itemList.stream()
|
|
|
- .filter(v -> v.getCategoryType().equals(SettleCategoryTypEnum.INSTALL_HOME.getKey())
|
|
|
- || v.getCategoryType().equals(SettleCategoryTypEnum.INSTALL_OTHER.getKey()))
|
|
|
- .collect(Collectors.groupingBy(v -> v.getCategory() + "|" + v.getInsideCode()));
|
|
|
+ final Map<String, List<ImportSettleExpenseItem>> itemGroupMap = itemList.stream().collect(Collectors.groupingBy(ImportSettleExpenseItem::getWebsitId));
|
|
|
|
|
|
- for (Map.Entry<String, List<ImportSettleExpenseItem>> entry : groupInsideCodeMap.entrySet()) {
|
|
|
- if (entry.getValue().size() > 1) {
|
|
|
- throw new RemoteServiceException("导入数据发现重复内机条码:" + entry.getKey());
|
|
|
+ for (Map.Entry<String, List<ImportSettleExpenseItem>> itemEntry : itemGroupMap.entrySet()) {
|
|
|
+ List<ImportSettleExpenseItem> itemGroupList = itemEntry.getValue();
|
|
|
+ // 检查当前导入内容安装是否有重复品类相同内机条码
|
|
|
+ final Map<String, List<ImportSettleExpenseItem>> groupInsideCodeMap = itemGroupList.stream()
|
|
|
+ .filter(v -> v.getCategoryType().equals(SettleCategoryTypEnum.INSTALL_HOME.getKey())
|
|
|
+ || v.getCategoryType().equals(SettleCategoryTypEnum.INSTALL_OTHER.getKey()))
|
|
|
+ .collect(Collectors.groupingBy(v -> v.getCategory() + "|" + v.getInsideCode()));
|
|
|
+
|
|
|
+ for (Map.Entry<String, List<ImportSettleExpenseItem>> entry : groupInsideCodeMap.entrySet()) {
|
|
|
+ if (entry.getValue().size() > 1) {
|
|
|
+ throw new RemoteServiceException("导入数据发现重复内机条码:" + entry.getKey());
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- // 检查导入历史是否重复品类相同内机条码
|
|
|
- final List<String> insideCodeList = itemList.stream()
|
|
|
- .filter(v -> v.getCategoryType().equals(SettleCategoryTypEnum.INSTALL_HOME.getKey())
|
|
|
- || v.getCategoryType().equals(SettleCategoryTypEnum.INSTALL_OTHER.getKey()))
|
|
|
- .map(v -> v.getTypeName() + "|" + v.getCategory() + "|" + v.getRepairCustomCode())
|
|
|
- .collect(Collectors.toList());
|
|
|
+ // 检查导入历史是否重复品类相同内机条码
|
|
|
+ final List<String> insideCodeList = itemGroupList.stream()
|
|
|
+ .filter(v -> v.getCategoryType().equals(SettleCategoryTypEnum.INSTALL_HOME.getKey())
|
|
|
+ || v.getCategoryType().equals(SettleCategoryTypEnum.INSTALL_OTHER.getKey()))
|
|
|
+ .map(v -> v.getTypeName() + "|" + v.getCategory() + "|" + v.getRepairCustomCode())
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
|
- if (CollectionUtil.isNotEmpty(insideCodeList)) {
|
|
|
- final List<SettleExpenseItem> installExpenseItems = settleExpenseItemService.lambdaQuery()
|
|
|
- .eq(SettleExpenseItem::getCompanyWechatId, companyWechatId)
|
|
|
- .in(SettleExpenseItem::getCategoryType, SettleCategoryTypEnum.INSTALL_HOME.getKey(), SettleCategoryTypEnum.INSTALL_OTHER.getKey())
|
|
|
- .in(SettleExpenseItem::getUniqueJoinCode, insideCodeList)
|
|
|
- .list();
|
|
|
+ if (CollectionUtil.isNotEmpty(insideCodeList)) {
|
|
|
+ final List<SettleExpenseItem> installExpenseItems = settleExpenseItemService.lambdaQuery()
|
|
|
+ .eq(SettleExpenseItem::getCompanyWechatId, companyWechatId)
|
|
|
+ .in(SettleExpenseItem::getCategoryType, SettleCategoryTypEnum.INSTALL_HOME.getKey(), SettleCategoryTypEnum.INSTALL_OTHER.getKey())
|
|
|
+ .in(SettleExpenseItem::getUniqueJoinCode, insideCodeList)
|
|
|
+ .list();
|
|
|
|
|
|
- if (CollectionUtil.isNotEmpty(installExpenseItems)) {
|
|
|
- for (SettleExpenseItem expenseItem : installExpenseItems) {
|
|
|
- throw new RemoteServiceException("历史导入记录与本次导入数据有重复: " + expenseItem.getUniqueJoinCode());
|
|
|
+ if (CollectionUtil.isNotEmpty(installExpenseItems)) {
|
|
|
+ for (SettleExpenseItem expenseItem : installExpenseItems) {
|
|
|
+ throw new RemoteServiceException("历史导入记录与本次导入数据有重复: " + expenseItem.getUniqueJoinCode());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- // 检查当前导入内容维修是否有重复品类相同维修自编号
|
|
|
- final Map<String, List<ImportSettleExpenseItem>> groupRepairMap = itemList.stream()
|
|
|
- .filter(v -> v.getCategoryType().equals(SettleCategoryTypEnum.REPAIR.getKey()))
|
|
|
- .collect(Collectors.groupingBy(v -> v.getCategory() + "|" + v.getRepairCustomCode()));
|
|
|
+ // 检查当前导入内容维修是否有重复品类相同维修自编号
|
|
|
+ final Map<String, List<ImportSettleExpenseItem>> groupRepairMap = itemGroupList.stream()
|
|
|
+ .filter(v -> v.getCategoryType().equals(SettleCategoryTypEnum.REPAIR.getKey()))
|
|
|
+ .collect(Collectors.groupingBy(v -> v.getCategory() + "|" + v.getRepairCustomCode()));
|
|
|
|
|
|
- for (Map.Entry<String, List<ImportSettleExpenseItem>> entry : groupRepairMap.entrySet()) {
|
|
|
- if (entry.getValue().size() > 1) {
|
|
|
- throw new RemoteServiceException("导入数据发现重复维修自编号:" + entry.getKey());
|
|
|
+ for (Map.Entry<String, List<ImportSettleExpenseItem>> entry : groupRepairMap.entrySet()) {
|
|
|
+ if (entry.getValue().size() > 1) {
|
|
|
+ throw new RemoteServiceException("导入数据发现重复维修自编号:" + entry.getKey());
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- // 检查导入历史是否重复品类相同维修自编号
|
|
|
- final List<String> repairCustomCodeList = itemList.stream()
|
|
|
- .filter(v -> v.getCategoryType().equals(SettleCategoryTypEnum.REPAIR.getKey()))
|
|
|
- .map(v -> v.getTypeName() + "|" + v.getCategory() + "|" + v.getRepairCustomCode())
|
|
|
- .collect(Collectors.toList());
|
|
|
+ // 检查导入历史是否重复品类相同维修自编号
|
|
|
+ final List<String> repairCustomCodeList = itemGroupList.stream()
|
|
|
+ .filter(v -> v.getCategoryType().equals(SettleCategoryTypEnum.REPAIR.getKey()))
|
|
|
+ .map(v -> v.getTypeName() + "|" + v.getCategory() + "|" + v.getRepairCustomCode())
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
|
- if (CollectionUtil.isNotEmpty(repairCustomCodeList)) {
|
|
|
- final List<SettleExpenseItem> repairExpenseItems = settleExpenseItemService.lambdaQuery()
|
|
|
- .eq(SettleExpenseItem::getCompanyWechatId, companyWechatId)
|
|
|
- .eq(SettleExpenseItem::getCategoryType, SettleCategoryTypEnum.REPAIR.getKey())
|
|
|
- .in(SettleExpenseItem::getUniqueJoinCode, repairCustomCodeList)
|
|
|
- .list();
|
|
|
+ if (CollectionUtil.isNotEmpty(repairCustomCodeList)) {
|
|
|
+ final List<SettleExpenseItem> repairExpenseItems = settleExpenseItemService.lambdaQuery()
|
|
|
+ .eq(SettleExpenseItem::getCompanyWechatId, companyWechatId)
|
|
|
+ .eq(SettleExpenseItem::getCategoryType, SettleCategoryTypEnum.REPAIR.getKey())
|
|
|
+ .in(SettleExpenseItem::getUniqueJoinCode, repairCustomCodeList)
|
|
|
+ .list();
|
|
|
|
|
|
- if (CollectionUtil.isNotEmpty(repairExpenseItems)) {
|
|
|
- for (SettleExpenseItem expenseItem : repairExpenseItems) {
|
|
|
- throw new RemoteServiceException("历史导入记录与本次导入数据有重复: " + expenseItem.getUniqueJoinCode());
|
|
|
+ if (CollectionUtil.isNotEmpty(repairExpenseItems)) {
|
|
|
+ for (SettleExpenseItem expenseItem : repairExpenseItems) {
|
|
|
+ throw new RemoteServiceException("历史导入记录与本次导入数据有重复: " + expenseItem.getUniqueJoinCode());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
|
|
|
- SettleExpense expense = new SettleExpense();
|
|
|
- expense.setCompanyWechatId(companyWechatId);
|
|
|
- expense.setCompanyWechatName(companyWechatName);
|
|
|
- expense.setWebsitId(createWebsitId);
|
|
|
- expense.setWebsitName(createWebsitName);
|
|
|
- expense.setImportBatchNo(IdWorker.getIdStr());
|
|
|
- expense.setSettleByCount(byCount.size());
|
|
|
- expense.setSettleOrderCount(itemList.size());
|
|
|
- expense.setSettleAmount(settleAmount);
|
|
|
- expense.setStatus(SettleExpenseStatusEnum.NO.getKey());
|
|
|
- expense.insert();
|
|
|
-
|
|
|
- List<SettleExpenseItem> items = itemList.stream().map(v -> {
|
|
|
- SettleExpenseItem item = new SettleExpenseItem();
|
|
|
- BeanUtils.copyProperties(v, item);
|
|
|
- item.setSettleExpenseId(expense.getId());
|
|
|
- if (!item.getCategoryType().equals(SettleCategoryTypEnum.OTHER.getKey())) {
|
|
|
- if (item.getCategoryType().equals(SettleCategoryTypEnum.REPAIR.getKey())) {
|
|
|
- item.setUniqueJoinCode(item.getTypeName() + "|" + item.getCategory() + "|" + item.getRepairCustomCode());
|
|
|
- } else {
|
|
|
- item.setUniqueJoinCode(item.getTypeName() + "|" + item.getCategory() + "|" + item.getInsideCode());
|
|
|
+ SettleExpense expense = new SettleExpense();
|
|
|
+ expense.setCompanyWechatId(companyWechatId);
|
|
|
+ expense.setCompanyWechatName(companyWechatName);
|
|
|
+ expense.setWebsitId(itemGroupList.get(0).getWebsitId());
|
|
|
+ expense.setWebsitName(itemGroupList.get(0).getWebsitName());
|
|
|
+ expense.setImportBatchNo(IdWorker.getIdStr());
|
|
|
+ expense.setSettleByCount(byCount.size());
|
|
|
+ expense.setSettleOrderCount(itemGroupList.size());
|
|
|
+ expense.setSettleAmount(settleAmount);
|
|
|
+ expense.setStatus(SettleExpenseStatusEnum.NO.getKey());
|
|
|
+ expense.insert();
|
|
|
+
|
|
|
+ List<SettleExpenseItem> items = itemGroupList.stream().map(v -> {
|
|
|
+ SettleExpenseItem item = new SettleExpenseItem();
|
|
|
+ BeanUtils.copyProperties(v, item);
|
|
|
+ item.setSettleExpenseId(expense.getId());
|
|
|
+ if (!item.getCategoryType().equals(SettleCategoryTypEnum.OTHER.getKey())) {
|
|
|
+ if (item.getCategoryType().equals(SettleCategoryTypEnum.REPAIR.getKey())) {
|
|
|
+ item.setUniqueJoinCode(item.getTypeName() + "|" + item.getCategory() + "|" + item.getRepairCustomCode());
|
|
|
+ } else {
|
|
|
+ item.setUniqueJoinCode(item.getTypeName() + "|" + item.getCategory() + "|" + item.getInsideCode());
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- return item;
|
|
|
- }).collect(Collectors.toList());
|
|
|
+ return item;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
|
|
- settleExpenseItemService.saveBatch(items);
|
|
|
+ settleExpenseItemService.saveBatch(items);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private void checkRequireParams(Integer row, SettleExpenseItem item, Map<String, User> userMap, String itemId) {
|