| | |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | |
| | | lqw.like(StringUtils.isNotEmpty(zfEquipment.getRemark()), ZfEquipment::getRemark, zfEquipment.getRemark()); |
| | | lqw.eq(zfEquipment.getHappenTime() != null, ZfEquipment::getHappenTime, zfEquipment.getHappenTime()); |
| | | lqw.between(zfEquipment.getHappenStartTime() != null && zfEquipment.getHappenEndTime() != null, ZfEquipment::getHappenTime, zfEquipment.getHappenStartTime(), zfEquipment.getHappenEndTime()); |
| | | return lqw; |
| | | } |
| | | |
| | | private LambdaQueryWrapper<ZfEquipment> uniqueCondition(ZfEquipment zfEquipment) { |
| | | LambdaQueryWrapper<ZfEquipment> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.eq(StringUtils.isNotEmpty(zfEquipment.getName()), ZfEquipment::getName, zfEquipment.getName()); |
| | | lqw.eq(StringUtils.isNotEmpty(zfEquipment.getBuyer()), ZfEquipment::getBuyer, zfEquipment.getBuyer()); |
| | | lqw.eq(StringUtils.isNotEmpty(zfEquipment.getContent()), ZfEquipment::getContent, zfEquipment.getContent()); |
| | | lqw.eq(StringUtils.isNotEmpty(zfEquipment.getLocation()), ZfEquipment::getLocation, zfEquipment.getLocation()); |
| | | lqw.eq(StringUtils.isNotEmpty(zfEquipment.getRemark()), ZfEquipment::getRemark, zfEquipment.getRemark()); |
| | | lqw.eq(zfEquipment.getHappenTime() != null, ZfEquipment::getHappenTime, zfEquipment.getHappenTime()); |
| | | return lqw; |
| | | } |
| | | |
| | |
| | | return markOwnData(familyIds, beanRecords); |
| | | } |
| | | |
| | | @Override |
| | | public List<ZfEquipment> selectByIds(Long[] ids) { |
| | | List<ZfEquipment> list = new ArrayList<>(); |
| | | if(ids.length!=0) |
| | | list = listByIds(Arrays.asList(ids)); |
| | | else |
| | | list = list(); |
| | | return list; } |
| | | |
| | | private static List<ZfEquipment> markOwnData(String familyIds, List<ZfEquipment> beanRecords) { |
| | | return beanRecords.stream().peek(record -> { |
| | | String recordFamilyId = record.getFamilyId(); |
| | |
| | | zfEquipment.setFamilyId(myFamilyId); |
| | | } |
| | | |
| | | //判断是否有重复数据 |
| | | LambdaQueryWrapper<ZfEquipment> lqw = uniqueCondition(zfEquipment); |
| | | List<ZfEquipment> list = list(lqw); |
| | | if(list.size()>0){ |
| | | throw new RuntimeException("请勿新增重复数据"); |
| | | } |
| | | |
| | | if (save(zfEquipment)) { |
| | | return AjaxResult.success(); |
| | | } else { |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @Override |
| | | @Transactional |
| | | public AjaxResult importExcel(MultipartFile file) { |