| | |
| | | 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 com.whyc.dto.FileUrlDTO; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.mapper.ProductHistoryMapper; |
| | | import com.whyc.mapper.ProductMapper; |
| | | import com.whyc.pojo.*; |
| | | import com.whyc.util.DateUtil; |
| | |
| | | @Autowired(required = false) |
| | | private ProductMapper mapper; |
| | | |
| | | @Autowired(required = false) |
| | | private ProductHistoryMapper hisMapper; |
| | | |
| | | @Autowired |
| | | private ProductHistoryService phService; |
| | | |
| | |
| | | private ProductLockLogService productLockLogService; |
| | | |
| | | //查询出所有的产品信息(分页加模糊查询<产品的编码,型号,名字,定制表编号> |
| | | public Response getAllProduct(String subCode,String parentCode, String parentName, String parentModel, String customCode, int pageCurr, int pageSize) { |
| | | /*PageHelper.startPage(pageCurr,pageSize); |
| | | QueryWrapper wrapper=new QueryWrapper(); |
| | | public Response getAllProduct(String subCode,String parentCode, String parentName, String parentModel, String customCode,Integer enabled, int pageCurr, int pageSize) { |
| | | PageHelper.startPage(pageCurr,pageSize); |
| | | /*QueryWrapper wrapper=new QueryWrapper(); |
| | | if(parentCode!=null){ |
| | | wrapper.like("parent_code",parentCode); |
| | | } |
| | |
| | | } |
| | | wrapper.orderByAsc("id"); |
| | | List list=mapper.selectList(wrapper);*/ |
| | | List list=mapper.getAllProduct(subCode,parentCode,parentName,parentModel,customCode); |
| | | List<Product> list=mapper.getAllProduct(subCode,parentCode,parentName,parentModel,customCode,enabled); |
| | | /*list.stream().forEach(product -> { |
| | | //1.查询是否存在该记录 |
| | | QueryWrapper qwrapper=new QueryWrapper(); |
| | | qwrapper.eq("id",product.getId()); |
| | | qwrapper.last("limit 1"); |
| | | ProductHistory pHis=hisMapper.selectOne(qwrapper); |
| | | product.setEnabled(pHis.getEnabled()); |
| | | });*/ |
| | | PageInfo pageInfo=new PageInfo(list); |
| | | return new Response().setII(1,list.size()>0,pageInfo,"返回产品信息"); |
| | | } |
| | |
| | | his.setEnabled(-1); |
| | | phService.insertAndUpdateEnabled(his); |
| | | //phService.insert(his); |
| | | // -> product 现有产品和产品bom不需要插入,但是要做删除原来的旧版本 |
| | | // -> product 现有产品和产品bom需要插入,version默认为-1,同时要做删除原来的旧版本 |
| | | product.setId(his.getId()); |
| | | product.setCreateTime(date); |
| | | product.setVersion(1); |
| | | //deleteAndInsert(product); |
| | | delete(product); |
| | | product.setVersion(-1); |
| | | deleteAndInsert(product); |
| | | // -> bom |
| | | /*bomList.forEach(bom-> { |
| | | bomList.forEach(bom-> { |
| | | bom.setProductId(product.getId()); |
| | | bom.setSubVersion(1); |
| | | }); |
| | | pbService.insertBatch(bomList);*/ |
| | | pbService.insertBatch(bomList); |
| | | // -> bom_his |
| | | List<ProductBomHistory> bomHistoryList = new LinkedList<>(); |
| | | bomList.forEach(bom->{ |
| | |
| | | |
| | | productHistory.setEnabled(-1); |
| | | phService.insertAndUpdateEnabled(productHistory); |
| | | // -> product 现有产品和产品bom不需要插入,但是要做删除原来的旧版本 |
| | | // -> product 现有产品和产品bom需要插入,version默认为-1,同时要做删除原来的旧版本 |
| | | product.setId(productHistory.getId()); |
| | | product.setCreateTime(date); |
| | | product.setVersion(nextVersion); |
| | | //deleteAndInsert(product); |
| | | delete(product); |
| | | product.setVersion(-1); |
| | | deleteAndInsert(product); |
| | | // -> product_bom |
| | | /*List<ProductBom> productBomList = new LinkedList<>(); |
| | | List<ProductBom> productBomList = new LinkedList<>(); |
| | | bomMaterialList.forEach(bomMaterial -> { |
| | | ProductBom bom = new ProductBom(); |
| | | bom.setProductId(product.getId()); |
| | |
| | | |
| | | productBomList.add(bom); |
| | | }); |
| | | pbService.insertBatch(productBomList);*/ |
| | | pbService.insertBatch(productBomList); |
| | | // -> product_bom_history |
| | | List<ProductBomHistory> bomHistoryList = new LinkedList<>(); |
| | | bomMaterialList.forEach(bomMaterial -> { |