| | |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.mapper.ProductBomHistoryMapper; |
| | | import com.whyc.mapper.ProductBomMapper; |
| | | import com.whyc.mapper.ProductHistoryMapper; |
| | | import com.whyc.mapper.ProductMapper; |
| | | import com.whyc.pojo.Product; |
| | | import com.whyc.pojo.ProductBom; |
| | | import com.whyc.pojo.ProductBomHistory; |
| | | import com.whyc.pojo.ProductHistory; |
| | | import org.apache.poi.hssf.record.ProtectionRev4Record; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | public class ProductHistoryService { |
| | | @Autowired(required = false) |
| | | private ProductHistoryMapper mapper; |
| | | |
| | | @Autowired(required = false) |
| | | private ProductMapper productMapper; |
| | | |
| | | @Autowired(required = false) |
| | | private ProductBomMapper productBomMapper; |
| | | |
| | | |
| | | @Autowired(required = false) |
| | | private ProductBomHistoryMapper productBomHistoryMapper; |
| | | |
| | | //产品详情查看版本信息 |
| | | public Response getProductVersion(String parentCode,String customCode) { |
| | |
| | | UpdateWrapper wrapper=new UpdateWrapper(); |
| | | wrapper.eq("parent_code",parentCode); |
| | | wrapper.eq("custom_code",customCode); |
| | | |
| | | int flag=0; |
| | | if(enabled==1){ |
| | | //先将所有的锁定 |
| | |
| | | QueryWrapper qWrapper=new QueryWrapper(); |
| | | qWrapper.eq("parent_code",parentCode); |
| | | qWrapper.eq("custom_code",customCode); |
| | | //将选中的版本的历史信息查询出来 |
| | | //1.查询当前product中的信息 |
| | | Product product=productMapper.selectOne(qWrapper); |
| | | //2.将选中的版本的历史信息查询出来 |
| | | qWrapper.eq("version",version); |
| | | ProductHistory pHistory=mapper.selectOne(qWrapper); |
| | | //prodcut中删除旧的产品信息 |
| | | //3:prodcut中删除旧的产品信息 |
| | | UpdateWrapper deleteWrapper=new UpdateWrapper(); |
| | | deleteWrapper.eq("parent_code",parentCode); |
| | | deleteWrapper.eq("custom_code",customCode); |
| | | productMapper.delete(deleteWrapper); |
| | | //再在product中查询设定可用的pHistory |
| | | //4.productBom中删除旧的信息 |
| | | if(product!=null){ |
| | | UpdateWrapper bomWrapper=new UpdateWrapper(); |
| | | bomWrapper.eq("product_id",product.getId()); |
| | | productBomMapper.delete(bomWrapper); |
| | | } |
| | | if(pHistory!=null){ |
| | | Product product=new Product(); |
| | | product.setId(pHistory.getId()); |
| | | product.setParentCode(pHistory.getParentCode()); |
| | | product.setParentName(pHistory.getParentName()); |
| | | product.setParentModel(pHistory.getParentModel()); |
| | | product.setCustomCode(pHistory.getCustomCode()); |
| | | product.setCreateTime(pHistory.getCreateTime()); |
| | | product.setVersionTime(pHistory.getVersionTime()); |
| | | product.setVersion(pHistory.getVersion()); |
| | | productMapper.insert(product); |
| | | // 5.在product中插入设定可用的pHistory |
| | | productMapper.insertPselectPH(pHistory.getId()); |
| | | //6.在productBom中插入pHsitoryBom查询出的数据 |
| | | productBomMapper.insertBomSelectBomH(pHistory.getId()); |
| | | } |
| | | } |
| | | }else{ |
| | |
| | | wrapper.set("enabled",0); |
| | | flag=mapper.update(null,wrapper); |
| | | if(flag>0){ |
| | | //prodcut中删除旧的产品信息 |
| | | QueryWrapper qWrapper=new QueryWrapper(); |
| | | qWrapper.eq("parent_code",parentCode); |
| | | qWrapper.eq("custom_code",customCode); |
| | | //1.查询当前product中的信息 |
| | | Product product=productMapper.selectOne(qWrapper); |
| | | |
| | | //2.prodcut中删除旧的产品信息 |
| | | UpdateWrapper deleteWrapper=new UpdateWrapper(); |
| | | deleteWrapper.eq("parent_code",parentCode); |
| | | deleteWrapper.eq("custom_code",customCode); |
| | | productMapper.delete(deleteWrapper); |
| | | |
| | | //3.删除productBom |
| | | if(product!=null){ |
| | | UpdateWrapper bomWrapper=new UpdateWrapper(); |
| | | bomWrapper.eq("product_id",product.getId()); |
| | | productBomMapper.delete(bomWrapper); |
| | | } |
| | | |
| | | } |
| | | |
| | | } |