|
@@ -127,27 +127,27 @@ public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMappe
|
|
|
/**
|
|
|
* 批量导入收入数据
|
|
|
*
|
|
|
- * @param list 输入的文件
|
|
|
+ * @param list 输入的文件
|
|
|
* @param user 用户
|
|
|
* @param file
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
|
|
- public Result importIncomeGroup(List<List<Object>> list, User user, MultipartFile file,String dateTime,Integer fileType) {
|
|
|
+ public Result importIncomeGroup(List<List<Object>> list, User user, MultipartFile file, String dateTime, Integer fileType) {
|
|
|
// 先检验当前年月是否存在数据
|
|
|
int year = 0;
|
|
|
int month = 0;
|
|
|
Date date = DateUtils.StringToDate(dateTime, DateStyleEnum.YYYY_MM_DD);
|
|
|
if (StrUtil.isNotBlank(dateTime)) {
|
|
|
year = DateUtil.year(date);
|
|
|
- month =DateUtil.month(date)+1;
|
|
|
+ month = DateUtil.month(date) + 1;
|
|
|
}
|
|
|
Long hospId = user.getHospId();
|
|
|
List<CostIncomeGroup> groups = this.list(new QueryWrapper<CostIncomeGroup>().lambda().eq(CostIncomeGroup::getHospId, hospId)
|
|
|
.eq(CostIncomeGroup::getDateYear, year).eq(CostIncomeGroup::getDateMonth, month));
|
|
|
- if (!CollectionUtils.isEmpty(groups)){
|
|
|
- throw new CostException(500,year+"年"+month+"月数据已存在");
|
|
|
+ if (!CollectionUtils.isEmpty(groups)) {
|
|
|
+ throw new CostException(500, year + "年" + month + "月数据已存在");
|
|
|
}
|
|
|
// 移除前几行的抬头内容 list的大小对应的就是行数的大小
|
|
|
for (int i = list.size() - 1; i >= 0; i--) {
|
|
@@ -175,29 +175,32 @@ public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMappe
|
|
|
Map<Long, Long> accountProMap = getProductIdAccountIdMap(accountingProductList);
|
|
|
List<CostIncomeGroup> costIncomeGroupArrayList = new ArrayList<>();
|
|
|
// 检验数据
|
|
|
- checkImportData(list, incomeErrorMessageList, costIncomeGroupArrayList, departmentMap, productMap, responsibilityMap, accountingMap, responsibilityDepMap, accountProMap,hospId,year,month);
|
|
|
+ checkImportData(list, incomeErrorMessageList, costIncomeGroupArrayList, departmentMap, productMap, responsibilityMap, accountingMap, responsibilityDepMap, accountProMap, hospId, year, month);
|
|
|
|
|
|
// 文件上传
|
|
|
String uploadFile = uploadFile(file, UserContext.getCurrentUser());
|
|
|
// 上传记录保存
|
|
|
- if (StrUtil.isBlank(uploadFile)){
|
|
|
- throw new CostException(500,"文件上传异常");
|
|
|
+ if (StrUtil.isBlank(uploadFile)) {
|
|
|
+ throw new CostException(500, "文件上传异常");
|
|
|
}
|
|
|
// 记录文件上传记录
|
|
|
- CostIncomeFile costIncomeFile =costIncomeFileService.saveCostIncomeFile(list, user, file, hospId, incomeErrorMessageList, uploadFile,fileType);
|
|
|
+ CostIncomeFile costIncomeFile = costIncomeFileService.saveCostIncomeFile(list, user, file, hospId, incomeErrorMessageList, uploadFile, fileType);
|
|
|
Long id = costIncomeFile.getId();
|
|
|
- costIncomeGroupArrayList.forEach(i->{
|
|
|
+ costIncomeGroupArrayList.forEach(i -> {
|
|
|
// 设置文件Id
|
|
|
i.setFileId(id);
|
|
|
});
|
|
|
- if (CollectionUtils.isEmpty(incomeErrorMessageList)){
|
|
|
+ if (CollectionUtils.isEmpty(incomeErrorMessageList)) {
|
|
|
this.saveBatch(costIncomeGroupArrayList);
|
|
|
+ return Result.build(200,"数据导入成功",null);
|
|
|
+ }else {
|
|
|
+ return Result.build(500, "数据未成功导入", null);
|
|
|
}
|
|
|
- return Result.ok();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 返回成本会计对照数据 Key 成本项目Id Value 会计科目Id
|
|
|
+ *
|
|
|
* @param accountingProductList
|
|
|
* @return
|
|
|
*/
|
|
@@ -210,6 +213,7 @@ public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMappe
|
|
|
* Map类型
|
|
|
* Key DepartmentId
|
|
|
* Value ResponsibilityId
|
|
|
+ *
|
|
|
* @param responsibilityDepartmentList
|
|
|
* @return
|
|
|
*/
|
|
@@ -219,12 +223,13 @@ public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMappe
|
|
|
|
|
|
public List<ResponsibilityDepartment> getResponsibilityDepartments(Long hospId) {
|
|
|
return responsibilityDepartmentService.list(new QueryWrapper<ResponsibilityDepartment>().lambda()
|
|
|
- .eq(ResponsibilityDepartment::getHospId, hospId));
|
|
|
+ .eq(ResponsibilityDepartment::getHospId, hospId));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Key AccountId
|
|
|
* Value Accounting对象
|
|
|
+ *
|
|
|
* @param hospId
|
|
|
* @return
|
|
|
*/
|
|
@@ -235,6 +240,7 @@ public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMappe
|
|
|
/**
|
|
|
* Key responsibilityId 责任中心Id
|
|
|
* Value Responsibility对象
|
|
|
+ *
|
|
|
* @param hospId
|
|
|
* @return
|
|
|
*/
|
|
@@ -245,15 +251,18 @@ public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMappe
|
|
|
/**
|
|
|
* Key 成本项目Code+Name
|
|
|
* Value 成本项目对象
|
|
|
+ *
|
|
|
* @param hospId
|
|
|
* @return
|
|
|
*/
|
|
|
public Map<String, Product> getProductByCodeNameMap(Long hospId) {
|
|
|
return productService.list(new QueryWrapper<Product>().lambda().eq(Product::getHospId, hospId)).stream().collect(Collectors.toMap(k -> k.getProductCode() + k.getProductName(), synOe -> synOe));
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* Key 科室项目Code+Name
|
|
|
* Value 科室对象
|
|
|
+ *
|
|
|
* @param hospId
|
|
|
* @return
|
|
|
*/
|
|
@@ -279,7 +288,8 @@ public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMappe
|
|
|
|
|
|
/**
|
|
|
* 检验数据
|
|
|
- * @param list 表单数据
|
|
|
+ *
|
|
|
+ * @param list 表单数据
|
|
|
* @param incomeErrorMessageList 存储错误信息的集合
|
|
|
* @param costIncomeGroupArrayList
|
|
|
* @param departmentMap 科室Map
|
|
@@ -290,7 +300,7 @@ public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMappe
|
|
|
* @param accountProMap 责任中心Map
|
|
|
* @param hospId
|
|
|
*/
|
|
|
- private void checkImportData(List<List<Object>> list, List<IncomeErrorMessage> incomeErrorMessageList, List<CostIncomeGroup> costIncomeGroupArrayList, Map<String, Department> departmentMap, Map<String, Product> productMap, Map<Long, Responsibility> responsibilityMap, Map<Long, Accounting> accountingMap, Map<Long, Long> responsibilityDepMap, Map<Long, Long> accountProMap, Long hospId,Integer year,Integer month) {
|
|
|
+ private void checkImportData(List<List<Object>> list, List<IncomeErrorMessage> incomeErrorMessageList, List<CostIncomeGroup> costIncomeGroupArrayList, Map<String, Department> departmentMap, Map<String, Product> productMap, Map<Long, Responsibility> responsibilityMap, Map<Long, Accounting> accountingMap, Map<Long, Long> responsibilityDepMap, Map<Long, Long> accountProMap, Long hospId, Integer year, Integer month) {
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
|
CostIncomeGroup costIncomeGroup = new CostIncomeGroup();
|
|
|
AfterIncomegroup afterIncomegroup = new AfterIncomegroup();
|
|
@@ -325,8 +335,8 @@ public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMappe
|
|
|
Product product = productMap.get(productCode + productName);
|
|
|
Department department = departmentMap.get(openDepartmentCode + openDepartmentName);
|
|
|
Department department1 = departmentMap.get(startDepartmentCode + startDepartmentName);
|
|
|
- if (!checkNull && !checkOne ){
|
|
|
- if (StrUtil.isNotBlank(productCode) && StrUtil.isNotBlank(productName)){
|
|
|
+ if (!checkNull && !checkOne) {
|
|
|
+ if (StrUtil.isNotBlank(productCode) && StrUtil.isNotBlank(productName)) {
|
|
|
if (Objects.isNull(product)) {
|
|
|
incomeErrorMessage.setTotal(i);
|
|
|
incomeErrorMessage.setErrMessage("代码:" + productCode + " 名称:" + productName + "成本项目不存在");
|
|
@@ -346,16 +356,16 @@ public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMappe
|
|
|
costIncomeGroup.setAccountName(accountingMap.get(accountId).getAccountingName());
|
|
|
}
|
|
|
}
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
costIncomeGroup.setProductCode(null);
|
|
|
costIncomeGroup.setProductName(null);
|
|
|
- costIncomeGroup.setAccountCode( null);
|
|
|
+ costIncomeGroup.setAccountCode(null);
|
|
|
costIncomeGroup.setAccountName(null);
|
|
|
}
|
|
|
}
|
|
|
// 检验开单科室
|
|
|
- if (!checkNull && !checkOne ){
|
|
|
- if (StrUtil.isNotBlank(openDepartmentCode) && StrUtil.isNotBlank(openDepartmentName)){
|
|
|
+ if (!checkNull && !checkOne) {
|
|
|
+ if (StrUtil.isNotBlank(openDepartmentCode) && StrUtil.isNotBlank(openDepartmentName)) {
|
|
|
// 开单科室
|
|
|
if (Objects.isNull(department)) {
|
|
|
incomeErrorMessage.setTotal(i);
|
|
@@ -374,10 +384,12 @@ public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMappe
|
|
|
costIncomeGroup.setOpenDepartmentName(openDepartmentName);
|
|
|
costIncomeGroup.setOpenResponsibilityCode(responsibility.getResponsibilityCode());
|
|
|
costIncomeGroup.setOpenResponsibilityName(responsibility.getResponsibilityName());
|
|
|
+ afterIncomegroup.setOpenDepartmentCode(openDepartmentCode);
|
|
|
+ afterIncomegroup.setOpenDepartmentName(openDepartmentName);
|
|
|
afterIncomegroup.setOpenDepartmentStatus(responsibility.getResponsibilityType());
|
|
|
}
|
|
|
}
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
costIncomeGroup.setOpenDepartmentCode(null);
|
|
|
costIncomeGroup.setOpenDepartmentName(null);
|
|
|
costIncomeGroup.setOpenResponsibilityCode(null);
|
|
@@ -385,8 +397,8 @@ public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMappe
|
|
|
}
|
|
|
}
|
|
|
// 检验执行科室
|
|
|
- if ( !checkNull && !checkOne ){
|
|
|
- if (StrUtil.isNotBlank(startDepartmentCode) && StrUtil.isNotBlank(startDepartmentName)){
|
|
|
+ if (!checkNull && !checkOne) {
|
|
|
+ if (StrUtil.isNotBlank(startDepartmentCode) && StrUtil.isNotBlank(startDepartmentName)) {
|
|
|
//执行科室
|
|
|
if (Objects.isNull(department1)) {
|
|
|
incomeErrorMessage.setTotal(i);
|
|
@@ -405,10 +417,12 @@ public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMappe
|
|
|
costIncomeGroup.setStartDepartmentName(startDepartmentName);
|
|
|
costIncomeGroup.setStartResponsibilityCode(responsibility.getResponsibilityCode());
|
|
|
costIncomeGroup.setStartResponsibilityName(responsibility.getResponsibilityName());
|
|
|
+ afterIncomegroup.setStartDepartmentCode(startDepartmentCode);
|
|
|
+ afterIncomegroup.setStartDepartmentName(startDepartmentName);
|
|
|
afterIncomegroup.setStartDepartmentStatus(responsibility.getResponsibilityType());
|
|
|
}
|
|
|
}
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
costIncomeGroup.setStartDepartmentCode(null);
|
|
|
costIncomeGroup.setStartDepartmentName(null);
|
|
|
costIncomeGroup.setStartResponsibilityCode(null);
|
|
@@ -420,7 +434,7 @@ public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMappe
|
|
|
.setPatientName(data.get(10).toString()).setPatientFee(data.get(11).toString()).setReceiptFee(data.get(12).toString())
|
|
|
.setTotalNumber(Integer.parseInt(data.get(13).toString())).setUnit(data.get(14).toString())
|
|
|
.setFeeDatetime(DateUtils.StringToDate(data.get(16).toString(), DateStyleEnum.YYYY_MM_DD_HH_MM_SS_EN));
|
|
|
- if (StrUtil.isNotBlank(costIncomeGroup.getOpenResponsibilityCode())){
|
|
|
+ if (StrUtil.isNotBlank(costIncomeGroup.getOpenResponsibilityCode())) {
|
|
|
|
|
|
}
|
|
|
costIncomeGroup.setHospId(hospId);
|
|
@@ -431,22 +445,31 @@ public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMappe
|
|
|
// 检验数据
|
|
|
Integer openDepartmentStatus = afterIncomegroup.getOpenDepartmentStatus();
|
|
|
Integer startDepartmentStatus = afterIncomegroup.getStartDepartmentStatus();
|
|
|
- Map<String, CostIncomeGroupSet> incomeGroupSetMap = costIncomeGroupSetService.list(new QueryWrapper<CostIncomeGroupSet>().lambda().eq(CostIncomeGroupSet::getHospId, hospId)).stream().collect(Collectors.toMap(k -> k.getOpenDepartmentStatus().toString() + k.getStartDepartmentStatus().toString(), synOe -> synOe));
|
|
|
- CostIncomeGroupSet costIncomeGroupSet = incomeGroupSetMap.get(openDepartmentStatus.toString() + startDepartmentStatus.toString());
|
|
|
- if (Objects.nonNull(costIncomeGroupSet)){
|
|
|
- afterIncomegroup.setOpenDepartmentStatus(costIncomeGroupSet.getOpenDepartmentStatus());
|
|
|
- afterIncomegroup.setOpenDepartmentProportion(costIncomeGroupSet.getOpenDepartmentProportion());
|
|
|
- // TODO 金额
|
|
|
-// afterIncomegroup.setOpenDepartmentDecimal(beforeMoney.multiply();
|
|
|
- afterIncomegroup.setStartDepartmentStatus(costIncomeGroupSet.getStartDepartmentStatus());
|
|
|
- afterIncomegroup.setStartDepartmentProportion(costIncomeGroupSet.getStartDepartmentProportion());
|
|
|
- // TODO 金额
|
|
|
-// afterIncomegroup.setOpenDepartmentDecimal(beforeMoney.multiply();
|
|
|
- if (NumberConstant.ZERO.equals(costIncomeGroupSet.getOpenDepartmentProportion()) && NumberConstant.ZERO.equals(costIncomeGroupSet.getStartDepartmentProportion())){
|
|
|
- afterIncomegroup.setResponsibilityCodes(costIncomeGroupSet.getResponsibilityCodes());
|
|
|
- afterIncomegroup.setDirectStatus(NumberConstant.TWO);
|
|
|
+ if (Objects.nonNull(openDepartmentStatus) && Objects.nonNull(startDepartmentStatus)) {
|
|
|
+ Map<String, CostIncomeGroupSet> incomeGroupSetMap = costIncomeGroupSetService.list(new QueryWrapper<CostIncomeGroupSet>().lambda().eq(CostIncomeGroupSet::getHospId, hospId)).stream().collect(Collectors.toMap(k -> k.getOpenDepartmentStatus().toString() + k.getStartDepartmentStatus().toString(), synOe -> synOe));
|
|
|
+ CostIncomeGroupSet costIncomeGroupSet = incomeGroupSetMap.get(openDepartmentStatus.toString() + startDepartmentStatus.toString());
|
|
|
+ if (Objects.nonNull(costIncomeGroupSet)) {
|
|
|
+ Map<String, Responsibility> map = responsibilityService.list(new QueryWrapper<Responsibility>().lambda().eq(Responsibility::getHospId, hospId)).stream().collect(Collectors.toMap(Responsibility::getResponsibilityCode, synOe -> synOe));
|
|
|
+ // 开单科室比例
|
|
|
+ BigDecimal openDepartmentProportion = new BigDecimal(costIncomeGroupSet.getOpenDepartmentProportion().toString());
|
|
|
+ // 执行科室比例
|
|
|
+ BigDecimal startDepartmentProportion = new BigDecimal(costIncomeGroupSet.getStartDepartmentProportion().toString());
|
|
|
+ // beforeMoney
|
|
|
+ afterIncomegroup.setOpenDepartmentDecimal(beforeMoney.multiply(openDepartmentProportion).divide(new BigDecimal(100), 4, BigDecimal.ROUND_HALF_UP));
|
|
|
+ afterIncomegroup.setStartDepartmentDecimal(beforeMoney.multiply(startDepartmentProportion).divide(new BigDecimal(100), 4, BigDecimal.ROUND_HALF_UP));
|
|
|
+ String responsibilityCodes = costIncomeGroupSet.getResponsibilityCodes();
|
|
|
+ if (NumberConstant.TWO.equals(costIncomeGroupSet.getOpenDepartmentStatus()) && NumberConstant.TWO.equals(costIncomeGroupSet.getStartDepartmentStatus()) && StrUtil.isNotBlank(responsibilityCodes)) {
|
|
|
+ // /拼接的
|
|
|
+ afterIncomegroup.setDirectStatus(NumberConstant.TWO);
|
|
|
+ String responsibilityCode = responsibilityCodes.split(StrUtil.SLASH)[responsibilityCodes.split(StrUtil.SLASH).length - 1];
|
|
|
+ Responsibility responsibility = map.get(responsibilityCode);
|
|
|
+ if (Objects.nonNull(responsibility)) {
|
|
|
+ afterIncomegroup.setResponsibilityCode(responsibility.getResponsibilityCode());
|
|
|
+ afterIncomegroup.setResponsibilityName(responsibility.getResponsibilityName());
|
|
|
+ }
|
|
|
+ costIncomeGroup.setAfterIncomeGroup(JSON.toJSONString(afterIncomegroup));
|
|
|
+ }
|
|
|
}
|
|
|
- costIncomeGroup.setAfterIncomeGroup(JSON.toJSONString(afterIncomegroup));
|
|
|
}
|
|
|
|
|
|
costIncomeGroupArrayList.add(costIncomeGroup);
|
|
@@ -485,7 +508,7 @@ public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMappe
|
|
|
*/
|
|
|
public String uploadFile(MultipartFile file, User user) {
|
|
|
Long hospId = user.getHospId();
|
|
|
- String fileName = file.getOriginalFilename().substring(0, file.getOriginalFilename().lastIndexOf("."))+System.currentTimeMillis()+".xsl";
|
|
|
+ String fileName = file.getOriginalFilename().substring(0, file.getOriginalFilename().lastIndexOf(".")) + System.currentTimeMillis() + ".xsl";
|
|
|
String localFilePath = fileTempPath + StrUtil.SLASH + hospId + StrUtil.SLASH;
|
|
|
File tempFile = new File(localFilePath);
|
|
|
if (!tempFile.exists()) {
|