| | |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.yuanchu.mom.mapper.SpecificationsMapper; |
| | | import com.yuanchu.mom.pojo.Specifications; |
| | | import com.yuanchu.mom.service.SpecificationsService; |
| | | import com.yuanchu.mom.mapper.*; |
| | | import com.yuanchu.mom.pojo.*; |
| | | import com.yuanchu.mom.pojo.dto.SpecificationsDto; |
| | | import com.yuanchu.mom.service.*; |
| | | import com.yuanchu.mom.utils.MyUtil; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @author Administrator |
| | |
| | | * @createDate 2023-07-26 16:01:49 |
| | | */ |
| | | @Service |
| | | public class SpecificationsServiceImpl extends ServiceImpl<SpecificationsMapper, Specifications> |
| | | implements SpecificationsService { |
| | | public class SpecificationsServiceImpl extends ServiceImpl<SpecificationsMapper, Specifications> implements SpecificationsService { |
| | | |
| | | @Resource |
| | | private SpecificationsMapper specificationsMapper; |
| | | MaterialMapper materialMapper; |
| | | |
| | | /** |
| | | * 检验模块-->OMS管理-->成品检验-->新增(需要规格型号的Id与名称) |
| | | */ |
| | | @Resource |
| | | SpecificationsMapper specificationsMapper; |
| | | |
| | | @Resource |
| | | TechnologyService technologyService; |
| | | |
| | | @Resource |
| | | TechnologyTemplateMapper technologyTemplateMapper; |
| | | |
| | | @Resource |
| | | ProductService productService; |
| | | |
| | | @Resource |
| | | TechnicalModelMapper technicalModelMapper; |
| | | |
| | | @Resource |
| | | MbomService mbomService; |
| | | |
| | | @Resource |
| | | MbomModelMapper mbomModelMapper; |
| | | |
| | | @Resource |
| | | TechniqueService techniqueService; |
| | | |
| | | @Resource |
| | | TechniqueModelMapper techniqueModelMapper; |
| | | |
| | | @Resource |
| | | DeviceMapper deviceMapper; |
| | | |
| | | //(4级)新增-->型号 |
| | | @Override |
| | | public List<Map<String, Object>> selectSpecificationIdAndName(Integer materialId) { |
| | | List<Map<String, Object>> maps = specificationsMapper.selectSpecificationIdAndName(materialId); |
| | | return maps; |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public String addSpecifications(SpecificationsDto specificationsDto) { |
| | | //校验添加该标准下的型号是否重复 |
| | | List<String> specificationsNameList = specificationsMapper.selectList(Wrappers.<Specifications>query().eq("standard_id", specificationsDto.getId())).stream().map(specifications -> { |
| | | String specificationsName = specifications.getName(); |
| | | return specificationsName; |
| | | }).collect(Collectors.toList()); |
| | | if (specificationsNameList.contains(specificationsDto.getSpecifications())){ |
| | | return "该标准下有该型号"; |
| | | } |
| | | /*新增型号表*/ |
| | | Specifications specifications = new Specifications(); |
| | | specifications.setStandardId(specificationsDto.getId()); |
| | | specifications.setName(specificationsDto.getSpecifications()); |
| | | specificationsMapper.insert(specifications); |
| | | /*新增标准BOM-->工艺路线(批量添加)*/ |
| | | //根据标准id查询物料大类 |
| | | Material material = materialMapper.selFath(specificationsDto.getId()); |
| | | Integer type = null; |
| | | if (material.getFather().equals("橡胶连接器")){ |
| | | type=0; |
| | | }else if (material.getFather().equals("金属连接器")){ |
| | | type=1; |
| | | }else if(material.getFather().equals("湿插拔电连接器")){ |
| | | type=2; |
| | | }else if(material.getFather().equals("分支组件")){ |
| | | type=3; |
| | | }else return "添加型号【" + specificationsDto.getSpecifications() + "】成功"; |
| | | List<TechnologyTemplate> technologyTemplateList = technologyTemplateMapper.selectList(Wrappers.<TechnologyTemplate>query().eq("type",type)); |
| | | List<Technology> technologyList = technologyTemplateList.stream().map(technologyTemplate -> { |
| | | Technology technology = new Technology(); |
| | | technology.setSpecificationsId(specifications.getId()); |
| | | technology.setFather(technologyTemplate.getFather()); |
| | | technology.setName(technologyTemplate.getName()); |
| | | technology.setDeviceGroup(technologyTemplate.getDeviceGroup()); |
| | | return technology; |
| | | }).collect(Collectors.toList()); |
| | | technologyService.saveBatch(technologyList); |
| | | /*新增标准BOM-->技术指标(批量添加)*/ |
| | | //新增的工艺路线id集合 |
| | | List<Integer> technologyIds = technologyList.stream().map(Technology::getId).collect(Collectors.toList()); |
| | | //基础数据中工艺路线id集合 |
| | | List<Integer> techTemIds = technologyTemplateList.stream().map(TechnologyTemplate::getId).collect(Collectors.toList()); |
| | | //两者长度一定一样 |
| | | List<Product> productList = new ArrayList<>(); |
| | | for (int i = 0; i < technologyIds.size(); i++) { |
| | | List<TechnicalModel> technicalModelList = technicalModelMapper.selectList(Wrappers.<TechnicalModel>query().eq("tech_tem_id", techTemIds.get(i))); |
| | | for (TechnicalModel technicalModel : technicalModelList) { |
| | | Product product = new Product(); |
| | | product.setFather(technicalModel.getFather()); |
| | | product.setName(technicalModel.getName()); |
| | | product.setUnit(technicalModel.getUnit()); |
| | | product.setTechnologyId(technologyIds.get(i)); |
| | | productList.add(product); |
| | | } |
| | | } |
| | | productService.saveBatch(productList); |
| | | /*新增标准BOM-->物料清单(批量添加)*/ |
| | | List<Mbom> mbomList = new ArrayList<>(); |
| | | for (int i = 0; i < technologyIds.size(); i++) { |
| | | List<MbomModel> mbomModelList = mbomModelMapper.selectList(Wrappers.<MbomModel>query().eq("tech_tem_id", techTemIds.get(i))); |
| | | for (MbomModel mbomModel : mbomModelList) { |
| | | Mbom mbom = new Mbom(); |
| | | mbom.setUnit(mbomModel.getUnit()); |
| | | mbom.setName(mbomModel.getName()); |
| | | mbom.setSupplier(mbomModel.getSupplier()); |
| | | mbom.setQualityTraceability(mbomModel.getQualityTraceability()); |
| | | mbom.setSpecifications(mbomModel.getSpecifications()); |
| | | mbom.setTechnologyId(technologyIds.get(i)); |
| | | mbomList.add(mbom); |
| | | } |
| | | } |
| | | mbomService.saveBatch(mbomList); |
| | | /*新增标准BOM-->生产工艺(批量添加)*/ |
| | | List<Technique> techniqueList = new ArrayList<>(); |
| | | for (int i = 0; i < technologyIds.size(); i++) { |
| | | List<TechniqueModel> techniqueModelList = techniqueModelMapper.selectList(Wrappers.<TechniqueModel>query().eq("tech_tem_id", techTemIds.get(i))); |
| | | for (TechniqueModel techniqueModel : techniqueModelList) { |
| | | //查询设备名称 |
| | | Device device = deviceMapper.selectById(techniqueModel.getDeviceId()); |
| | | //查询基础生产工艺中每个设备的具体项目 |
| | | TechnicalModel technicalModel = technicalModelMapper.selectById(techniqueModel.getTechnicalModelId()); |
| | | Technique technique = new Technique(); |
| | | technique.setTechnologyId(technologyIds.get(i)); |
| | | technique.setDevice(device.getName()); |
| | | technique.setProductFather(technicalModel.getFather()); |
| | | technique.setProduct(technicalModel.getName()); |
| | | technique.setUnit(technicalModel.getUnit()); |
| | | techniqueList.add(technique); |
| | | } |
| | | } |
| | | techniqueService.saveBatch(techniqueList); |
| | | return "添加型号【"+ specificationsDto.getSpecifications() +"】成功!"; |
| | | } |
| | | |
| | | |
| | | //根据规格id和型号名称查询型号信息 |
| | | @Override |
| | | public Specifications selectSpIdByname(Integer id, String name) { |
| | | Specifications specifications = specificationsMapper.selectOne(Wrappers.<Specifications>query() |
| | | .eq("standard_id", id) |
| | | .eq("name", name)); |
| | | return specifications; |
| | | } |
| | | } |
| | | |
| | | |