| | |
| | | package com.whyc.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.github.pagehelper.PageInfo; |
| | |
| | | import java.io.FileOutputStream; |
| | | import java.io.IOException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service |
| | |
| | | |
| | | public List<Material> getSameSubCodeAndModel(List<ProductBom> bomList) { |
| | | return mapper.getSameSubCodeAndModel(bomList); |
| | | } |
| | | |
| | | public void updateFillCategory(String sign) { |
| | | if(sign.equals("perryhsu")){ //允许操作 |
| | | //联查产品物料历史表,获取物料对应的类别 |
| | | List<Material> materialList = mapper.getCategory(); |
| | | List<Material> materialWithOneCategoryList = new LinkedList<>(); |
| | | Map<Integer, List<Material>> materialIdMap = materialList.stream().collect(Collectors.groupingBy(Material::getId)); |
| | | Set<Integer> materialIdSet = materialIdMap.keySet(); |
| | | for (Integer materialId : materialIdSet) { |
| | | List<Material> temp = materialIdMap.get(materialId); |
| | | if(temp.size()==1){ |
| | | materialWithOneCategoryList.add(temp.get(0)); |
| | | }else{ |
| | | System.err.println("物料id:"+materialId+"对应"+temp.size()+"个类别"+temp.get(0).getCategory()+"/"+temp.get(1).getCategory()); |
| | | } |
| | | } |
| | | //将类别回填到物料表 |
| | | for (int i = 0; i < materialWithOneCategoryList.size(); i++) { |
| | | Material material = materialWithOneCategoryList.get(i); |
| | | UpdateWrapper<Material> update = Wrappers.update(); |
| | | update.set("category",material.getCategory()).eq("id",material.getId()); |
| | | mapper.update(null,update); |
| | | } |
| | | } |
| | | } |
| | | } |