| | |
| | | @Resource |
| | | DeviceMapper deviceMapper; |
| | | |
| | | @Resource |
| | | TechnologyMapper technologyMapper; |
| | | |
| | | @Resource |
| | | ProductMapper productMapper; |
| | | |
| | | @Resource |
| | | MbomMapper mbomMapper; |
| | | |
| | | @Resource |
| | | TechniqueMapper techniqueMapper; |
| | | |
| | | //标准MOM-->左侧五级树展示 |
| | | @Override |
| | | public List<Map<String, Object>> selectTreeByMaterial() { |
| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public String addMaterial(MaterialDto materialDto) { |
| | | //校验添加物料是否重复 |
| | | if (materialMapper.selectOne(Wrappers.<Material>query() |
| | | List<Material> materialList = materialMapper.selectList(Wrappers.<Material>query() |
| | | .eq("type", materialDto.getType()) |
| | | .eq("father", materialDto.getFather())).getName().equals(materialDto.getName())) { |
| | | return "该类型产品大类下有该产品名称"; |
| | | .eq("father", materialDto.getFather())); |
| | | for (Material material : materialList) { |
| | | if (material.getName().equals(materialDto.getName())) { |
| | | return "该类型产品大类下有该产品名称"; |
| | | } |
| | | } |
| | | /*新增物料表*/ |
| | | Material material = new Material(); |
| | |
| | | specifications.setName(materialDto.getSpecifications()); |
| | | specifications.setStandardId(standard.getId()); |
| | | specificationsMapper.insert(specifications); |
| | | /*新增标准BOM-->工艺路线(批量添加)*/ |
| | | List<TechnologyTemplate> technologyTemplateList = technologyTemplateMapper.selectList(Wrappers.<TechnologyTemplate>query().eq("type", materialDto.getFather())); |
| | | /*新增标准BOM-->工艺路线(批量添加)*///0:橡胶连接器;1:金属连接器;2:湿插拔电连接器;3:分支组件 |
| | | Integer type = null; |
| | | if (materialDto.getFather().equals("橡胶连接器")){ |
| | | type=0; |
| | | }else if (materialDto.getFather().equals("金属连接器")){ |
| | | type=1; |
| | | }else if(materialDto.getFather().equals("湿插拔电连接器")){ |
| | | type=2; |
| | | }else if(materialDto.getFather().equals("分支组件")){ |
| | | type=3; |
| | | }else return "添加物料【" + materialDto.getName() + "】成功"; |
| | | 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()); |
| | |
| | | return "添加物料【" + materialDto.getName() + "】成功"; |
| | | } |
| | | |
| | | //检验模块-->QMS管理-->成品检验-->新增(项目名称下拉框:Id与名称,编码) |
| | | |
| | | //添加同一个型号工艺路线,技术指标,物料清单,生产工艺的版本 |
| | | @Override |
| | | public List<Map<String, Object>> selectMaterialIdAndNameAndCode() { |
| | | LambdaQueryWrapper<Material> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.select(Material::getId, Material::getName, Material::getCode); |
| | | return materialMapper.selectMaps(wrapper); |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Integer addVersion(Integer specificationsId, Integer version) { |
| | | List<Technology> technologyList = technologyMapper.selectList(Wrappers.<Technology>query() |
| | | .eq("specifications_id", specificationsId) |
| | | .eq("version", version)); |
| | | /*上一个版本的工艺路线id集合*/ |
| | | List<Integer> techTemIds = technologyList.stream().map(Technology::getId).collect(Collectors.toList()); |
| | | for (Technology technology : technologyList) { |
| | | technology.setId(null); |
| | | //最新版本+1 |
| | | technology.setVersion(technologyMapper.selectVerByTec(specificationsId).get(0) + 1); |
| | | } |
| | | technologyService.saveBatch(technologyList); |
| | | /*工艺路线的版本新增的同时该工艺路线下下的技术指标,生产工艺,物料清单都要新增*/ |
| | | //新增版本的工艺路线id集合 |
| | | List<Integer> technologyIds = technologyList.stream().map(Technology::getId).collect(Collectors.toList()); |
| | | //两者长度一定一样 |
| | | List<Product> productList = new ArrayList<>(); |
| | | for (int i = 0; i < technologyIds.size(); i++) { |
| | | List<Product> products = productMapper.selectList(Wrappers.<Product>query().eq("technology_id", techTemIds.get(i))); |
| | | for (Product pro : products) { |
| | | Product product = new Product(); |
| | | product.setFather(pro.getFather()); |
| | | product.setName(pro.getName()); |
| | | product.setUnit(pro.getUnit()); |
| | | product.setRequired(pro.getRequired()); |
| | | product.setInternal(pro.getInternal()); |
| | | product.setVersion(pro.getVersion()+1); |
| | | 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<Mbom> mboms = mbomMapper.selectList(Wrappers.<Mbom>query().eq("technology_id", techTemIds.get(i))); |
| | | for (Mbom mb : mboms) { |
| | | Mbom mbom = new Mbom(); |
| | | mbom.setUnit(mb.getUnit()); |
| | | mbom.setName(mb.getName()); |
| | | mbom.setSupplier(mb.getSupplier()); |
| | | mbom.setQualityTraceability(mb.getQualityTraceability()); |
| | | mbom.setSpecifications(mb.getSpecifications()); |
| | | mbom.setVersion(mb.getVersion()+1); |
| | | mbom.setNum(mb.getNum()); |
| | | 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<Technique> techniques = techniqueMapper.selectList(Wrappers.<Technique>query().eq("technology_id", techTemIds.get(i))); |
| | | for (Technique teque : techniques) { |
| | | Technique technique = new Technique(); |
| | | technique.setTechnologyId(technologyIds.get(i)); |
| | | technique.setDevice(teque.getDevice()); |
| | | technique.setProductFather(teque.getProductFather()); |
| | | technique.setProduct(teque.getProduct()); |
| | | technique.setUnit(teque.getUnit()); |
| | | technique.setVersion(teque.getVersion()+1); |
| | | techniqueList.add(technique); |
| | | } |
| | | } |
| | | techniqueService.saveBatch(techniqueList); |
| | | return technologyList.get(0).getVersion(); |
| | | } |
| | | |
| | | } |