|
|
@@ -29,7 +29,6 @@ import org.springblade.client.corps.excel.GoodsImportExcel;
|
|
|
import org.springblade.client.corps.mapper.CorpsDescMapper;
|
|
|
import org.springblade.client.dto.GoodsDescDto;
|
|
|
import org.springblade.client.entity.*;
|
|
|
-import org.springblade.client.feign.ICorpsDescClient;
|
|
|
import org.springblade.client.goods.excel.GoodsExcel;
|
|
|
import org.springblade.client.goods.excel.GoodsExcels;
|
|
|
import org.springblade.client.goods.excel.GoodsInfoExcel;
|
|
|
@@ -83,7 +82,6 @@ public class GoodsDescServiceImpl extends ServiceImpl<GoodsDescMapper, GoodsDesc
|
|
|
private final GoodsFilesMapper goodsFilesMapper;
|
|
|
private final GoodsSpecificationMapper goodsSpecificationMapper;
|
|
|
private final CorpsDescMapper corpsDescMapper;
|
|
|
- private final ICorpsDescClient corpsDescClient;
|
|
|
private final IBrandClient brandClient;
|
|
|
private final IUserClient userClient;
|
|
|
|
|
|
@@ -392,84 +390,99 @@ public class GoodsDescServiceImpl extends ServiceImpl<GoodsDescMapper, GoodsDesc
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public R importGoods(List<GoodsExcel> data, Boolean isCovered) {
|
|
|
|
|
|
if (org.springframework.util.CollectionUtils.isEmpty(data)) {
|
|
|
throw new SecurityException("导入数据不能为空");
|
|
|
}
|
|
|
|
|
|
+ String type = data.stream().map(GoodsExcel::getType).distinct().collect(Collectors.joining(","));
|
|
|
+ List<GoodsType> goodsTypeList = goodsTypeMapper.selectList(new LambdaQueryWrapper<GoodsType>()
|
|
|
+ .eq(GoodsType::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(GoodsType::getIsDeleted, 0)
|
|
|
+ .apply("find_in_set(cname,'" + type + "')"));
|
|
|
+ if (goodsTypeList.isEmpty()) {
|
|
|
+ throw new RuntimeException("未查到分类信息");
|
|
|
+ }
|
|
|
for (int i = 0; i < data.size(); i++) {
|
|
|
GoodsExcel goodsExcel = data.get(i);
|
|
|
- String type = goodsExcel.getType();
|
|
|
- GoodsType goodsType = goodsTypeMapper.selectGoodsTypeCname(type, AuthUtil.getTenantId(), null);
|
|
|
- if (goodsType == null) {
|
|
|
+ List<GoodsType> goodsTypes = goodsTypeList.stream().filter(e -> goodsExcel.getType().contains(e.getCname())).collect(Collectors.toList());
|
|
|
+ if (goodsTypes.isEmpty()) {
|
|
|
throw new SecurityException("第" + (i + 1) + "行未添加分类或者分类不存在");
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ List<CorpsDesc> corpsDescList = corpsDescMapper.selectList(new LambdaQueryWrapper<CorpsDesc>()
|
|
|
+ .eq(CorpsDesc::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(CorpsDesc::getIsDeleted, 0)
|
|
|
+ .eq(CorpsDesc::getCorpType, "GYS"));
|
|
|
data.forEach(e -> {
|
|
|
- String type = e.getType();
|
|
|
- GoodsType goodsType = goodsTypeMapper.selectGoodsTypeCname(type, AuthUtil.getTenantId(), null);
|
|
|
- if (goodsType != null) {
|
|
|
- GoodsDesc goodsDesc = new GoodsDesc();
|
|
|
- goodsDesc.setCode(e.getCode());
|
|
|
- goodsDesc.setCname(e.getCname());
|
|
|
- goodsDesc.setCnameInt(e.getCnameInt());
|
|
|
- if (StringUtil.isBlank(goodsDesc.getCnameInt())) {
|
|
|
- goodsDesc.setCnameInt(getCnameInt(goodsDesc.getCname()));
|
|
|
- }
|
|
|
- goodsDesc.setBrandItem(e.getBrandItem());
|
|
|
- goodsDesc.setBrand(e.getBrand());
|
|
|
- goodsDesc.setTypeno(e.getTypeNo());
|
|
|
- goodsDesc.setSpecsOne(e.getSpecsOne());
|
|
|
- goodsDesc.setLevel(e.getLevel());
|
|
|
- goodsDesc.setLevelOne(e.getLevelOne());
|
|
|
- goodsDesc.setMasterUnit(e.getMasterUnit());
|
|
|
- goodsDesc.setSlaveUnit(e.getSlaveUnit());
|
|
|
- goodsDesc.setSwapRate(e.getSwapRate());
|
|
|
- goodsDesc.setTinyNumber(e.getTinyNumber());
|
|
|
- goodsDesc.setTax(e.getTax());
|
|
|
- goodsDesc.setPrice(e.getPrice());
|
|
|
- goodsDesc.setEffectiveDay(e.getEffectiveDay());
|
|
|
- goodsDesc.setPlaceProduction(e.getPlaceProduction());
|
|
|
- goodsDesc.setCompany(e.getCompany());
|
|
|
- goodsDesc.setRemarks(e.getRemarks());
|
|
|
- goodsDesc.setType(0L);
|
|
|
- goodsDesc.setGoodsTypeId(String.valueOf(goodsType.getId()));
|
|
|
- // 获取供应商
|
|
|
- /*CorpsDesc corpsDesc = new CorpsDesc();
|
|
|
- corpsDesc.setCname(e.getCorpName());
|
|
|
- corpsDesc.setCorpType("GYS");*/
|
|
|
- CorpsDesc corpByName = corpsDescClient.getCorpsDesc(e.getCorpName(), "GYS");
|
|
|
- if (corpByName != null) {
|
|
|
- goodsDesc.setCorpId(corpByName.getId());
|
|
|
- goodsDesc.setCorpName(corpByName.getCname());
|
|
|
- }
|
|
|
- // 如果名称相等 就认为重复
|
|
|
- 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);
|
|
|
-
|
|
|
+ List<GoodsType> goodsTypes = goodsTypeList.stream().filter(i -> e.getType().contains(i.getCname())).collect(Collectors.toList());
|
|
|
+ GoodsDesc goodsDesc = new GoodsDesc();
|
|
|
+ goodsDesc.setCode(e.getCode());
|
|
|
+ goodsDesc.setCname(e.getCname());
|
|
|
+ goodsDesc.setCnameInt(e.getCnameInt());
|
|
|
+ if (StringUtil.isBlank(goodsDesc.getCnameInt())) {
|
|
|
+ goodsDesc.setCnameInt(getCnameInt(goodsDesc.getCname()));
|
|
|
+ }
|
|
|
+ goodsDesc.setBrandItem(e.getBrandItem());
|
|
|
+ goodsDesc.setBrand(e.getBrand());
|
|
|
+ goodsDesc.setTypeno(e.getTypeNo());
|
|
|
+ goodsDesc.setSpecsOne(e.getSpecsOne());
|
|
|
+ goodsDesc.setLevel(e.getLevel());
|
|
|
+ goodsDesc.setLevelOne(e.getLevelOne());
|
|
|
+ goodsDesc.setMasterUnit(e.getMasterUnit());
|
|
|
+ goodsDesc.setSlaveUnit(e.getSlaveUnit());
|
|
|
+ goodsDesc.setSwapRate(e.getSwapRate());
|
|
|
+ goodsDesc.setTinyNumber(e.getTinyNumber());
|
|
|
+ goodsDesc.setTax(e.getTax());
|
|
|
+ goodsDesc.setPrice(e.getPrice());
|
|
|
+ goodsDesc.setEffectiveDay(e.getEffectiveDay());
|
|
|
+ goodsDesc.setPlaceProduction(e.getPlaceProduction());
|
|
|
+ goodsDesc.setCompany(e.getCompany());
|
|
|
+ goodsDesc.setRemarks(e.getRemarks());
|
|
|
+ goodsDesc.setType(0L);
|
|
|
+ StringBuilder typeIds = new StringBuilder();
|
|
|
+ List<Long> typeIdList = goodsTypes.stream().map(GoodsType::getId).distinct().collect(Collectors.toList());
|
|
|
+ for (Long id : typeIdList) {
|
|
|
+ typeIds.append(id).append(",");
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isNotNull(typeIds.toString())) {
|
|
|
+ typeIds = new StringBuilder(typeIds.substring(0, typeIds.length() - 1));
|
|
|
+ }
|
|
|
+ goodsDesc.setGoodsTypeId(typeIds.toString());
|
|
|
+ // 获取供应商
|
|
|
+ CorpsDesc corpByName = corpsDescList.stream().filter(i -> i.getCname().equals(e.getCorpName())).findFirst().orElse(null);
|
|
|
+ if (corpByName != null) {
|
|
|
+ goodsDesc.setCorpId(corpByName.getId());
|
|
|
+ goodsDesc.setCorpName(corpByName.getCname());
|
|
|
+ }
|
|
|
+ // 如果名称相等 就认为重复
|
|
|
+ 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);
|
|
|
+
|
|
|
+ for (GoodsType item : goodsTypes) {
|
|
|
GoodsTypeDesc goodsTypeDes = new GoodsTypeDesc();
|
|
|
goodsTypeDes.setGoodsId(goodsDesc.getId());
|
|
|
- goodsTypeDes.setGoodsTypeId(goodsType.getId());
|
|
|
+ goodsTypeDes.setGoodsTypeId(item.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);
|
|
|
}
|
|
|
});
|
|
|
return R.success("ok");
|
|
|
@@ -484,48 +497,89 @@ public class GoodsDescServiceImpl extends ServiceImpl<GoodsDescMapper, GoodsDesc
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public R importGoodsNew(List<GoodsExcels> data, Boolean isCovered) {
|
|
|
if (org.springframework.util.CollectionUtils.isEmpty(data)) {
|
|
|
throw new SecurityException("导入数据不能为空");
|
|
|
}
|
|
|
-
|
|
|
+ String type = data.stream().map(GoodsExcels::getType).distinct().collect(Collectors.joining(","));
|
|
|
+ List<GoodsType> goodsTypeList = goodsTypeMapper.selectList(new LambdaQueryWrapper<GoodsType>()
|
|
|
+ .eq(GoodsType::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(GoodsType::getIsDeleted, 0)
|
|
|
+ .apply("find_in_set(cname,'" + type + "')"));
|
|
|
+ if (goodsTypeList.isEmpty()) {
|
|
|
+ throw new RuntimeException("未查到分类信息");
|
|
|
+ }
|
|
|
for (int i = 0; i < data.size(); i++) {
|
|
|
GoodsExcels goodsExcel = data.get(i);
|
|
|
- String type = goodsExcel.getType();
|
|
|
- GoodsType goodsType = goodsTypeMapper.selectGoodsTypeCname(type, AuthUtil.getTenantId(), null);
|
|
|
- if (goodsType == null) {
|
|
|
+ List<GoodsType> goodsTypes = goodsTypeList.stream().filter(e -> goodsExcel.getType().contains(e.getCname())).collect(Collectors.toList());
|
|
|
+ if (goodsTypes.isEmpty()) {
|
|
|
throw new SecurityException("第" + (i + 1) + "行未添加分类或者分类不存在");
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- data.forEach(e -> {
|
|
|
- String type = e.getType();
|
|
|
- GoodsType goodsType = goodsTypeMapper.selectGoodsTypeCname(type, AuthUtil.getTenantId(), null);
|
|
|
- if (goodsType != null) {
|
|
|
- GoodsDesc goodsDesc = new GoodsDesc();
|
|
|
- goodsDesc.setCode(e.getCode());
|
|
|
- goodsDesc.setCname(e.getCname());
|
|
|
- goodsDesc.setEname(e.getEname());
|
|
|
- goodsDesc.setTypeno(e.getTypeno());
|
|
|
- goodsDesc.setEtypeno(e.getEtypeno());
|
|
|
- goodsDesc.setCustomName(e.getCustomName());
|
|
|
- goodsDesc.setCustomEname(e.getCustomEname());
|
|
|
- goodsDesc.setCustomCode(e.getCustomCode());
|
|
|
- goodsDesc.setCustomRate(e.getCustomRate());
|
|
|
- goodsDesc.setNameDescription(e.getNameDescription());
|
|
|
- goodsDesc.setCnameDescription(e.getCnameDescription());
|
|
|
- if (StringUtil.isBlank(goodsDesc.getCnameInt())) {
|
|
|
- goodsDesc.setCnameInt(getCnameInt(goodsDesc.getCname()));
|
|
|
+ String adminProfilesName = data.stream().map(GoodsExcels::getSupervisorUserNameGroup).distinct().collect(Collectors.joining(","));
|
|
|
+ String userIds = userClient.selectUserByNames(adminProfilesName);
|
|
|
+ List<User> userList = new ArrayList<>();
|
|
|
+ if (ObjectUtils.isNotNull(userIds)) {
|
|
|
+ userList = userClient.selectUserList(userIds);
|
|
|
+ }
|
|
|
+ List<CorpsDesc> corpsDescList = corpsDescMapper.selectList(new LambdaQueryWrapper<CorpsDesc>()
|
|
|
+ .eq(CorpsDesc::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(CorpsDesc::getIsDeleted, 0)
|
|
|
+ .eq(CorpsDesc::getCorpType, "GYS"));
|
|
|
+ for (GoodsExcels e : data) {
|
|
|
+ List<GoodsType> goodsTypes = goodsTypeList.stream().filter(i -> e.getType().contains(i.getCname())).collect(Collectors.toList());
|
|
|
+ GoodsDesc goodsDesc = new GoodsDesc();
|
|
|
+ goodsDesc.setCode(e.getCode());
|
|
|
+ goodsDesc.setCname(e.getCname());
|
|
|
+ goodsDesc.setEname(e.getEname());
|
|
|
+ goodsDesc.setTypeno(e.getTypeno());
|
|
|
+ goodsDesc.setEtypeno(e.getEtypeno());
|
|
|
+ goodsDesc.setCustomName(e.getCustomName());
|
|
|
+ goodsDesc.setCustomEname(e.getCustomEname());
|
|
|
+ goodsDesc.setCustomCode(e.getCustomCode());
|
|
|
+ goodsDesc.setCustomRate(e.getCustomRate());
|
|
|
+ goodsDesc.setNameDescription(e.getNameDescription());
|
|
|
+ goodsDesc.setCnameDescription(e.getCnameDescription());
|
|
|
+ if (StringUtil.isBlank(goodsDesc.getCnameInt())) {
|
|
|
+ goodsDesc.setCnameInt(getCnameInt(goodsDesc.getCname()));
|
|
|
+ }
|
|
|
+ goodsDesc.setPrice(e.getPrice());
|
|
|
+ goodsDesc.setType(0L);
|
|
|
+ StringBuilder typeIds = new StringBuilder();
|
|
|
+ List<Long> typeIdList = goodsTypes.stream().map(GoodsType::getId).distinct().collect(Collectors.toList());
|
|
|
+ for (Long id : typeIdList) {
|
|
|
+ typeIds.append(id).append(",");
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isNotNull(typeIds.toString())) {
|
|
|
+ typeIds = new StringBuilder(typeIds.substring(0, typeIds.length() - 1));
|
|
|
+ }
|
|
|
+ goodsDesc.setGoodsTypeId(typeIds.toString());
|
|
|
+ // 获取供应商
|
|
|
+ CorpsDesc corpByName = corpsDescList.stream().filter(i -> i.getCname().equals(e.getCorpName())).findFirst().orElse(null);
|
|
|
+ if (corpByName != null) {
|
|
|
+ goodsDesc.setCorpId(corpByName.getId());
|
|
|
+ goodsDesc.setCorpName(corpByName.getCname());
|
|
|
+ }
|
|
|
+ if (!userList.isEmpty() && ObjectUtils.isNotNull(e.getSupervisorUserNameGroup())) {
|
|
|
+ goodsDesc.setSupervisorUserNameGroup(userList.stream().map(User::getRealName)
|
|
|
+ .filter(realName -> e.getSupervisorUserNameGroup().contains(realName)).collect(Collectors.joining(",")));
|
|
|
+ List<Long> ids = userList.stream().filter(realName -> e.getSupervisorUserNameGroup().contains(realName.getRealName()))
|
|
|
+ .map(User::getId).distinct().collect(Collectors.toList());
|
|
|
+ StringBuilder supervisorUserIdGroup = new StringBuilder();
|
|
|
+ for (Long i : ids) {
|
|
|
+ supervisorUserIdGroup.append(i).append(",");
|
|
|
}
|
|
|
- goodsDesc.setPrice(e.getPrice());
|
|
|
- goodsDesc.setType(0L);
|
|
|
- goodsDesc.setGoodsTypeId(String.valueOf(goodsType.getId()));
|
|
|
- // 获取供应商
|
|
|
- CorpsDesc corpByName = corpsDescClient.getCorpsDesc(e.getCorpName(), "GYS");
|
|
|
- if (corpByName != null) {
|
|
|
- goodsDesc.setCorpId(corpByName.getId());
|
|
|
- goodsDesc.setCorpName(corpByName.getCname());
|
|
|
+ if (ObjectUtils.isNotNull(supervisorUserIdGroup.toString())) {
|
|
|
+ goodsDesc.setSupervisorUserIdGroup(supervisorUserIdGroup.substring(0, supervisorUserIdGroup.length() - 1));
|
|
|
}
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isNotNull(e.getGoodsIds())) {
|
|
|
+ goodsDesc.setId(Long.parseLong(e.getGoodsIds()));
|
|
|
+ goodsDesc.setUpdateTime(new Date());
|
|
|
+ goodsDesc.setUpdateUser(AuthUtil.getUserId());
|
|
|
+ goodsDescMapper.updateById(goodsDesc);
|
|
|
+ } else {
|
|
|
// 如果名称相等 就认为重复
|
|
|
LambdaQueryWrapper<GoodsDesc> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
queryWrapper.eq(GoodsDesc::getTenantId, AuthUtil.getTenantId());
|
|
|
@@ -537,14 +591,15 @@ public class GoodsDescServiceImpl extends ServiceImpl<GoodsDescMapper, GoodsDesc
|
|
|
goodsDesc.setCreateUser(AuthUtil.getUserId());
|
|
|
goodsDesc.setCreateDept(Long.valueOf(AuthUtil.getDeptId()));
|
|
|
goodsDescMapper.insert(goodsDesc);
|
|
|
-
|
|
|
- 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);
|
|
|
+ for (GoodsType item : goodsTypes) {
|
|
|
+ GoodsTypeDesc goodsTypeDes = new GoodsTypeDesc();
|
|
|
+ goodsTypeDes.setGoodsId(goodsDesc.getId());
|
|
|
+ goodsTypeDes.setGoodsTypeId(item.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());
|
|
|
@@ -552,93 +607,111 @@ public class GoodsDescServiceImpl extends ServiceImpl<GoodsDescMapper, GoodsDesc
|
|
|
goodsDescMapper.updateById(goodsDesc);
|
|
|
}
|
|
|
}
|
|
|
- });
|
|
|
+ }
|
|
|
return R.success("ok");
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public R importGoodsInfo(List<GoodsInfoExcel> data, Boolean isCovered) {
|
|
|
if (org.springframework.util.CollectionUtils.isEmpty(data)) {
|
|
|
throw new SecurityException("导入数据不能为空");
|
|
|
}
|
|
|
|
|
|
+ String type = data.stream().map(GoodsInfoExcel::getType).distinct().collect(Collectors.joining(","));
|
|
|
+ List<GoodsType> goodsTypeList = goodsTypeMapper.selectList(new LambdaQueryWrapper<GoodsType>()
|
|
|
+ .eq(GoodsType::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(GoodsType::getIsDeleted, 0)
|
|
|
+ .apply("find_in_set(cname,'" + type + "')"));
|
|
|
+ if (goodsTypeList.isEmpty()) {
|
|
|
+ throw new RuntimeException("未查到分类信息");
|
|
|
+ }
|
|
|
for (int i = 0; i < data.size(); i++) {
|
|
|
GoodsInfoExcel goodsExcel = data.get(i);
|
|
|
- String type = goodsExcel.getType();
|
|
|
- GoodsType goodsType = goodsTypeMapper.selectGoodsTypeCname(type, AuthUtil.getTenantId(), null);
|
|
|
- if (goodsType == null) {
|
|
|
+ List<GoodsType> goodsTypes = goodsTypeList.stream().filter(e -> goodsExcel.getType().contains(e.getCname())).collect(Collectors.toList());
|
|
|
+ if (goodsTypes.isEmpty()) {
|
|
|
throw new SecurityException("第" + (i + 1) + "行未添加分类或者分类不存在");
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ List<CorpsDesc> corpsDescList = corpsDescMapper.selectList(new LambdaQueryWrapper<CorpsDesc>()
|
|
|
+ .eq(CorpsDesc::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(CorpsDesc::getIsDeleted, 0)
|
|
|
+ .eq(CorpsDesc::getCorpType, "GYS"));
|
|
|
data.forEach(e -> {
|
|
|
- String type = e.getType();
|
|
|
- GoodsType goodsType = goodsTypeMapper.selectGoodsTypeCname(type, AuthUtil.getTenantId(), null);
|
|
|
- if (goodsType != null) {
|
|
|
- GoodsDesc goodsDesc = new GoodsDesc();
|
|
|
- BeanUtils.copyProperties(e, goodsDesc);
|
|
|
+ List<GoodsType> goodsTypes = goodsTypeList.stream().filter(i -> e.getType().contains(i.getCname())).collect(Collectors.toList());
|
|
|
+ GoodsDesc goodsDesc = new GoodsDesc();
|
|
|
+ BeanUtils.copyProperties(e, goodsDesc);
|
|
|
|
|
|
- if (StringUtil.isBlank(goodsDesc.getCnameInt())) {
|
|
|
- goodsDesc.setCnameInt(getCnameInt(goodsDesc.getCname()));
|
|
|
- }
|
|
|
+ if (StringUtil.isBlank(goodsDesc.getCnameInt())) {
|
|
|
+ goodsDesc.setCnameInt(getCnameInt(goodsDesc.getCname()));
|
|
|
+ }
|
|
|
|
|
|
- R<CorpsDesc> corpByName = corpsDescClient.getCorpByName(e.getCorpName(), AuthUtil.getTenantId());
|
|
|
- if (corpByName.isSuccess() && corpByName.getData() != null) {
|
|
|
- goodsDesc.setCorpName(e.getCorpName());
|
|
|
- goodsDesc.setCorpId(corpByName.getData().getId());
|
|
|
+ CorpsDesc corpByName = corpsDescList.stream().filter(i -> i.getCname().equals(e.getCorpName())).findFirst().orElse(null);
|
|
|
+ if (corpByName != null) {
|
|
|
+ goodsDesc.setCorpName(corpByName.getCname());
|
|
|
+ goodsDesc.setCorpId(corpByName.getId());
|
|
|
+ } else {
|
|
|
+ throw new SecurityException("请输入正确的供应商");
|
|
|
+ }
|
|
|
+ if (StringUtil.isNotBlank(e.getArtsVisionName())) {
|
|
|
+ CorpsDesc company = corpsDescMapper.selectOne(new LambdaQueryWrapper<CorpsDesc>()
|
|
|
+ .eq(CorpsDesc::getCname, e.getArtsVisionName())
|
|
|
+ .like(CorpsDesc::getCorpType, "GS")
|
|
|
+ .eq(CorpsDesc::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(CorpsDesc::getIsDeleted, 0)
|
|
|
+ );
|
|
|
+ if (ObjectUtil.isNotEmpty(company)) {
|
|
|
+ goodsDesc.setArtsVision(String.valueOf(company.getId()));
|
|
|
} else {
|
|
|
- throw new SecurityException("请输入正确的供应商");
|
|
|
+ throw new SecurityException("请输入正确的所属公司");
|
|
|
}
|
|
|
- if (StringUtil.isNotBlank(e.getArtsVisionName())) {
|
|
|
- CorpsDesc company = corpsDescMapper.selectOne(new LambdaQueryWrapper<CorpsDesc>()
|
|
|
- .eq(CorpsDesc::getCname, e.getArtsVisionName())
|
|
|
- .like(CorpsDesc::getCorpType, "GS")
|
|
|
- .eq(CorpsDesc::getTenantId, AuthUtil.getTenantId())
|
|
|
- .eq(CorpsDesc::getIsDeleted, 0)
|
|
|
- );
|
|
|
- if (ObjectUtil.isNotEmpty(company)) {
|
|
|
- goodsDesc.setArtsVision(String.valueOf(company.getId()));
|
|
|
- } else {
|
|
|
- throw new SecurityException("请输入正确的所属公司");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 获取供应商
|
|
|
- goodsDesc.setTypeno(e.getTypeNo());
|
|
|
- goodsDesc.setCntrVolumn(e.getCntrVolumn());
|
|
|
- goodsDesc.setCartonWeight(e.getCartonWeight());
|
|
|
- goodsDesc.setUnit(e.getUnit());
|
|
|
- goodsDesc.setSize(e.getSize());
|
|
|
- goodsDesc.setType(0L);
|
|
|
- goodsDesc.setGoodsTypeId(String.valueOf(goodsType.getId()));
|
|
|
- // 如果名称相等 就认为重复
|
|
|
- LambdaQueryWrapper<GoodsDesc> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
- queryWrapper.eq(GoodsDesc::getTenantId, AuthUtil.getTenantId());
|
|
|
- queryWrapper.eq(GoodsDesc::getCode, goodsDesc.getCode());
|
|
|
- queryWrapper.eq(GoodsDesc::getIsDeleted, 0);
|
|
|
- GoodsDesc one = goodsDescMapper.selectOne(queryWrapper);
|
|
|
-
|
|
|
- if (one == null) {
|
|
|
- goodsDesc.setIntegralMultiples(new BigDecimal(StringUtils.isBlank(e.getIntegralMultiples()) ? "0" : e.getIntegralMultiples()));
|
|
|
- goodsDesc.setCreateTime(new Date());
|
|
|
- goodsDesc.setCreateUser(AuthUtil.getUserId());
|
|
|
- goodsDesc.setCreateDept(Long.valueOf(AuthUtil.getDeptId()));
|
|
|
- goodsDescMapper.insert(goodsDesc);
|
|
|
+ }
|
|
|
|
|
|
+ // 获取供应商
|
|
|
+ goodsDesc.setTypeno(e.getTypeNo());
|
|
|
+ goodsDesc.setCntrVolumn(e.getCntrVolumn());
|
|
|
+ goodsDesc.setCartonWeight(e.getCartonWeight());
|
|
|
+ goodsDesc.setUnit(e.getUnit());
|
|
|
+ goodsDesc.setSize(e.getSize());
|
|
|
+ goodsDesc.setType(0L);
|
|
|
+ StringBuilder typeIds = new StringBuilder();
|
|
|
+ List<Long> typeIdList = goodsTypes.stream().map(GoodsType::getId).distinct().collect(Collectors.toList());
|
|
|
+ for (Long id : typeIdList) {
|
|
|
+ typeIds.append(id).append(",");
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isNotNull(typeIds.toString())) {
|
|
|
+ typeIds = new StringBuilder(typeIds.substring(0, typeIds.length() - 1));
|
|
|
+ }
|
|
|
+ goodsDesc.setGoodsTypeId(typeIds.toString());
|
|
|
+ // 如果名称相等 就认为重复
|
|
|
+ LambdaQueryWrapper<GoodsDesc> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(GoodsDesc::getTenantId, AuthUtil.getTenantId());
|
|
|
+ queryWrapper.eq(GoodsDesc::getCode, goodsDesc.getCode());
|
|
|
+ queryWrapper.eq(GoodsDesc::getIsDeleted, 0);
|
|
|
+ GoodsDesc one = goodsDescMapper.selectOne(queryWrapper);
|
|
|
+
|
|
|
+ if (one == null) {
|
|
|
+ goodsDesc.setIntegralMultiples(new BigDecimal(StringUtils.isBlank(e.getIntegralMultiples()) ? "0" : e.getIntegralMultiples()));
|
|
|
+ goodsDesc.setCreateTime(new Date());
|
|
|
+ goodsDesc.setCreateUser(AuthUtil.getUserId());
|
|
|
+ goodsDesc.setCreateDept(Long.valueOf(AuthUtil.getDeptId()));
|
|
|
+ goodsDescMapper.insert(goodsDesc);
|
|
|
+
|
|
|
+ for (GoodsType item : goodsTypes) {
|
|
|
GoodsTypeDesc goodsTypeDes = new GoodsTypeDesc();
|
|
|
goodsTypeDes.setGoodsId(goodsDesc.getId());
|
|
|
- goodsTypeDes.setGoodsTypeId(goodsType.getId());
|
|
|
+ goodsTypeDes.setGoodsTypeId(item.getId());
|
|
|
goodsTypeDes.setCreateTime(new Date());
|
|
|
goodsTypeDes.setCreateUser(AuthUtil.getUserId());
|
|
|
goodsTypeDes.setCreateDept(Long.valueOf(AuthUtil.getDeptId()));
|
|
|
goodsTypeDescMapper.insert(goodsTypeDes);
|
|
|
- } else {
|
|
|
- goodsDesc.setIntegralMultiples(new BigDecimal(StringUtils.isBlank(e.getIntegralMultiples()) ? "0" : e.getIntegralMultiples()));
|
|
|
- goodsDesc.setId(one.getId());
|
|
|
- goodsDesc.setUpdateTime(new Date());
|
|
|
- goodsDesc.setUpdateUser(AuthUtil.getUserId());
|
|
|
- goodsDescMapper.updateById(goodsDesc);
|
|
|
}
|
|
|
+ } else {
|
|
|
+ goodsDesc.setIntegralMultiples(new BigDecimal(StringUtils.isBlank(e.getIntegralMultiples()) ? "0" : e.getIntegralMultiples()));
|
|
|
+ goodsDesc.setId(one.getId());
|
|
|
+ goodsDesc.setUpdateTime(new Date());
|
|
|
+ goodsDesc.setUpdateUser(AuthUtil.getUserId());
|
|
|
+ goodsDescMapper.updateById(goodsDesc);
|
|
|
}
|
|
|
});
|
|
|
return R.success("ok");
|
|
|
@@ -696,7 +769,6 @@ public class GoodsDescServiceImpl extends ServiceImpl<GoodsDescMapper, GoodsDesc
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- @GlobalTransactional(rollbackFor = Exception.class, timeoutMills = 12000000)
|
|
|
public void modifyParts(GoodsDescDto goodsDescDto) {
|
|
|
LambdaQueryWrapper<GoodsDesc> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
lambdaQueryWrapper.eq(GoodsDesc::getType, 0);
|
|
|
@@ -783,6 +855,7 @@ public class GoodsDescServiceImpl extends ServiceImpl<GoodsDescMapper, GoodsDesc
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public R importDescPartsInfo(List<GoodsInfoPartsExcel> excelList, boolean b) {
|
|
|
if (ObjectUtils.isNull(excelList)) {
|
|
|
throw new SecurityException("导入数据不能为空");
|
|
|
@@ -900,13 +973,13 @@ public class GoodsDescServiceImpl extends ServiceImpl<GoodsDescMapper, GoodsDesc
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- @Transactional
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public R importCorp(List<GoodsImportExcel> excelList) {
|
|
|
List<GoodsDesc> goodsDescList = new ArrayList<>();
|
|
|
String adminProfilesName = excelList.stream().map(GoodsImportExcel::getSupervisorUserNameGroup).distinct().collect(Collectors.joining(","));
|
|
|
String userIds = userClient.selectUserByNames(adminProfilesName);
|
|
|
List<User> userList = new ArrayList<>();
|
|
|
- if (ObjectUtils.isNotNull(userIds)){
|
|
|
+ if (ObjectUtils.isNotNull(userIds)) {
|
|
|
userList = userClient.selectUserList(userIds);
|
|
|
}
|
|
|
for (GoodsImportExcel item : excelList) {
|