| | |
| | | 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,"返回产品信息"); |
| | | } |
| | |
| | | Date date = new Date(); |
| | | boolean isCopyCustom = false; |
| | | Product relatedProduct = null; |
| | | //校验凡是有定制表单号的产品,不能使用已上传过的标准产品编码 |
| | | if(customCode!=null && !customCode.trim().equals("")){ |
| | | ProductHistory standard = phService.getStandard(parentCode); |
| | | if(standard !=null){ |
| | | return new Response().set(1,false,"系统存在此次母物料编码的标准产品,拒绝提交"); |
| | | } |
| | | } |
| | | //判断是否为依据产品复制定制的产品 |
| | | if(bomList == null){ |
| | | bomList = pbService.getBomByProductId(product.getId()); |
| | |
| | | his.setVersionTime(product.getVersionTime()); |
| | | his.setVersion(1); |
| | | his.setSubVersionMax(1); |
| | | his.setEnabled(1); |
| | | //上传后的最初始使能状态为-1 |
| | | //第一次解锁后,后续的锁定和解锁在0和1之间切换 |
| | | his.setEnabled(-1); |
| | | phService.insertAndUpdateEnabled(his); |
| | | //phService.insert(his); |
| | | // -> product |
| | | // -> product 现有产品和产品bom需要插入,version默认为-1,同时要做删除原来的旧版本 |
| | | product.setId(his.getId()); |
| | | product.setCreateTime(date); |
| | | product.setVersion(1); |
| | | //insert(product); |
| | | product.setVersion(-1); |
| | | deleteAndInsert(product); |
| | | // -> bom |
| | | bomList.forEach(bom-> { |
| | |
| | | productHistory.setVersion(nextVersion); |
| | | //版本新增,初始bom子件版本为1 |
| | | productHistory.setSubVersionMax(1); |
| | | productHistory.setEnabled(1); |
| | | |
| | | productHistory.setEnabled(-1); |
| | | phService.insertAndUpdateEnabled(productHistory); |
| | | // -> product |
| | | // -> product 现有产品和产品bom需要插入,version默认为-1,同时要做删除原来的旧版本 |
| | | product.setId(productHistory.getId()); |
| | | product.setCreateTime(date); |
| | | product.setVersion(nextVersion); |
| | | product.setVersion(-1); |
| | | deleteAndInsert(product); |
| | | // -> product_bom |
| | | List<ProductBom> productBomList = new LinkedList<>(); |
| | |
| | | mapper.insert(product); |
| | | } |
| | | |
| | | private void delete(Product product) { |
| | | Product productDB = getByProductCodeAndCustomCode(product.getParentCode(), product.getCustomCode()); |
| | | if(productDB!=null) { |
| | | mapper.deleteById(productDB.getId()); |
| | | pbService.deleteByProductId(productDB.getId()); |
| | | } |
| | | } |
| | | |
| | | private Product getByProductCodeAndCustomCode(String parentCode, String customCode) { |
| | | QueryWrapper<Product> query = Wrappers.query(); |
| | | query.eq("parent_code",parentCode).eq("custom_code",customCode).last(" limit 1"); |