|
|
|
@ -17,13 +17,14 @@ package cc.hiver.core.serviceimpl; |
|
|
|
|
|
|
|
import cc.hiver.core.base.HiverBaseDao; |
|
|
|
import cc.hiver.core.common.constant.CommonConstant; |
|
|
|
import cc.hiver.core.common.utils.BeanUtils; |
|
|
|
import cc.hiver.core.dao.LogiticsCompanyDao; |
|
|
|
import cc.hiver.core.entity.LogiticsCompany; |
|
|
|
import cc.hiver.core.logisticsuser.entity.LogisticsUser; |
|
|
|
import cc.hiver.core.logisticsuser.service.LogisticsUserService; |
|
|
|
import cc.hiver.core.service.LogiticsCompanyService; |
|
|
|
import cc.hiver.core.vo.LogiticsCompanyQueryVo; |
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
import cn.hutool.core.text.CharSequenceUtil; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
@ -65,38 +66,38 @@ public class LogiticsCompanyServiceImpl implements LogiticsCompanyService { |
|
|
|
@Nullable |
|
|
|
@Override |
|
|
|
public Predicate toPredicate(Root<LogiticsCompany> root, CriteriaQuery<?> cq, CriteriaBuilder cb) { |
|
|
|
Path<String> companyNameField = root.get("companyName"); |
|
|
|
Path<String> signCompanyField = root.get("signCompany"); |
|
|
|
Path<String> contactsField = root.get("contacts"); |
|
|
|
Path<String> mobileField = root.get("mobile"); |
|
|
|
Path<String> delFlagField = root.get("delFlag"); |
|
|
|
Path<String> isOnLineField = root.get("isOnLine"); |
|
|
|
final Path<String> companyNameField = root.get("companyName"); |
|
|
|
final Path<String> signCompanyField = root.get("signCompany"); |
|
|
|
final Path<String> contactsField = root.get("contacts"); |
|
|
|
final Path<String> mobileField = root.get("mobile"); |
|
|
|
final Path<String> delFlagField = root.get("delFlag"); |
|
|
|
final Path<String> isOnLineField = root.get("isOnLine"); |
|
|
|
|
|
|
|
List<Predicate> list = new ArrayList<>(); |
|
|
|
final List<Predicate> list = new ArrayList<>(); |
|
|
|
|
|
|
|
if (StrUtil.isNotBlank(company.getSignCompany())) { |
|
|
|
if (CharSequenceUtil.isNotBlank(company.getSignCompany())) { |
|
|
|
list.add(cb.equal(signCompanyField, company.getSignCompany() )); |
|
|
|
} |
|
|
|
if (company.getIsOnLine() != null) { |
|
|
|
list.add(cb.equal(isOnLineField, company.getIsOnLine() )); |
|
|
|
} |
|
|
|
|
|
|
|
if (StrUtil.isNotBlank(company.getCompanyName())) { |
|
|
|
if (CharSequenceUtil.isNotBlank(company.getCompanyName())) { |
|
|
|
list.add(cb.like(companyNameField, '%' + company.getCompanyName() + '%')); |
|
|
|
} |
|
|
|
|
|
|
|
if (StrUtil.isNotBlank(company.getContacts())) { |
|
|
|
if (CharSequenceUtil.isNotBlank(company.getContacts())) { |
|
|
|
list.add(cb.like(contactsField, '%' + company.getContacts() + '%')); |
|
|
|
} |
|
|
|
|
|
|
|
if (StrUtil.isNotBlank(company.getMobile())) { |
|
|
|
if (CharSequenceUtil.isNotBlank(company.getMobile())) { |
|
|
|
list.add(cb.like(mobileField, '%' + company.getMobile() + '%')); |
|
|
|
} |
|
|
|
|
|
|
|
// 未删除
|
|
|
|
list.add(cb.equal(delFlagField, company.getDelFlag())); |
|
|
|
|
|
|
|
Predicate[] arr = new Predicate[list.size()]; |
|
|
|
final Predicate[] arr = new Predicate[list.size()]; |
|
|
|
cq.where(list.toArray(arr)); |
|
|
|
cq.orderBy(cb.desc(root.<Integer>get("isOnLine")),cb.asc(root.<String>get("companyName"))); |
|
|
|
return null; |
|
|
|
@ -111,7 +112,7 @@ public class LogiticsCompanyServiceImpl implements LogiticsCompanyService { |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<LogiticsCompany> findByMobile(String mobile) { |
|
|
|
List<LogiticsCompany> logiticsCompanyList = companyDao.findByMobile(mobile); |
|
|
|
final List<LogiticsCompany> logiticsCompanyList = companyDao.findByMobile(mobile); |
|
|
|
if (logiticsCompanyList.isEmpty()) { |
|
|
|
// 物流公司主表中没有查询到信息,查询物流公司员工信息
|
|
|
|
final LogisticsUser logisticsUser = logisticsUserService.findByMobile(mobile); |
|
|
|
@ -119,12 +120,14 @@ public class LogiticsCompanyServiceImpl implements LogiticsCompanyService { |
|
|
|
return new ArrayList<>(); |
|
|
|
}else{ |
|
|
|
final LogiticsCompany logiticsCompany = companyDao.getById(logisticsUser.getCompanyId()); |
|
|
|
final LogiticsCompany userLogiticsCompany = new LogiticsCompany(); |
|
|
|
BeanUtils.copyBeanProp(userLogiticsCompany,logiticsCompany); |
|
|
|
// 将员工的信息封装至公司信息中
|
|
|
|
logiticsCompany.setId(logisticsUser.getId()); |
|
|
|
logiticsCompany.setPassword(logisticsUser.getPassword()); |
|
|
|
logiticsCompany.setUsername(logisticsUser.getMobile()); |
|
|
|
logiticsCompany.setCompanyId(logisticsUser.getCompanyId()); |
|
|
|
logiticsCompanyList.add(logiticsCompany); |
|
|
|
userLogiticsCompany.setId(logisticsUser.getId()); |
|
|
|
userLogiticsCompany.setPassword(logisticsUser.getPassword()); |
|
|
|
userLogiticsCompany.setUsername(logisticsUser.getMobile()); |
|
|
|
userLogiticsCompany.setCompanyId(logisticsUser.getCompanyId()); |
|
|
|
logiticsCompanyList.add(userLogiticsCompany); |
|
|
|
return logiticsCompanyList; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -138,41 +141,41 @@ public class LogiticsCompanyServiceImpl implements LogiticsCompanyService { |
|
|
|
@Nullable |
|
|
|
@Override |
|
|
|
public Predicate toPredicate(Root<LogiticsCompany> root, CriteriaQuery<?> cq, CriteriaBuilder cb) { |
|
|
|
Path<String> companyNameField = root.get("companyName"); |
|
|
|
Path<String> signCompanyField = root.get("signCompany"); |
|
|
|
Path<String> contactsField = root.get("contacts"); |
|
|
|
Path<String> mobileField = root.get("mobile"); |
|
|
|
Path<String> delFlagField = root.get("delFlag"); |
|
|
|
Path<String> networkField = root.get("network"); |
|
|
|
Path<String> addressField = root.get("companyAddress"); |
|
|
|
final Path<String> companyNameField = root.get("companyName"); |
|
|
|
final Path<String> signCompanyField = root.get("signCompany"); |
|
|
|
final Path<String> contactsField = root.get("contacts"); |
|
|
|
final Path<String> mobileField = root.get("mobile"); |
|
|
|
final Path<String> delFlagField = root.get("delFlag"); |
|
|
|
final Path<String> networkField = root.get("network"); |
|
|
|
final Path<String> addressField = root.get("companyAddress"); |
|
|
|
|
|
|
|
List<Predicate> list = new ArrayList<>(); |
|
|
|
final List<Predicate> list = new ArrayList<>(); |
|
|
|
|
|
|
|
if (StrUtil.isNotEmpty(company.getSignCompany())) { |
|
|
|
if (CharSequenceUtil.isNotEmpty(company.getSignCompany())) { |
|
|
|
list.add(cb.equal(signCompanyField, company.getSignCompany() )); |
|
|
|
} |
|
|
|
|
|
|
|
if (StrUtil.isNotEmpty(company.getCompanyName())) { |
|
|
|
if (CharSequenceUtil.isNotEmpty(company.getCompanyName())) { |
|
|
|
list.add(cb.like(companyNameField, '%' + company.getCompanyName() + '%')); |
|
|
|
} |
|
|
|
|
|
|
|
if (StrUtil.isNotEmpty(company.getContacts())) { |
|
|
|
if (CharSequenceUtil.isNotEmpty(company.getContacts())) { |
|
|
|
list.add(cb.like(contactsField, '%' + company.getContacts() + '%')); |
|
|
|
} |
|
|
|
|
|
|
|
if (StrUtil.isNotEmpty(company.getMobile())) { |
|
|
|
if (CharSequenceUtil.isNotEmpty(company.getMobile())) { |
|
|
|
list.add(cb.like(mobileField, '%' + company.getMobile() + '%')); |
|
|
|
} |
|
|
|
if(StringUtils.isNotEmpty(company.getSeachParams())){ |
|
|
|
Predicate p = cb.or(cb.like(companyNameField, "%" + company.getSeachParams() + "%")); |
|
|
|
p = cb.or(p, cb.like(networkField, "%" + company.getSeachParams() + "%")); |
|
|
|
p = cb.or(p, cb.like(addressField, "%" + company.getSeachParams() + "%")); |
|
|
|
Predicate p = cb.or(cb.like(companyNameField, '%' + company.getSeachParams() + '%')); |
|
|
|
p = cb.or(p, cb.like(networkField, '%' + company.getSeachParams() + '%')); |
|
|
|
p = cb.or(p, cb.like(addressField, '%' + company.getSeachParams() + '%')); |
|
|
|
list.add(p); |
|
|
|
} |
|
|
|
// 未删除
|
|
|
|
list.add(cb.equal(delFlagField, company.getDelFlag())); |
|
|
|
|
|
|
|
Predicate[] arr = new Predicate[list.size()]; |
|
|
|
final Predicate[] arr = new Predicate[list.size()]; |
|
|
|
cq.where(list.toArray(arr)); |
|
|
|
cq.orderBy(cb.desc(root.<Integer>get("isOnLine")),cb.desc(root.<Integer>get("createTime")),cb.asc(root.<String>get("companyName"))); |
|
|
|
return null; |
|
|
|
@ -187,10 +190,12 @@ public class LogiticsCompanyServiceImpl implements LogiticsCompanyService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onLine(String id){ |
|
|
|
companyDao.changeOnLine(id,CommonConstant.ON_LINE); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void offLine(String id){ |
|
|
|
companyDao.changeOnLine(id,CommonConstant.OFF_LINE); |
|
|
|
} |
|
|
|
|