|
|
|
@ -1,11 +1,9 @@ |
|
|
|
|
package com.dxhy.order.consumer.modules.taxcodematch.controller; |
|
|
|
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
|
import com.dxhy.base.file.common.ExcelReadContext; |
|
|
|
|
import com.dxhy.base.file.exception.ExcelReadException; |
|
|
|
|
import com.dxhy.base.file.handle.ExcelReadHandle; |
|
|
|
|
import com.dxhy.order.baseservice.module.commodity.constant.CommodityEnum; |
|
|
|
|
import com.dxhy.order.baseservice.module.commodity.model.CommodityExcel; |
|
|
|
|
import com.dxhy.order.consumer.modules.commodity.domain.dto.QueryGroupCommodityDTO; |
|
|
|
|
import com.dxhy.order.consumer.modules.taxcodematch.emum.SdenergyTaxCodeMatchEnum; |
|
|
|
|
import com.dxhy.order.consumer.modules.taxcodematch.entity.SdenergyTaxCodeMatch; |
|
|
|
|
import com.dxhy.order.consumer.modules.taxcodematch.model.dto.SdenergyTaxCodeMatchDTO; |
|
|
|
@ -13,6 +11,7 @@ import com.dxhy.order.consumer.modules.taxcodematch.model.dto.SdenergyTaxCodeMat |
|
|
|
|
import com.dxhy.order.consumer.modules.taxcodematch.service.SdenergyTaxCodeMatchService; |
|
|
|
|
import com.dxhy.order.model.PageUtils; |
|
|
|
|
import com.dxhy.order.model.R; |
|
|
|
|
import com.google.common.collect.Lists; |
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
import org.apache.commons.beanutils.BeanUtils; |
|
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
@ -67,6 +66,16 @@ public class SdenergyTaxCodeMatchController { |
|
|
|
|
|
|
|
|
|
@PostMapping("/create") |
|
|
|
|
public R create(@RequestBody SdenergyTaxCodeMatchDTO dto) { |
|
|
|
|
if(StringUtils.isEmpty(dto.getWlflbm())){ |
|
|
|
|
return R.error("物料分类编码为空!"); |
|
|
|
|
}else { |
|
|
|
|
SdenergyTaxCodeMatch codeMatch = sdenergyTaxCodeMatchService.queryByWlflbm(dto.getWlflbm()); |
|
|
|
|
if(codeMatch != null){ |
|
|
|
|
return R.error("物料分类编码已存在"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return sdenergyTaxCodeMatchService.insert(dto) > 0 ? R.ok() : R.error("插入失败"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -74,6 +83,14 @@ public class SdenergyTaxCodeMatchController { |
|
|
|
|
public R edit(@RequestBody SdenergyTaxCodeMatch dto) { |
|
|
|
|
SdenergyTaxCodeMatch updateEntity = new SdenergyTaxCodeMatch(); |
|
|
|
|
try { |
|
|
|
|
if(StringUtils.isEmpty(dto.getWlflbm())){ |
|
|
|
|
return R.error("物料分类编码为空!"); |
|
|
|
|
}else { |
|
|
|
|
SdenergyTaxCodeMatch codeMatch = sdenergyTaxCodeMatchService.queryByWlflbm(dto.getWlflbm()); |
|
|
|
|
if(codeMatch != null && !dto.getId().equals(dto.getId())){ |
|
|
|
|
return R.error("物料分类编码已存在"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
BeanUtils.copyProperties(updateEntity, dto); |
|
|
|
|
if (sdenergyTaxCodeMatchService.update(updateEntity) > 0) { |
|
|
|
|
return R.ok(); |
|
|
|
@ -125,7 +142,37 @@ public class SdenergyTaxCodeMatchController { |
|
|
|
|
log.error("{},导入物料分类编码异常", LOGGER_MSG, e); |
|
|
|
|
return R.error("导入物料分类编码异常,请重新上传"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(ObjectUtil.isEmpty(uploadList) ){ |
|
|
|
|
return R.error("数据解析为空"); |
|
|
|
|
} |
|
|
|
|
List<String> errorMsgList = Lists.newArrayList(); |
|
|
|
|
int resultIndex = 3; |
|
|
|
|
for (SdenergyTaxCodeMatch taxCodeMatch : uploadList) { |
|
|
|
|
String wlflbm = taxCodeMatch.getWlflbm(); |
|
|
|
|
if(StringUtils.isNotBlank(wlflbm)){ |
|
|
|
|
SdenergyTaxCodeMatch codeMatch = sdenergyTaxCodeMatchService.queryByWlflbm(taxCodeMatch.getWlflbm()); |
|
|
|
|
if(codeMatch != null){ |
|
|
|
|
errorMsgList.add("第" + resultIndex + "行,物料分类编码已存在"); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
}else { |
|
|
|
|
errorMsgList.add("第" + resultIndex + "行,物料分类编码不能为空"); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
String ssflbm = taxCodeMatch.getSsflbm(); |
|
|
|
|
if(StringUtils.isBlank(ssflbm)){ |
|
|
|
|
errorMsgList.add("第" + resultIndex + "行,税收分类编码不能为空"); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
String ssflmc = taxCodeMatch.getSsflmc(); |
|
|
|
|
if(StringUtils.isBlank(ssflmc)){ |
|
|
|
|
errorMsgList.add("第" + resultIndex + "行,税收分类名称不能为空"); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (ObjectUtil.isNotEmpty(errorMsgList)) { |
|
|
|
|
return R.error(errorMsgList); |
|
|
|
|
} |
|
|
|
|
return sdenergyTaxCodeMatchService.upload(uploadList) > 0 ? R.ok() : R.error(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|