Quellcode durchsuchen

导入模板修改

1021934019@qq.com vor 4 Jahren
Ursprung
Commit
90bb342b41

+ 2 - 6
blade-service/blade-client/src/main/java/org/springblade/client/corps/controller/CorpsDescController.java

@@ -146,17 +146,13 @@ public class CorpsDescController extends BladeController {
 	@PostMapping("/import-desc")
 	@ApiOperationSupport(order = 12)
 	@ApiOperation(value = "导入客户资料", notes = "传入excel")
-	public R importUser(MultipartFile file,String typeId) {
+	public R importUser(MultipartFile file) {
 		List<CorpsExcel> excelList = ExcelUtil.read(file, CorpsExcel.class);
 		if(CollectionUtils.isEmpty(excelList))
 		{
 			throw new SecurityException("数据不能为空");
 		}
-		excelList.forEach(e->{
-			e.setTypeId(typeId);
-		});
-		corpsDescService.importUser(excelList,false);
-		return R.success("操作成功");
+		return corpsDescService.importUser(excelList,false);
 	}
 
 

+ 2 - 1
blade-service/blade-client/src/main/java/org/springblade/client/corps/excel/CorpsExcel.java

@@ -42,7 +42,8 @@ public class CorpsExcel implements Serializable {
 	@ExcelProperty("职位")
 	private String position;
 
-
+	@ExcelProperty("客户分类(必填)")
+	private String type;
 
 	@ExcelProperty("联系人")
 	private String attn;

+ 1 - 1
blade-service/blade-client/src/main/java/org/springblade/client/corps/service/ICorpsDescService.java

@@ -93,6 +93,6 @@ public interface ICorpsDescService extends IService<CorpsDesc> {
 	 * @param
 	 * @return
 	 */
-	void importUser(List<CorpsExcel> data,Boolean isCovered);
+	R importUser(List<CorpsExcel> data,Boolean isCovered);
 
 }

+ 70 - 47
blade-service/blade-client/src/main/java/org/springblade/client/corps/service/impl/CorpsDescServiceImpl.java

@@ -25,10 +25,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.interceptor.TransactionAspectSupport;
 
-import java.util.Arrays;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -48,6 +45,7 @@ public class CorpsDescServiceImpl extends ServiceImpl<CorpsDescMapper, CorpsDesc
 	private CorpsTypeDescServiceImpl corpsTypeDescService;//客户与客户类别对应表
 	private CorpsTypeDescMapper corpsTypeDescMapper;
 	private CorpsTypeServiceImpl corpsTypeService;
+	private CorpsTypeMapper corpsTypeMapper;
 	@Autowired
 	private CorpsTypeDescMapper middleMapper;
 
@@ -166,63 +164,88 @@ public class CorpsDescServiceImpl extends ServiceImpl<CorpsDescMapper, CorpsDesc
 
 	@Override
 	@Transactional
-	public void importUser(List<CorpsExcel> data, Boolean isCovered)
+	public R importUser(List<CorpsExcel> data, Boolean isCovered)
 	{
 		try {
 			if(org.springframework.util.CollectionUtils.isEmpty(data))
 			{
 				throw new SecurityException("导入数据不能为空");
 			}
+			List<Boolean> countList=new ArrayList<>();
+
 			data.forEach(e->{
-				CorpsDesc corpsDesc=new CorpsDesc();
-				corpsDesc.setCode(e.getCode());
-				corpsDesc.setCname(e.getCname());
-				corpsDesc.setAttn(e.getAttn());
-				corpsDesc.setAttn(e.getAttn());
-				corpsDesc.setTel(e.getTel());
-				corpsDesc.setAddr(e.getAddr());
-				corpsDesc.setAccountBank(e.getAccountBank());
-				corpsDesc.setAccountName(e.getAccountName());
-				corpsDesc.setAccountNo(e.getAccountNo());
-				corpsDesc.setAccountBankFcy(e.getAccountBankFcy());
-				corpsDesc.setAccountNameFcy(e.getAccountNameFcy());
-				corpsDesc.setTenantId(AuthUtil.getTenantId());
-				corpsDesc.setAccountNoFcy(e.getAccountNoFcy());
-				corpsDesc.setEnname(e.getEnname());
-				corpsDesc.setGoodtypes(e.getGoodtypes());
-				corpsDesc.setBelongtocompany(e.getBelongtocompany());
-				corpsDesc.setBelongtoarea(e.getBelongtoarea());
-				corpsDesc.setCompanytype(e.getCompanytype());
-				corpsDesc.setPosition(e.getPosition());
-				//名称相等视为重复数据
-				LambdaQueryWrapper<CorpsDesc> queryWrapper = new LambdaQueryWrapper<>();
-				queryWrapper.eq(CorpsDesc::getCname,corpsDesc.getCname());
-				queryWrapper.eq(CorpsDesc::getIsDeleted,0);
-				CorpsDesc selectOne = baseMapper.selectOne(queryWrapper);
-				if(selectOne==null)
+				String type = e.getType();
+				CorpsType corpsType = corpsTypeMapper.selectCorpsTypeCname(type, AuthUtil.getTenantId());
+				if(corpsType!=null)
 				{
-					corpsDesc.setCreateTime(new Date());
-					corpsDesc.setCreateUser(AuthUtil.getUserId());
-					corpsDesc.setCreateDept(Long.valueOf(AuthUtil.getDeptId()));
-					baseMapper.insert(corpsDesc);
+					countList.add(true);
+					CorpsDesc corpsDesc=new CorpsDesc();
+					corpsDesc.setCode(e.getCode());
+					corpsDesc.setCname(e.getCname());
+					corpsDesc.setAttn(e.getAttn());
+					corpsDesc.setAttn(e.getAttn());
+					corpsDesc.setTel(e.getTel());
+					corpsDesc.setAddr(e.getAddr());
+					corpsDesc.setAccountBank(e.getAccountBank());
+					corpsDesc.setAccountName(e.getAccountName());
+					corpsDesc.setAccountNo(e.getAccountNo());
+					corpsDesc.setAccountBankFcy(e.getAccountBankFcy());
+					corpsDesc.setAccountNameFcy(e.getAccountNameFcy());
+					corpsDesc.setTenantId(AuthUtil.getTenantId());
+					corpsDesc.setAccountNoFcy(e.getAccountNoFcy());
+					corpsDesc.setEnname(e.getEnname());
+					corpsDesc.setGoodtypes(e.getGoodtypes());
+					corpsDesc.setBelongtocompany(e.getBelongtocompany());
+					corpsDesc.setBelongtoarea(e.getBelongtoarea());
+					corpsDesc.setCompanytype(e.getCompanytype());
+					corpsDesc.setPosition(e.getPosition());
+					//名称相等视为重复数据
+					LambdaQueryWrapper<CorpsDesc> queryWrapper = new LambdaQueryWrapper<>();
+					queryWrapper.eq(CorpsDesc::getCname,corpsDesc.getCname());
+					queryWrapper.eq(CorpsDesc::getIsDeleted,0);
+					CorpsDesc selectOne = baseMapper.selectOne(queryWrapper);
+					if(selectOne==null)
+					{
+						corpsDesc.setCreateTime(new Date());
+						corpsDesc.setCreateUser(AuthUtil.getUserId());
+						corpsDesc.setCreateDept(Long.valueOf(AuthUtil.getDeptId()));
+						baseMapper.insert(corpsDesc);
 
-					CorpsTypeDesc middle=new CorpsTypeDesc();
-					middle.setCorpId(corpsDesc.getId());
-					middle.setCorpTypeId(Long.valueOf(e.getTypeId()));
-					middle.setCreateTime(new Date());
-					middle.setCreateUser(AuthUtil.getUserId());
-					middle.setCreateDept(Long.valueOf(AuthUtil.getDeptId()));
-					middleMapper.insert(middle);
+						CorpsTypeDesc middle=new CorpsTypeDesc();
+						middle.setCorpId(corpsDesc.getId());
+						middle.setCorpTypeId(Long.valueOf(e.getTypeId()));
+						middle.setCreateTime(new Date());
+						middle.setCreateUser(AuthUtil.getUserId());
+						middle.setCreateDept(Long.valueOf(AuthUtil.getDeptId()));
+						middleMapper.insert(middle);
+					}
+					else
+					{
+						corpsDesc.setId(selectOne.getId());
+						corpsDesc.setUpdateTime(new Date());
+						corpsDesc.setUpdateUser(AuthUtil.getUserId());
+						baseMapper.updateById(corpsDesc);
+					}
 				}
 				else
 				{
-					corpsDesc.setId(selectOne.getId());
-					corpsDesc.setUpdateTime(new Date());
-					corpsDesc.setUpdateUser(AuthUtil.getUserId());
-					baseMapper.updateById(corpsDesc);
+					countList.add(false);
 				}
-
 			});
+			List<Boolean> booleanList = countList.stream().filter(e -> e == true).collect(Collectors.toList());
+			if(data.size()>booleanList.size())
+			{
+				return R.fail("导入中的数据,分类字段不存在或者未填分类字段");
+			}
+			else if(data.size()==booleanList.size())
+			{
+				return R.success("导入成功");
+			}
+			else
+			{
+				throw new SecurityException("导入失败,请仔细检查导入数据");
+			}
+
 		} catch (Exception e) {
 			throw new SecurityException("请检查导入数据");
 		}

+ 2 - 6
blade-service/blade-client/src/main/java/org/springblade/client/goods/controller/GoodsDescController.java

@@ -278,17 +278,13 @@ public class GoodsDescController extends BladeController {
 	@PostMapping("/import-desc")
 	@ApiOperationSupport(order = 12)
 	@ApiOperation(value = "导入商品资料", notes = "传入excel")
-	public R importUser(MultipartFile file,String typeId) {
+	public R importUser(MultipartFile file) {
 		List<GoodsExcel> excelList = ExcelUtil.read(file, GoodsExcel.class);
 		if(CollectionUtils.isEmpty(excelList))
 		{
 			throw new SecurityException("数据不能为空");
 		}
-		excelList.forEach(e->{
-			e.setTypeId(typeId);
-		});
-		goodsDescService.importGoods(excelList,false);
-		return R.success("操作成功");
+		return goodsDescService.importGoods(excelList,false);
 	}
 
 	/**

+ 1 - 1
blade-service/blade-client/src/main/java/org/springblade/client/goods/excel/GoodsExcel.java

@@ -54,7 +54,7 @@ public class GoodsExcel implements Serializable {
 	@ExcelProperty("规格尺寸")
 	private String specs;
 
-	@ExcelProperty("type,不需要填")
+	@ExcelProperty("分类(必填)")
 	private String type;
 
 

+ 2 - 1
blade-service/blade-client/src/main/java/org/springblade/client/goods/service/IGoodsDescService.java

@@ -22,6 +22,7 @@ import org.springblade.client.goods.excel.GoodsExcel;
 import org.springblade.client.vo.GoodsDescVO;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import org.springblade.core.tool.api.R;
 
 import java.util.List;
 
@@ -91,5 +92,5 @@ public interface IGoodsDescService extends IService<GoodsDesc> {
 	 * @param
 	 * @return
 	 */
-	void importGoods(List<GoodsExcel> data, Boolean isCovered);
+	R importGoods(List<GoodsExcel> data, Boolean isCovered);
 }

+ 81 - 48
blade-service/blade-client/src/main/java/org/springblade/client/goods/service/impl/GoodsDescServiceImpl.java

@@ -33,12 +33,14 @@ import org.springblade.core.log.exception.ServiceException;
 import org.springblade.core.mp.support.Condition;
 import org.springblade.core.secure.utils.AuthUtil;
 import org.springblade.core.secure.utils.SecureUtil;
+import org.springblade.core.tool.api.R;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
 import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * 商品详情表 服务实现类
@@ -319,68 +321,99 @@ public class GoodsDescServiceImpl extends ServiceImpl<GoodsDescMapper, GoodsDesc
 
 	@Override
 	@Transactional
-	public void importGoods(List<GoodsExcel> data, Boolean isCovered)
+	public R importGoods(List<GoodsExcel> data, Boolean isCovered)
 	{
 		try {
 			if(org.springframework.util.CollectionUtils.isEmpty(data))
 			{
 				throw new SecurityException("导入数据不能为空");
 			}
+			//统计正确数据行数
+            List<Boolean> countList=new ArrayList<>();
+
 			data.forEach(e->{
-				GoodsDesc goodsDesc=new GoodsDesc();
-				goodsDesc.setCode(e.getCode());
-				goodsDesc.setCname(e.getCname());
-				goodsDesc.setTypeno(e.getTypeNo());
-				goodsDesc.setBrand(e.getBrand());
-				goodsDesc.setBrandItem(e.getBrandItem());
-				goodsDesc.setSpecs(e.getSpecs());
-				goodsDesc.setType(0L);
-				goodsDesc.setCategory(e.getCategory());
-				goodsDesc.setCategoryitem(e.getCategoryitem());
-				goodsDesc.setUnit(e.getUnit());
-				goodsDesc.setPackgeunit(e.getPackgeunit());
-				goodsDesc.setRemarks(e.getRemarks());
-				goodsDesc.setGoodsTypeId(e.getTypeId());
-				goodsDesc.setEname(e.getEname());
-				goodsDesc.setNameDescription(e.getNameDescription());
-				goodsDesc.setCnameDescription(e.getCnameDescription());
-				goodsDesc.setCustomCode(e.getCustomCode());
-				goodsDesc.setCustomName(e.getCustomName());
-				goodsDesc.setCustomEname(e.getCustomEname());
-				if(e.getCustomRate()!=null)
-				{
-					goodsDesc.setCustomRate(new BigDecimal(e.getCustomRate()));
-				}
-				//如果名称相等 就认为重复
-				LambdaQueryWrapper<GoodsDesc> queryWrapper = new LambdaQueryWrapper<>();
-				queryWrapper.eq(GoodsDesc::getCname,goodsDesc.getCname());
-				queryWrapper.eq(GoodsDesc::getIsDeleted,0);
-				GoodsDesc one = goodsDescMapper.selectOne(queryWrapper);
-				if(one==null)
+				String type = e.getType();
+				GoodsType goodsType = goodsTypeMapper.selectGoodsTypeCname(type, AuthUtil.getTenantId());
+				if(goodsType!=null)
 				{
-					goodsDesc.setCreateTime(new Date());
-					goodsDesc.setCreateUser(AuthUtil.getUserId());
-					goodsDesc.setCreateDept(Long.valueOf(AuthUtil.getDeptId()));
-					goodsDescMapper.insert(goodsDesc);
+					countList.add(true);
+					GoodsDesc goodsDesc=new GoodsDesc();
+					goodsDesc.setCode(e.getCode());
+					goodsDesc.setCname(e.getCname());
+					goodsDesc.setTypeno(e.getTypeNo());
+					goodsDesc.setBrand(e.getBrand());
+					goodsDesc.setBrandItem(e.getBrandItem());
+					goodsDesc.setSpecs(e.getSpecs());
+					goodsDesc.setType(0L);
+					goodsDesc.setCategory(e.getCategory());
+					goodsDesc.setCategoryitem(e.getCategoryitem());
+					goodsDesc.setUnit(e.getUnit());
+					goodsDesc.setPackgeunit(e.getPackgeunit());
+					goodsDesc.setRemarks(e.getRemarks());
+					goodsDesc.setGoodsTypeId(e.getTypeId());
+					goodsDesc.setEname(e.getEname());
+					goodsDesc.setNameDescription(e.getNameDescription());
+					goodsDesc.setCnameDescription(e.getCnameDescription());
+					goodsDesc.setCustomCode(e.getCustomCode());
+					goodsDesc.setCustomName(e.getCustomName());
+					goodsDesc.setCustomEname(e.getCustomEname());
+					goodsDesc.setGoodsTypeId(String.valueOf(goodsType.getId()));
+					if(e.getCustomRate()!=null)
+					{
+						goodsDesc.setCustomRate(new BigDecimal(e.getCustomRate()));
+					}
+					//如果名称相等 就认为重复
+					LambdaQueryWrapper<GoodsDesc> queryWrapper = new LambdaQueryWrapper<>();
+					queryWrapper.eq(GoodsDesc::getTenantId,AuthUtil.getTenantId());
+					queryWrapper.eq(GoodsDesc::getCname,goodsDesc.getCname());
+					queryWrapper.eq(GoodsDesc::getIsDeleted,0);
+					GoodsDesc one = goodsDescMapper.selectOne(queryWrapper);
+					if(one==null)
+					{
+						goodsDesc.setCreateTime(new Date());
+						goodsDesc.setCreateUser(AuthUtil.getUserId());
+						goodsDesc.setCreateDept(Long.valueOf(AuthUtil.getDeptId()));
+						goodsDescMapper.insert(goodsDesc);
 
-					GoodsTypeDesc goodsTypeDes=new GoodsTypeDesc();
-					goodsTypeDes.setGoodsId(goodsDesc.getId());
-					goodsTypeDes.setGoodsTypeId(Long.valueOf(e.getTypeId()));
-					goodsTypeDes.setCreateTime(new Date());
-					goodsTypeDes.setCreateUser(AuthUtil.getUserId());
-					goodsTypeDes.setCreateDept(Long.valueOf(AuthUtil.getDeptId()));
-					goodsTypeDescMapper.insert(goodsTypeDes);
+						GoodsTypeDesc goodsTypeDes=new GoodsTypeDesc();
+						goodsTypeDes.setGoodsId(goodsDesc.getId());
+						goodsTypeDes.setGoodsTypeId(goodsType.getId());
+						goodsTypeDes.setCreateTime(new Date());
+						goodsTypeDes.setCreateUser(AuthUtil.getUserId());
+						goodsTypeDes.setCreateDept(Long.valueOf(AuthUtil.getDeptId()));
+						goodsTypeDescMapper.insert(goodsTypeDes);
+					}
+					else
+					{
+						goodsDesc.setId(one.getId());
+						goodsDesc.setUpdateTime(new Date());
+						goodsDesc.setUpdateUser(AuthUtil.getUserId());
+						goodsDescMapper.updateById(goodsDesc);
+					}
 				}
 				else
 				{
-					goodsDesc.setId(one.getId());
-					goodsDesc.setUpdateTime(new Date());
-					goodsDesc.setUpdateUser(AuthUtil.getUserId());
-					goodsDescMapper.updateById(goodsDesc);
+					countList.add(false);
 				}
 			});
-		} catch (Exception e) {
-			throw new SecurityException("请仔细检查导入数据");
+			List<Boolean> booleanList = countList.stream().filter(e -> e == true).collect(Collectors.toList());
+			if(data.size()>booleanList.size())
+			{
+				return R.fail("导入中的数据,分类字段不存在或者未填分类字段");
+			}
+			else if(data.size()==booleanList.size())
+			{
+				return R.success("导入成功");
+			}
+			else
+			{
+				throw new SecurityException("导入失败,请仔细检查导入数据");
+			}
+
+		}
+		catch (Exception e)
+		{
+			throw new SecurityException("导入失败,请仔细检查导入数据");
 		}
 	}
 

+ 6 - 1
blade-service/trade-finance/src/main/java/com/trade/finance/controller/SettlementController.java

@@ -31,6 +31,7 @@ import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
 import lombok.AllArgsConstructor;
 import javax.validation.Valid;
 
+import org.springblade.client.entity.CorpsDesc;
 import org.springblade.client.feign.ICorpsDescClient;
 import org.springblade.core.mp.support.Condition;
 import org.springblade.core.mp.support.Query;
@@ -94,7 +95,11 @@ public class SettlementController extends BladeController {
 		if(CollectionUtils.isNotEmpty(settlementList))
 		{
 			settlementList.forEach(e->{
-
+				R<CorpsDesc> corpMessage = corpsDescClient.getCorpMessage(e.getCorpId());
+				if(corpMessage.getData()!=null)
+				{
+					e.setCorpName(corpMessage.getData().getCname());
+				}
 			});
 		}
 		return R.data(pages);