| | |
| | | import com.ruoyi.common.utils.bean.BeanUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.domain.ZInfoUser; |
| | | import com.ruoyi.domain.ZfEquipment; |
| | | import com.ruoyi.domain.ZfEvent; |
| | | import com.ruoyi.domain.ZfProperty; |
| | | import com.ruoyi.mapper.ZfPropertyMapper; |
| | | import com.ruoyi.service.IZfPropertyService; |
| | |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static com.ruoyi.constant.MenuAuthority.PROPERTY_LIST; |
| | |
| | | @Service |
| | | public class IZfPropertyServiceImpl extends ServiceImpl<ZfPropertyMapper, ZfProperty> implements IZfPropertyService { |
| | | |
| | | |
| | | |
| | | @Resource |
| | | IZfPropertyService zfPropertyService; |
| | | |
| | | @Resource |
| | | ZInfoUserService zInfoUserService; |
| | | |
| | | |
| | | |
| | | private LambdaQueryWrapper<ZfProperty> buildCondition(ZfProperty zfProperty) { |
| | |
| | | .like(!StringUtils.isEmpty(zfProperty.getHolder()), ZfProperty::getHolder, zfProperty.getHolder()) |
| | | .like(!StringUtils.isEmpty(zfProperty.getAddress()), ZfProperty::getAddress, zfProperty.getAddress()) |
| | | .like(!StringUtils.isEmpty(zfProperty.getRemark()), ZfProperty::getRemark, zfProperty.getRemark()) |
| | | .like(zfProperty.getCreateTime() != null, ZfProperty::getCreateTime, zfProperty.getCreateTime()); |
| | | .eq(zfProperty.getHappenTime()!=null,ZfProperty::getHappenTime,zfProperty.getHappenTime()) |
| | | .between(zfProperty.getHappenStartTime() != null && zfProperty.getHappenEndTime() != null, ZfProperty::getHappenTime, zfProperty.getHappenStartTime(), zfProperty.getHappenEndTime()); |
| | | return lqw; |
| | | } |
| | | |
| | |
| | | secondFamilyIdsBuffer.deleteCharAt(secondFamilyIdsBuffer.length() - 1); |
| | | } |
| | | |
| | | }else{ |
| | | } else { |
| | | setSecondFamilyAuthority(secondFamilyIdsBuffer, secondFamilyAuthority); |
| | | //把后面的逗号去掉 |
| | | if (secondFamilyIdsBuffer.length() > 1) { |
| | |
| | | |
| | | } |
| | | |
| | | lqw.orderByDesc(ZfProperty::getId); |
| | | lqw.orderByDesc(ZfProperty::getCreateTime); |
| | | return lqw; |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<ZfProperty> selectByCondition(ZfProperty zfProperty) { |
| | | public List<ZfProperty> selectByCondition(ZfProperty zfProperty) { |
| | | String familyIds = listFamilyIds(); |
| | | String secondFamilyIds = listSecondFamilyIds(); |
| | | LambdaQueryWrapper<ZfProperty> lambdaQueryWrapper = buildCondition(zfProperty, familyIds, secondFamilyIds); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<ZfProperty> selectByIds(Long[] ids) { |
| | | List<ZfProperty> list = new ArrayList<>(); |
| | | if(ids.length!=0) |
| | | list = listByIds(Arrays.asList(ids)); |
| | | else |
| | | list = list(); |
| | | return list; |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult addData(ZfProperty zfProperty) { |
| | | |
| | | String familyIds = listFamilyIds(); |
| | |
| | | if (flag) { |
| | | if (save(zfProperty)) { |
| | | return AjaxResult.success(); |
| | | }else { |
| | | } else { |
| | | return AjaxResult.error(); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult addData2(ZfProperty zfProperty){ |
| | | public AjaxResult addData2(ZfProperty zfProperty) { |
| | | ZInfoUser mySelf = getMySelf(); |
| | | String myFamilyId = mySelf.getFamilyId(); |
| | | |
| | | if (StringUtils.isNotEmpty(zfProperty.getFamilyId())){ |
| | | if (StringUtils.isNotEmpty(zfProperty.getFamilyId())) { |
| | | throw new RuntimeException("导入数据时您不能指定家庭号"); |
| | | } |
| | | |
| | | if(StringUtils.isEmpty(myFamilyId)){ |
| | | if (StringUtils.isEmpty(myFamilyId)) { |
| | | throw new RuntimeException("您还未加入任何家庭"); |
| | | } |
| | | |
| | | if (myFamilyId.contains(",")){ |
| | | if (myFamilyId.contains(",")) { |
| | | String[] myFamilyIds = myFamilyId.split(","); |
| | | //默认添加第一个家庭的数据 |
| | | zfProperty.setFamilyId(myFamilyIds[0]); |
| | | }else { |
| | | } else { |
| | | zfProperty.setFamilyId(myFamilyId); |
| | | } |
| | | |
| | | //判断是否有重复数据 |
| | | LambdaQueryWrapper<ZfProperty> lqw = uniqueCondition(zfProperty); |
| | | List<ZfProperty> list = list(lqw); |
| | | if(list.size()>0){ |
| | | throw new RuntimeException("请勿新增重复数据"); |
| | | } |
| | | |
| | | if (save(zfProperty)) { |
| | | return AjaxResult.success(); |
| | | }else { |
| | | } else { |
| | | return AjaxResult.error(); |
| | | } |
| | | } |
| | | |
| | | private LambdaQueryWrapper<ZfProperty> uniqueCondition(ZfProperty zfProperty) { |
| | | LambdaQueryWrapper<ZfProperty> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.eq(!StringUtils.isEmpty(zfProperty.getType()), ZfProperty::getType, zfProperty.getType()) |
| | | .eq(!StringUtils.isEmpty(zfProperty.getTitle()), ZfProperty::getTitle, zfProperty.getTitle()) |
| | | .eq(!StringUtils.isEmpty(zfProperty.getLocation()), ZfProperty::getLocation, zfProperty.getLocation()) |
| | | .eq(!StringUtils.isEmpty(zfProperty.getHolder()), ZfProperty::getHolder, zfProperty.getHolder()) |
| | | .eq(!StringUtils.isEmpty(zfProperty.getAddress()), ZfProperty::getAddress, zfProperty.getAddress()) |
| | | .eq(!StringUtils.isEmpty(zfProperty.getRemark()), ZfProperty::getRemark, zfProperty.getRemark()) |
| | | .eq(zfProperty.getHappenTime()!=null,ZfProperty::getHappenTime,zfProperty.getHappenTime()); |
| | | return lqw; |
| | | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |