| | |
| | | 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.whyc.dto.Response; |
| | |
| | | if(!userName.equals(specificationInDB.getOwner())){ |
| | | return new Response().set(1,false,"非负责人无法解锁"); |
| | | } |
| | | //存在解锁版本,无法解锁 |
| | | //校验解锁时,存在解锁版本,无法解锁 |
| | | if(lockFlag == 0){ |
| | | TechnicalSpecification availableVersion = getAvailableVersion(specificationInDB.getApplyMaterialCode(),specificationInDB.getApplyCustomCode()); |
| | | if(availableVersion!=null){ |
| | | if(!availableVersion.getOwner().equals(userName)) { |
| | | return new Response().set(1, false, "存在生效版本,无法解锁. 目前生效版本负责人为" + availableVersion.getOwner() + ",生效版本为:" + availableVersion.getVersion()); |
| | | }else{ |
| | | //锁定目前生效版本 |
| | | availableVersion.setLockFlag(1); |
| | | availableVersion.setLockReason("新版本解锁,此旧版本锁定"); |
| | | mapper.updateById(availableVersion); |
| | | } |
| | | } |
| | | } |
| | | specificationInDB.setLockFlag(lockFlag); |
| | | mapper.updateById(specificationInDB); |
| | | |
| | | return null; |
| | | return new Response().set(1, true, "更新完成"); |
| | | } |
| | | |
| | | private TechnicalSpecification getAvailableVersion(String applyMaterialCode, String applyCustomCode) { |
| | | QueryWrapper<TechnicalSpecification> query = Wrappers.query(); |
| | | query.eq("apply_material_code",applyMaterialCode); |
| | | query.eq("apply_custom_code",applyCustomCode); |
| | | query.eq("lock_flag",0); |
| | | query.last(" limit 1"); |
| | | return mapper.selectOne(query); |
| | | } |
| | | |
| | | private TechnicalSpecification get(int id){ |