|
@@ -17,6 +17,7 @@ import com.platform.dao.dto.sqarepartmanage.SparePartInfoDTO;
|
|
|
import com.platform.dao.dto.sqarepartmanage.SparePartUsedDTO;
|
|
|
import com.platform.dao.dto.store.InStoreFormDTO;
|
|
|
import com.platform.dao.entity.check.CheckJob;
|
|
|
+import com.platform.dao.entity.sb.SbInfo;
|
|
|
import com.platform.dao.entity.sb.SbModel;
|
|
|
import com.platform.dao.entity.sb.SbModelSpareBom;
|
|
|
import com.platform.dao.entity.sqarepartmanage.SparePartInfo;
|
|
@@ -66,6 +67,9 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
import tk.mybatis.mapper.weekend.Weekend;
|
|
|
import tk.mybatis.mapper.weekend.WeekendCriteria;
|
|
|
|
|
|
+import javax.persistence.Id;
|
|
|
+import java.lang.annotation.Annotation;
|
|
|
+import java.lang.reflect.Field;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
@@ -1128,6 +1132,29 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
|
|
|
throw new BusinessException(e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
+ private List<String> getSbNos(String str){
|
|
|
+ List<String> list = new ArrayList<>();
|
|
|
+ if (StringUtils.isNotBlank(str)){
|
|
|
+ list = Arrays.asList( str.trim().split(";"));
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setKey2(SbModelSpareBom t) {
|
|
|
+ Field[] fields = t.getClass().getDeclaredFields();
|
|
|
+ for (Field field : fields) {
|
|
|
+ Annotation id = field.getAnnotation(Id.class);
|
|
|
+ if (id == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ field.setAccessible(true);
|
|
|
+ field.set(t, IdGeneratorUtils.getObjectId());
|
|
|
+ } catch (IllegalAccessException e) {
|
|
|
+ log.error("主键赋值异常");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
|
public String importListByUpdate(MultipartFile file) {
|
|
@@ -1139,6 +1166,35 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
|
|
|
if (!CollectionUtils.isEmpty(items)) {
|
|
|
List<SpareType> typeList = spareTypeMapper.selectAll();
|
|
|
for (SparePartInfoVO item : items) {
|
|
|
+ //先删除当前备件的所有bom,再新增excel导入的bom
|
|
|
+ SbModelSpareBom bom = new SbModelSpareBom();
|
|
|
+ bom.setSpareId(item.getSpareId());
|
|
|
+ sbModelSpareBomMapper.delete(bom);
|
|
|
+ List<String> sbNos = new ArrayList<>();
|
|
|
+ if (item.getSbNo()!=null){
|
|
|
+ sbNos = getSbNos(item.getSbNo());
|
|
|
+ }
|
|
|
+ if (sbNos.size()>0) {
|
|
|
+ Weekend<SbInfo> weekend = new Weekend<>(SbInfo.class);
|
|
|
+ WeekendCriteria<SbInfo, Object> weekendCriteria = weekend.weekendCriteria();
|
|
|
+ weekendCriteria.andIn(SbInfo::getNo, sbNos);
|
|
|
+ List<SbInfo> sbinfos = sbInfoMapper.selectByExample(weekend);
|
|
|
+ List<SbModelSpareBom> boms = new ArrayList<>();
|
|
|
+ for (SbInfo info : sbinfos) {
|
|
|
+ bom = new SbModelSpareBom();
|
|
|
+ bom.setSpareId(item.getId());
|
|
|
+ bom.setSbId(info.getId());
|
|
|
+ setKey2(bom);
|
|
|
+ bom.setCreatedTime(LocalDateTime.now());
|
|
|
+ bom.setCreatedUserId(SecurityUtils.getUserInfo().getUserId());
|
|
|
+ bom.setUpdateTime(LocalDateTime.now());
|
|
|
+ bom.setUpdateUserId(SecurityUtils.getUserInfo().getUserId());
|
|
|
+ bom.setCreatedUserName(SecurityUtils.getUserInfo().getUsername());
|
|
|
+ bom.setUpdateUserName(SecurityUtils.getUserInfo().getUsername());
|
|
|
+ boms.add(bom);
|
|
|
+ }
|
|
|
+ sbModelSpareBomMapper.insertListforComplex(boms);
|
|
|
+ }
|
|
|
// 设置类型转换
|
|
|
for (SpareType type : typeList) {
|
|
|
if (type.getName().equals(item.getTypeName())) {
|