|
@@ -11,8 +11,7 @@ import com.ktg.common.core.text.Convert;
|
|
|
import com.ktg.common.exception.ServiceException;
|
|
import com.ktg.common.exception.ServiceException;
|
|
|
import com.ktg.common.utils.DateUtils;
|
|
import com.ktg.common.utils.DateUtils;
|
|
|
import com.ktg.common.utils.bean.BeanUtils;
|
|
import com.ktg.common.utils.bean.BeanUtils;
|
|
|
-import com.ktg.iscs.domain.IsMaterials;
|
|
|
|
|
-import com.ktg.iscs.domain.IsMaterialsType;
|
|
|
|
|
|
|
+import com.ktg.iscs.domain.*;
|
|
|
import com.ktg.iscs.domain.dto.materials.LoanMaterialDTO;
|
|
import com.ktg.iscs.domain.dto.materials.LoanMaterialDTO;
|
|
|
import com.ktg.iscs.domain.dto.materials.MaterialBindingDTO;
|
|
import com.ktg.iscs.domain.dto.materials.MaterialBindingDTO;
|
|
|
import com.ktg.iscs.domain.dto.materials.MaterialsPageDTO;
|
|
import com.ktg.iscs.domain.dto.materials.MaterialsPageDTO;
|
|
@@ -22,9 +21,7 @@ import com.ktg.iscs.domain.vo.materials.ImportMaterialsVO;
|
|
|
import com.ktg.iscs.domain.vo.materials.MaterialsPageVO;
|
|
import com.ktg.iscs.domain.vo.materials.MaterialsPageVO;
|
|
|
import com.ktg.iscs.domain.vo.materials.PropertyVO;
|
|
import com.ktg.iscs.domain.vo.materials.PropertyVO;
|
|
|
import com.ktg.iscs.mapper.IsMaterialsMapper;
|
|
import com.ktg.iscs.mapper.IsMaterialsMapper;
|
|
|
-import com.ktg.iscs.service.IIsMaterialsLoanService;
|
|
|
|
|
-import com.ktg.iscs.service.IIsMaterialsService;
|
|
|
|
|
-import com.ktg.iscs.service.IIsMaterialsTypeService;
|
|
|
|
|
|
|
+import com.ktg.iscs.service.*;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -48,6 +45,12 @@ public class IsMaterialsServiceImpl extends ServiceImpl<IsMaterialsMapper, IsMat
|
|
|
private IIsMaterialsLoanService iIsMaterialsLoanService;
|
|
private IIsMaterialsLoanService iIsMaterialsLoanService;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private IIsMaterialsTypeService iIsMaterialsTypeService;
|
|
private IIsMaterialsTypeService iIsMaterialsTypeService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IIsMaterialsCabinetService iIsMaterialsCabinetService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IIsMaterialsPropertyService iIsMaterialsPropertyService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IIsMaterialsPropertyValueService iIsMaterialsPropertyValueService;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 查询物资
|
|
* 查询物资
|
|
@@ -190,7 +193,7 @@ public class IsMaterialsServiceImpl extends ServiceImpl<IsMaterialsMapper, IsMat
|
|
|
|
|
|
|
|
@Transactional
|
|
@Transactional
|
|
|
@Override
|
|
@Override
|
|
|
- public String importMaterials(List<ImportMaterialsVO> itemList, boolean updateSupport, String operName) {
|
|
|
|
|
|
|
+ public String importMaterials(List<ImportMaterialsVO> itemList, boolean updateSupport, String operName) throws JsonProcessingException {
|
|
|
Assert.notNull(itemList, "导入物资数据不能为空!");
|
|
Assert.notNull(itemList, "导入物资数据不能为空!");
|
|
|
int successNum = 0;
|
|
int successNum = 0;
|
|
|
int failureNum = 0;
|
|
int failureNum = 0;
|
|
@@ -205,7 +208,7 @@ public class IsMaterialsServiceImpl extends ServiceImpl<IsMaterialsMapper, IsMat
|
|
|
// 2.-----------------检查物资名称不能为空-------------------------------
|
|
// 2.-----------------检查物资名称不能为空-------------------------------
|
|
|
if (StringUtils.isBlank(materials.getMaterialsName())) {
|
|
if (StringUtils.isBlank(materials.getMaterialsName())) {
|
|
|
result = false;
|
|
result = false;
|
|
|
- failureMsg.append("<br/>" + failureNum + "、物资名称 " + materials.getMaterialsName() + " 不能为空");
|
|
|
|
|
|
|
+ failureMsg.append("<br/>" + failureNum + "、物资名称 :" + materials.getMaterialsName() + " 不能为空");
|
|
|
}
|
|
}
|
|
|
// 3.-----------------检查物资类型不能为空-------------------------------
|
|
// 3.-----------------检查物资类型不能为空-------------------------------
|
|
|
if (StringUtils.isNotBlank(materials.getMaterialsTypeName())) {
|
|
if (StringUtils.isNotBlank(materials.getMaterialsTypeName())) {
|
|
@@ -214,13 +217,13 @@ public class IsMaterialsServiceImpl extends ServiceImpl<IsMaterialsMapper, IsMat
|
|
|
.eq(IsMaterialsType::getMaterialsTypeName, materials.getMaterialsTypeName()));
|
|
.eq(IsMaterialsType::getMaterialsTypeName, materials.getMaterialsTypeName()));
|
|
|
if (materialsTypelist.isEmpty()) {
|
|
if (materialsTypelist.isEmpty()) {
|
|
|
result = false;
|
|
result = false;
|
|
|
- failureMsg.append("<br/>" + failureNum + "、物资分类 " + materials.getMaterialsName() + " 系统中无该物资类型");
|
|
|
|
|
|
|
+ failureMsg.append("<br/>" + failureNum + "、物资分类 :" + materials.getMaterialsTypeName() + " 系统中无该物资类型");
|
|
|
} else {
|
|
} else {
|
|
|
materialsTypeId = materialsTypelist.get(0).getMaterialsTypeId();
|
|
materialsTypeId = materialsTypelist.get(0).getMaterialsTypeId();
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
result = false;
|
|
result = false;
|
|
|
- failureMsg.append("<br/>" + failureNum + "、物资分类 " + materials.getMaterialsName() + " 不能为空");
|
|
|
|
|
|
|
+ failureMsg.append("<br/>" + failureNum + "、物资分类 :" + materials.getMaterialsName() + " 的物资分类不能为空");
|
|
|
}
|
|
}
|
|
|
// 4.---------------------检查rfid是否填写------------------------------
|
|
// 4.---------------------检查rfid是否填写------------------------------
|
|
|
if (StringUtils.isNotBlank(materials.getMaterialsRfid())) {
|
|
if (StringUtils.isNotBlank(materials.getMaterialsRfid())) {
|
|
@@ -229,11 +232,36 @@ public class IsMaterialsServiceImpl extends ServiceImpl<IsMaterialsMapper, IsMat
|
|
|
.eq(IsMaterials::getMaterialsRfid, materials.getMaterialsRfid()));
|
|
.eq(IsMaterials::getMaterialsRfid, materials.getMaterialsRfid()));
|
|
|
if (!materialslist.isEmpty()) {
|
|
if (!materialslist.isEmpty()) {
|
|
|
result = false;
|
|
result = false;
|
|
|
- failureMsg.append("<br/>" + failureNum + "、物资RFID " + materials.getMaterialsRfid() + " 已被使用");
|
|
|
|
|
|
|
+ failureMsg.append("<br/>" + failureNum + "、物资RFID :" + materials.getMaterialsRfid() + " 已被使用");
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
result = false;
|
|
result = false;
|
|
|
- failureMsg.append("<br/>" + failureNum + "、物资RFID " + materials.getMaterialsName() + " 不能为空");
|
|
|
|
|
|
|
+ failureMsg.append("<br/>" + failureNum + "、物资RFID :" + materials.getMaterialsName() + " 的RFID不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ // 5.---------------------检查物资柜信息------------------------------
|
|
|
|
|
+ if (StringUtils.isNotBlank(materials.getCabinetName())) {
|
|
|
|
|
+ List<IsMaterialsCabinet> cabinets = iIsMaterialsCabinetService.list(Wrappers.<IsMaterialsCabinet>lambdaQuery()
|
|
|
|
|
+ .eq(IsMaterialsCabinet::getCabinetName, materials.getCabinetName()));
|
|
|
|
|
+ if (!cabinets.isEmpty()) {
|
|
|
|
|
+ materials.setMaterialsCabinetId(cabinets.get(0).getCabinetId());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ // 6.---------------------检查物资规格------------------------------
|
|
|
|
|
+ if (StringUtils.isNotBlank(materials.getValueName())) {
|
|
|
|
|
+ List<IsMaterialsPropertyValue> propertyValueList = iIsMaterialsPropertyValueService.list(Wrappers.<IsMaterialsPropertyValue>lambdaQuery()
|
|
|
|
|
+ .eq(IsMaterialsPropertyValue::getValueName, materials.getValueName()));
|
|
|
|
|
+ if (!propertyValueList.isEmpty()) {
|
|
|
|
|
+ IsMaterialsProperty property = iIsMaterialsPropertyService.getById(propertyValueList.get(0).getPropertyId());
|
|
|
|
|
+ PropertyVO propertyVO = new PropertyVO();
|
|
|
|
|
+ propertyVO.setPropertyId(String.valueOf(property.getPropertyId()));
|
|
|
|
|
+ propertyVO.setPropertyName(property.getPropertyName());
|
|
|
|
|
+ propertyVO.setRecordId(String.valueOf(propertyValueList.get(0).getRecordId()));
|
|
|
|
|
+ propertyVO.setValueName(propertyValueList.get(0).getValueName());
|
|
|
|
|
+ // 使用 ObjectMapper 将对象转换为 JSON 字符串
|
|
|
|
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
|
+ String jsonString = objectMapper.writeValueAsString(propertyVO);
|
|
|
|
|
+ materials.setProperties("[" + jsonString + "]");
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 开始做最后的插入操作
|
|
// 开始做最后的插入操作
|