| | |
| | | package com.by4cloud.platformx.business.service.impl; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.by4cloud.platformx.admin.api.entity.SysDept; |
| | | import com.by4cloud.platformx.admin.api.vo.DeptExcelVO; |
| | | import com.by4cloud.platformx.business.dto.ContractSubjectMatterAddDTO; |
| | | import com.by4cloud.platformx.business.entity.ContractSubjectMatter; |
| | | import com.by4cloud.platformx.business.entity.Product; |
| | | import com.by4cloud.platformx.business.mapper.ContractSubjectMatterMapper; |
| | | import com.by4cloud.platformx.business.mapper.ProductMapper; |
| | | import com.by4cloud.platformx.business.service.ContractSubjectMatterService; |
| | | import com.by4cloud.platformx.business.vo.ContractSubjectMatterVo; |
| | | import com.by4cloud.platformx.business.vo.SubjectMatterExcelVO; |
| | | import com.by4cloud.platformx.common.core.util.R; |
| | | import com.by4cloud.platformx.common.data.datascope.DataScope; |
| | | import com.by4cloud.platformx.common.data.mybatis.BaseModel; |
| | | import com.by4cloud.platformx.common.excel.vo.ErrorMessage; |
| | | import com.by4cloud.platformx.common.security.util.SecurityUtils; |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.validation.BindingResult; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | /** |
| | | * 合同标的物明细表 |
| | |
| | | * @date 2026-04-29 16:39:29 |
| | | */ |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | public class ContractSubjectMatterServiceImpl extends ServiceImpl<ContractSubjectMatterMapper, ContractSubjectMatter> implements ContractSubjectMatterService { |
| | | |
| | | private final ProductMapper productMapper; |
| | | |
| | | @Override |
| | | public R selectSubjectMatterProcess(Long id) { |
| | | MPJLambdaWrapper<ContractSubjectMatter> wrapper = new MPJLambdaWrapper<ContractSubjectMatter>() |
| | |
| | | return R.ok(baseMapper.selectListByScope(Wrappers.<ContractSubjectMatter>lambdaQuery().eq(ContractSubjectMatter::getContractId,contractId) |
| | | .orderByAsc(ContractSubjectMatter::getCreateTime), DataScope.of("comp_id"))); |
| | | } |
| | | |
| | | @Override |
| | | public R importSubjectMatter(List<SubjectMatterExcelVO> excelVOList, BindingResult bindingResult) { |
| | | List<ErrorMessage> errorMessageList = (List<ErrorMessage>) bindingResult.getTarget(); |
| | | List<ContractSubjectMatterAddDTO> addDTOList = new ArrayList<>(); |
| | | for (SubjectMatterExcelVO item : excelVOList) { |
| | | Set<String> errorMsg = new HashSet<>(); |
| | | |
| | | Product one = productMapper.selectOne(Wrappers.<Product>lambdaQuery() |
| | | .eq(Product::getErpCode, item.getMaterialCode()) |
| | | .eq(Product::getCompId, SecurityUtils.getUser().getCompId())); |
| | | |
| | | if (one == null) { |
| | | errorMsg.add(item.getMaterialCode()+"erp编码不存在"); |
| | | } |
| | | if (CollUtil.isEmpty(errorMsg)) { |
| | | ContractSubjectMatterAddDTO addDTO = new ContractSubjectMatterAddDTO(); |
| | | addDTO.setMaterialCode(item.getMaterialCode()); |
| | | addDTO.setMaterialInternalName(one.getProductName()); |
| | | addDTO.setMaterialName(item.getMaterialName()); |
| | | addDTO.setUnitPrice(item.getUnitPrice()); |
| | | addDTO.setQuantity(item.getQuantity()); |
| | | addDTO.setSpecification(one.getProductType()); |
| | | addDTOList.add(addDTO); |
| | | } |
| | | else { |
| | | // 数据不合法情况 |
| | | errorMessageList.add(new ErrorMessage(item.getLineNum(), errorMsg)); |
| | | } |
| | | } |
| | | if (CollUtil.isNotEmpty(errorMessageList)) { |
| | | return R.failed(errorMessageList,"部门导入失败"); |
| | | } |
| | | return R.ok(addDTOList, "部门导入成功"); |
| | | } |
| | | |
| | | |
| | | } |