| | |
| | | import com.whyc.pojo.ProductLockLog; |
| | | import com.whyc.util.ActionUtil; |
| | | import com.whyc.util.DateUtil; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | query.eq("parent_code",parentCode).eq("custom_code",customCode).orderByDesc("version").last(" limit 1"); |
| | | return mapper.selectOne(query); |
| | | } |
| | | //历史版本可用性设定 |
| | | //历史版本可用性设定<产品中包含钣金件(0120)如果包含需要把当成产品的钣金件锁掉 |
| | | @Transactional |
| | | public Response setpHistoryEnable(String parentCode, String customCode, int version, int enabled, String reason, String versionTime) { |
| | | UpdateWrapper wrapper=new UpdateWrapper(); |
| | |
| | | qWrapper.eq("custom_code",customCode); |
| | | //1.查询当前product中的信息 |
| | | Product product=productMapper.selectOne(qWrapper); |
| | | if(enabled==1){ |
| | | if(enabled==1){//解锁 |
| | | //先将所有的锁定 |
| | | wrapper.set("enabled",0); |
| | | flag=mapper.update(null,wrapper); |
| | |
| | | productMapper.update(null,uWrapper); |
| | | |
| | | //4.查询产品是否存在物料时钣金件的产品 |
| | | Material material_0120=productMapper.selectMaterial_0120(parentCode,customCode); |
| | | List<Material> list=productMapper.selectMaterial_0120(parentCode,customCode); |
| | | //如果存在则锁定 |
| | | if(material_0120!=null){ |
| | | //先锁定历史 |
| | | UpdateWrapper wrapperHistory_0120=new UpdateWrapper(); |
| | | wrapperHistory_0120.eq("parent_code",material_0120.getSubCode()); |
| | | wrapperHistory_0120.set("enabled",0); |
| | | mapper.update(null,wrapperHistory_0120); |
| | | //再设置实时为-1 |
| | | UpdateWrapper wrapper_0120=new UpdateWrapper(); |
| | | wrapper_0120.eq("parent_code",material_0120.getSubCode()); |
| | | //设为不可用版本为-1 |
| | | wrapper_0120.set("version",-1); |
| | | productMapper.update(null,wrapper_0120); |
| | | if(list!=null&&list.size()>0){ |
| | | for (Material material_0120:list) { |
| | | //先锁定历史 |
| | | UpdateWrapper wrapperHistory_0120=new UpdateWrapper(); |
| | | wrapperHistory_0120.eq("parent_code",material_0120.getSubCode()); |
| | | wrapperHistory_0120.set("enabled",0); |
| | | mapper.update(null,wrapperHistory_0120); |
| | | //再设置实时为-1 |
| | | UpdateWrapper wrapper_0120=new UpdateWrapper(); |
| | | wrapper_0120.eq("parent_code",material_0120.getSubCode()); |
| | | //设为不可用版本为-1 |
| | | wrapper_0120.set("version",-1); |
| | | productMapper.update(null,wrapper_0120); |
| | | } |
| | | } |
| | | /*if(flag>0){ |
| | | // |
| | |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public boolean checkExists(String parentCode, String customCode) { |
| | | QueryWrapper<ProductHistory> query = Wrappers.query(); |
| | | query.eq("parent_code",parentCode); |
| | | if(!StringUtils.isBlank(customCode)){ //标准产品 |
| | | query.eq("custom_code",customCode); |
| | | } |
| | | query.last(" limit 1"); |
| | | ProductHistory productHistory = mapper.selectOne(query); |
| | | return productHistory!=null; |
| | | } |
| | | } |