| | |
| | | |
| | | 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; |
| | | import com.whyc.mapper.AttachLockMapper; |
| | | import com.whyc.pojo.AttachLock; |
| | |
| | | UpdateWrapper uwrapper=new UpdateWrapper(); |
| | | uwrapper.set("lock_flag",attachLock.getLockFlag()); |
| | | uwrapper.set("local_reason",attachLock.getLocalReason()); |
| | | uwrapper.eq("attach_name",attachLock.getAttachName()); |
| | | uwrapper.eq("material_id",attachLock.getMaterialId()); |
| | | mapper.update(null,uwrapper); |
| | | }else{ |
| | | mapper.insert(attachLock); |
| | |
| | | }); |
| | | return new Response().set(1,true,""); |
| | | } |
| | | |
| | | @Transactional |
| | | public Response updateProductLock(List<AttachLock> list) { |
| | | if(list!=null&&list.size()>0){} |
| | | list.stream().forEach(attachLock -> { |
| | | //1.查询是否存在该记录 |
| | | QueryWrapper qwrapper=new QueryWrapper(); |
| | | qwrapper.eq("product_id",attachLock.getProductId()); |
| | | qwrapper.eq("attach_name",attachLock.getAttachName()); |
| | | qwrapper.last("limit 1"); |
| | | AttachLock attach=mapper.selectOne(qwrapper); |
| | | if(attach!=null){ |
| | | UpdateWrapper uwrapper=new UpdateWrapper(); |
| | | uwrapper.set("lock_flag",attachLock.getLockFlag()); |
| | | uwrapper.set("local_reason",attachLock.getLocalReason()); |
| | | uwrapper.eq("attach_name",attachLock.getAttachName()); |
| | | uwrapper.eq("product_id",attachLock.getProductId()); |
| | | mapper.update(null,uwrapper); |
| | | }else{ |
| | | mapper.insert(attachLock); |
| | | } |
| | | }); |
| | | return new Response().set(1,true,""); |
| | | } |
| | | |
| | | public void getAndInsert(Integer materialIdInDB, Integer materialId) { |
| | | QueryWrapper<AttachLock> query = Wrappers.query(); |
| | | query.eq("material_id",materialIdInDB).eq("lock_flag",1).eq("product_id",0); |
| | | List<AttachLock> attachLocksInDB = mapper.selectList(query); |
| | | |
| | | attachLocksInDB.forEach(attachLock -> { |
| | | attachLock.setId(null); |
| | | attachLock.setMaterialId(materialId); |
| | | }); |
| | | if(attachLocksInDB.size()!=0) { |
| | | mapper.insertBatchSomeColumn(attachLocksInDB); |
| | | } |
| | | } |
| | | } |