|
@@ -6,6 +6,7 @@ import com.rongwei.bscommon.sys.dao.CommonDao;
|
|
|
import com.rongwei.bscommon.sys.dao.EquWarrantyProviderMapperDao;
|
|
|
import com.rongwei.bscommon.sys.service.EquWarrantyProviderService;
|
|
|
import com.rongwei.bscommon.sys.utils.ExcelUtils;
|
|
|
+import com.rongwei.bscommon.sys.utils.ExceptionUtils;
|
|
|
import com.rongwei.bscommon.sys.utils.StringUtil;
|
|
|
import com.rongwei.bsentity.domain.EquWarrantyProviderDo;
|
|
|
import com.rongwei.rwadmincommon.system.domain.*;
|
|
@@ -47,6 +48,7 @@ public class EquWarrantyProviderServiceImpl extends ServiceImpl<EquWarrantyProvi
|
|
|
@Override
|
|
|
public R importEquWarrantyProvider(MultipartFile file) {
|
|
|
try {
|
|
|
+ StringBuilder allStrBuilder = new StringBuilder();
|
|
|
Sheet sheet = new XSSFWorkbook(file.getInputStream()).getSheetAt(0);
|
|
|
StringBuilder stringBuilder = new StringBuilder();
|
|
|
int lastRowNum = sheet.getLastRowNum();
|
|
@@ -74,11 +76,9 @@ public class EquWarrantyProviderServiceImpl extends ServiceImpl<EquWarrantyProvi
|
|
|
if (StringUtils.isNotBlank(code)){
|
|
|
code = StringUtil.formatDecimal(code);
|
|
|
}else {
|
|
|
- stringBuilder.append("第").append(i+1).append("行");
|
|
|
stringBuilder.append("保修商编号不能为空");
|
|
|
}
|
|
|
if (StringUtils.isBlank(name)){
|
|
|
- stringBuilder.append("第").append(i+1).append("行");
|
|
|
stringBuilder.append("保修商名称不能为空");
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(zuscc)){
|
|
@@ -87,7 +87,6 @@ public class EquWarrantyProviderServiceImpl extends ServiceImpl<EquWarrantyProvi
|
|
|
zuscc = formatAccount.setScale(0,BigDecimal.ROUND_HALF_UP).toPlainString();
|
|
|
}
|
|
|
}else {
|
|
|
- stringBuilder.append("第").append(i+1).append("行");
|
|
|
stringBuilder.append("统一社会信用代码不能为空");
|
|
|
}
|
|
|
boolean containFactory = factorys.contains(factory);
|
|
@@ -104,11 +103,9 @@ public class EquWarrantyProviderServiceImpl extends ServiceImpl<EquWarrantyProvi
|
|
|
}
|
|
|
if (containFactory){
|
|
|
if (containName){
|
|
|
- stringBuilder.append("第").append(i+1).append("行");
|
|
|
stringBuilder.append("表格中当前工厂下已存在该名称,不可重复录入");
|
|
|
}
|
|
|
if (containZuscc){
|
|
|
- stringBuilder.append("第").append(i+1).append("行");
|
|
|
stringBuilder.append("表格中当前工厂下已存在该统一社会信用代码,不可重复录入");
|
|
|
}
|
|
|
}
|
|
@@ -125,7 +122,6 @@ public class EquWarrantyProviderServiceImpl extends ServiceImpl<EquWarrantyProvi
|
|
|
if (StringUtils.isNotBlank(factory)){
|
|
|
factoryId = commonDao.getIdByFactoryName(factory);
|
|
|
if (StringUtil.isBlank(factoryId)){
|
|
|
- stringBuilder.append("第").append(i+1).append("行");
|
|
|
stringBuilder.append("所属工厂填写有误");
|
|
|
}
|
|
|
//当前用户所属工厂、【保修商名称】作唯一校验
|
|
@@ -133,7 +129,6 @@ public class EquWarrantyProviderServiceImpl extends ServiceImpl<EquWarrantyProvi
|
|
|
QueryWrapper<EquWarrantyProviderDo> entity = new QueryWrapper<EquWarrantyProviderDo>().eq("DELETED", 0).eq("WARRANTYPROVIDER",name).eq("TENANTID",factoryId).last("limit 1");
|
|
|
EquWarrantyProviderDo providerNameDo = equWarrantyProviderService.getOne(entity);
|
|
|
if (providerNameDo!= null){
|
|
|
- stringBuilder.append("第").append(i+1).append("行");
|
|
|
stringBuilder.append(String.format("在%s中%s已存在,不可重复导入",factory,name));
|
|
|
}
|
|
|
}
|
|
@@ -142,37 +137,36 @@ public class EquWarrantyProviderServiceImpl extends ServiceImpl<EquWarrantyProvi
|
|
|
QueryWrapper<EquWarrantyProviderDo> entity = new QueryWrapper<EquWarrantyProviderDo>().eq("DELETED", 0).eq("ZUSCC",zuscc).eq("TENANTID",factoryId).last("limit 1");
|
|
|
EquWarrantyProviderDo providerZusccDo = equWarrantyProviderService.getOne(entity);
|
|
|
if (providerZusccDo!= null){
|
|
|
- stringBuilder.append("第").append(i+1).append("行");
|
|
|
stringBuilder.append(String.format("在%s中%s保修商已存在,不可重复导入",factory,zuscc));
|
|
|
}
|
|
|
}
|
|
|
}else {
|
|
|
- stringBuilder.append("第").append(i+1).append("行");
|
|
|
stringBuilder.append("所属工厂不能为空");
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(dept)){
|
|
|
deptId = commonDao.getIdByFactoryIdAndDept(factoryId,dept);
|
|
|
}
|
|
|
- equWarrantyProviderDo.setId(SecurityUtil.getUUID());
|
|
|
- equWarrantyProviderDo.setWarrantyprovidercode(code);
|
|
|
- equWarrantyProviderDo.setWarrantyprovider(name);
|
|
|
- equWarrantyProviderDo.setZuscc(zuscc);
|
|
|
- equWarrantyProviderDo.setLegalperson(legal);
|
|
|
- equWarrantyProviderDo.setIsprivatelyoperated(isPrivately);
|
|
|
- equWarrantyProviderDo.setPrimarycontact(mainContacts);
|
|
|
- equWarrantyProviderDo.setContactphone(phone);
|
|
|
- equWarrantyProviderDo.setTenantid(factoryId);
|
|
|
- equWarrantyProviderDo.setBelongfactory(factory);
|
|
|
- equWarrantyProviderDo.setManagedepartmentid(deptId);
|
|
|
- equWarrantyProviderDo.setManagedepartment(dept);
|
|
|
- equWarrantyProviderDo.setEnablestate("10");
|
|
|
- equWarrantyProviderDo.setClassify("10");
|
|
|
- equWarrantyProviderDos.add(equWarrantyProviderDo);
|
|
|
- if(StringUtil.isNotBlank(stringBuilder)){
|
|
|
- stringBuilder.append("<br>");
|
|
|
+ if (StringUtil.isNotBlank(stringBuilder)) {
|
|
|
+ allStrBuilder.append("第").append(i + 1).append("行").append(stringBuilder).append("<br>");
|
|
|
+ }else {
|
|
|
+ equWarrantyProviderDo.setId(SecurityUtil.getUUID())
|
|
|
+ .setWarrantyprovidercode(code)
|
|
|
+ .setWarrantyprovider(name)
|
|
|
+ .setZuscc(zuscc)
|
|
|
+ .setLegalperson(legal)
|
|
|
+ .setIsprivatelyoperated(isPrivately)
|
|
|
+ .setPrimarycontact(mainContacts)
|
|
|
+ .setContactphone(phone)
|
|
|
+ .setTenantid(factoryId)
|
|
|
+ .setBelongfactory(factory)
|
|
|
+ .setManagedepartmentid(deptId)
|
|
|
+ .setManagedepartment(dept)
|
|
|
+ .setEnablestate("10")
|
|
|
+ .setClassify("10");
|
|
|
+ equWarrantyProviderDos.add(equWarrantyProviderDo);
|
|
|
}
|
|
|
}
|
|
|
- String errMsg = stringBuilder.toString();
|
|
|
+ String errMsg = allStrBuilder.toString();
|
|
|
if (StringUtils.isNotBlank(errMsg)){
|
|
|
return R.error(errMsg);
|
|
|
}else {
|
|
@@ -181,7 +175,7 @@ public class EquWarrantyProviderServiceImpl extends ServiceImpl<EquWarrantyProvi
|
|
|
}
|
|
|
}
|
|
|
} catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
+ ExceptionUtils.printExceptionDetail(e,"保修商导入异常");
|
|
|
}
|
|
|
return R.ok();
|
|
|
}
|