|
|
|
@ -6,6 +6,7 @@ import java.util.Collections; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
import net.lab1024.sa.admin.common.enums.ReviewEnum; |
|
|
|
import net.lab1024.sa.admin.module.cost.dao.FirmReportsDao; |
|
|
|
@ -27,6 +28,7 @@ import net.lab1024.sa.base.common.code.UnexpectedErrorCode; |
|
|
|
import net.lab1024.sa.base.common.code.UserErrorCode; |
|
|
|
import net.lab1024.sa.base.common.domain.ValidateList; |
|
|
|
import net.lab1024.sa.base.common.enumeration.UserTypeEnum; |
|
|
|
import net.lab1024.sa.base.common.exception.BusinessException; |
|
|
|
import net.lab1024.sa.base.common.util.SmartBeanUtil; |
|
|
|
import net.lab1024.sa.base.common.util.SmartPageUtil; |
|
|
|
import net.lab1024.sa.base.common.domain.ResponseDTO; |
|
|
|
@ -34,6 +36,7 @@ import net.lab1024.sa.base.common.domain.PageResult; |
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import net.lab1024.sa.base.module.support.dict.service.DictService; |
|
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
|
import org.springframework.dao.DuplicateKeyException; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
@ -287,13 +290,30 @@ public class FirmReportsService { |
|
|
|
/** |
|
|
|
* 批量创建缺失季度记录(空白报表) |
|
|
|
*/ |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public ResponseDTO<String> batchCreateMissing(Integer firmId, Integer year, List<Integer> quarters) { |
|
|
|
if (firmId == null || year == null || quarters == null || quarters.isEmpty()) { |
|
|
|
return ResponseDTO.userErrorParam("参数不能为空"); |
|
|
|
} |
|
|
|
|
|
|
|
List<Integer> distinctQuarters = quarters.stream().distinct().collect(Collectors.toList()); |
|
|
|
if (distinctQuarters.stream().anyMatch(quarter -> quarter == null || quarter < 1 || quarter > 4)) { |
|
|
|
return ResponseDTO.userErrorParam("季度必须为1至4"); |
|
|
|
} |
|
|
|
|
|
|
|
List<Integer> existingQuarters = distinctQuarters.stream() |
|
|
|
.filter(quarter -> firmReportsDao.selectList(String.valueOf(quarter), year, firmId) != null) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
if (!existingQuarters.isEmpty()) { |
|
|
|
String quarterNames = existingQuarters.stream() |
|
|
|
.map(quarter -> "第" + quarter + "季度") |
|
|
|
.collect(Collectors.joining("、")); |
|
|
|
return ResponseDTO.userErrorParam(year + "年" + quarterNames + "报表已存在,请刷新列表后重试"); |
|
|
|
} |
|
|
|
|
|
|
|
RequestEmployee requestUser = AdminRequestUtil.getRequestUser(); |
|
|
|
for (Integer quarter : quarters) { |
|
|
|
try { |
|
|
|
for (Integer quarter : distinctQuarters) { |
|
|
|
FirmReportsEntity entity = new FirmReportsEntity(); |
|
|
|
entity.setFirmId(firmId); |
|
|
|
entity.setDeclareYear(year); |
|
|
|
@ -309,6 +329,9 @@ public class FirmReportsService { |
|
|
|
entity.setActualCostIncomeRatio(BigDecimal.ZERO); |
|
|
|
firmReportsDao.insert(entity); |
|
|
|
} |
|
|
|
} catch (DuplicateKeyException exception) { |
|
|
|
throw new BusinessException("部分季度报表已被创建,请刷新列表后重试"); |
|
|
|
} |
|
|
|
return ResponseDTO.ok(); |
|
|
|
} |
|
|
|
|
|
|
|
|