提交 18a5f300 编写于 作者: L luojing

crm,添加未转化线索的搜索及展现

上级 1f77f71c
...@@ -215,4 +215,64 @@ public class LeadsFactory extends AbstractFactory { ...@@ -215,4 +215,64 @@ public class LeadsFactory extends AbstractFactory {
return em.createQuery(cq).getSingleResult(); return em.createQuery(cq).getSingleResult();
} }
//根据责任人列表获得线索列表 (未转化)
public List<Leads> ListByOwnerList_NoTransform(List<String> _distinguishNameList, Integer adjustPage,
Integer adjustPageSize, String keyString, String orderFieldName, String orderType) throws Exception {
EntityManager em = this.entityManagerContainer().get(Leads.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Leads> cq = cb.createQuery(Leads.class);
Root<Leads> root = cq.from(Leads.class);
Predicate p = root.get(Leads_.owneruser).in(_distinguishNameList);
p = cb.and(p, cb.equal(root.get(Leads_.istransform), BaseAction.NOT_TRANSFORM));
//搜索关键字判断
if (!StringWCRMUtils.isEmptyKeyString(keyString)) {
String key = StringUtils.trim(StringUtils.replaceEach(keyString, new String[] { "\u3000", "?", "%" },
new String[] { " ", "", "" }));
Predicate p_like = cb.or(cb.like(root.get(Leads_.name), "%" + key + "%"),
cb.like(root.get(Leads_.cellphone), "%" + key + "%"),
cb.like(root.get(Leads_.pinyin), "%" + key + "%"),
cb.like(root.get(Leads_.pinyinInitial), "%" + key + "%"),
cb.like(root.get(Leads_.telephone), "%" + key + "%"));
p = cb.and(p, p_like);
}
//排序值字段,升降序判断
Order _order;
if (StringUtils.isEmpty(orderType) || StringUtils.isEmpty(orderFieldName) || null == orderType
|| null == orderFieldName) {
_order = cb.desc(root.get(defaultOrder));
} else {
_order = CriteriaQueryTools.setOrder(cb, root, Leads_.class, orderFieldName, orderType);
}
cq.select(root).where(p).orderBy(_order);
// System.out.println("LeadsFactory.ListByOwnerList():" + cq.toString());
return em.createQuery(cq).setFirstResult((adjustPage - 1) * adjustPageSize).setMaxResults(adjustPageSize)
.getResultList();
}
//根据责任人列表获得线索数量(未转化)
public Long ListByOwnerList_NoTransform_Count(List<String> _distinguishNameList, String keyString)
throws Exception {
EntityManager em = this.entityManagerContainer().get(Leads.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Long> cq = cb.createQuery(Long.class);
Root<Leads> root = cq.from(Leads.class);
Predicate p = root.get(Leads_.owneruser).in(_distinguishNameList);
p = cb.and(p, cb.equal(root.get(Leads_.istransform), BaseAction.NOT_TRANSFORM));
//搜索关键字判断
if (!StringWCRMUtils.isEmptyKeyString(keyString)) {
String key = StringUtils.trim(StringUtils.replaceEach(keyString, new String[] { "\u3000", "?", "%" },
new String[] { " ", "", "" }));
Predicate p_like = cb.or(cb.like(root.get(Leads_.name), "%" + key + "%"),
cb.like(root.get(Leads_.cellphone), "%" + key + "%"),
cb.like(root.get(Leads_.pinyin), "%" + key + "%"),
cb.like(root.get(Leads_.pinyinInitial), "%" + key + "%"),
cb.like(root.get(Leads_.telephone), "%" + key + "%"));
p = cb.and(p, p_like);
}
cq.select(cb.count(root)).where(p);
return em.createQuery(cq).getSingleResult();
}
} }
package com.x.wcrm.assemble.control.jaxrs.leads;
import com.google.gson.JsonElement;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.wcrm.assemble.control.Business;
import com.x.wcrm.assemble.control.ThisApplication;
import com.x.wcrm.assemble.control.wrapin.ListPagingWi;
import com.x.wcrm.core.entity.Leads;
import java.util.List;
class ActionListMyNoTransform extends BaseAction {
// private static Logger logger = LoggerFactory.getLogger(ActionListMyHasTransform.class);
// 所有当前用户所有递归下级的已转化的线索,按照时间倒序排列。
ActionResult<List<Wo>> execute(EffectivePerson effectivePerson, Integer adjustPage, Integer adjustPageSize, JsonElement jsonElement)
throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<List<Wo>> result = new ActionResult<>();
Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
Business business = new Business(emc);
List<Leads> os = leadsPermissionService.getList_MyDuty_And_SubNestedDuty_NoTransform(ThisApplication.context(), business,
effectivePerson, adjustPage, adjustPageSize, wi.getKey(), wi.getOrderFieldName(), wi.getOrderType());
List<Wo> wos = Wo.copier.copy(os);
result.setData(wos);
long count = leadsPermissionService.getList_MyDuty_And_SubNestedDuty__NoTransform_Count(ThisApplication.context(), business,
effectivePerson, wi.getKey());
result.setCount(count);
return result;
}
}
public static class Wo extends Leads {
private static final long serialVersionUID = 5220686039082993620L;
static WrapCopier<Leads, Wo> copier = WrapCopierFactory.wo(Leads.class, Wo.class, null, JpaObject.FieldsInvisible, false);
}
public static class Wi extends ListPagingWi {
}
}
...@@ -329,4 +329,23 @@ public class LeadsAction extends StandardJaxrsAction { ...@@ -329,4 +329,23 @@ public class LeadsAction extends StandardJaxrsAction {
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result)); asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
} }
@JaxrsMethodDescribe(value = "获取我负责,和我下属负责未转化的线索", action = ActionListMyNoTransform.class)
@PUT
@Path("listmynotransform/page/{page}/size/{size}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void ListMyNoTransform(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("页码") @PathParam("page") Integer page, @JaxrsParameterDescribe("每页几条") @PathParam("size") Integer size,
@JaxrsParameterDescribe("匹配关键字") JsonElement jsonElement) {
ActionResult<List<ActionListMyNoTransform.Wo>> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionListMyNoTransform().execute(effectivePerson, page, size, jsonElement);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
} }
...@@ -189,6 +189,49 @@ public class LeadsPermissionService extends PermissionServiceBase { ...@@ -189,6 +189,49 @@ public class LeadsPermissionService extends PermissionServiceBase {
return count; return count;
} }
// 获得自己负责的,和我的下属负责线索(未转化):列表
public List<Leads> getList_MyDuty_And_SubNestedDuty_NoTransform(AbstractContext context, Business business,
EffectivePerson effectivePerson, Integer adjustPage, Integer adjustPageSize, String keyString,
String orderFieldName, String orderType) throws Exception {
String _me = effectivePerson.getDistinguishedName();
List<String> _me_collection = new ArrayList<String>();
_me_collection.add(effectivePerson.getDistinguishedName());
List<String> _persons = new ArrayList<String>();
_persons.add(_me);
List<String> _subNestedPersons = getListWithPersonSubNested(context, effectivePerson, _me_collection); // 所有下属
if (ListTools.isNotEmpty(_subNestedPersons)) {
_persons = ListTools.add(_persons, true, true, _subNestedPersons);
}
// List<Leads> os = business.leadsFactory().ListByOwnerList(_persons);
List<Leads> os = business.leadsFactory().ListByOwnerList_NoTransform(_persons, adjustPage, adjustPageSize,
keyString, orderFieldName, orderType);
//校验查询出的线索list是否为空
if(!os.isEmpty()) {
//获取跟进记录中的最新跟进记录时间和跟进记录内容,并赋值到线索内容中
this.getFollowRecords(os, business);
}
return os;
}
// 获得自己负责的,和我的下属负责线索(未转化):数量
public long getList_MyDuty_And_SubNestedDuty__NoTransform_Count(AbstractContext context, Business business,
EffectivePerson effectivePerson, String keyString) throws Exception {
String _me = effectivePerson.getDistinguishedName();
List<String> _me_collection = new ArrayList<String>();
_me_collection.add(effectivePerson.getDistinguishedName());
List<String> _persons = new ArrayList<String>();
_persons.add(_me);
List<String> _subNestedPersons = getListWithPersonSubNested(context, effectivePerson, _me_collection); // 所有下属
if (ListTools.isNotEmpty(_subNestedPersons)) {
_persons = ListTools.add(_persons, true, true, _subNestedPersons);
}
// List<Leads> os = business.leadsFactory().ListByOwnerList(_persons);
long count = business.leadsFactory().ListByOwnerList_NoTransform_Count(_persons, keyString);
return count;
}
/** /**
* 根据线索的ID,获取对应的跟进记录中的最新跟进记录时间和跟进记录内容,并把时间和内容写入到线索内容中返回前端 * 根据线索的ID,获取对应的跟进记录中的最新跟进记录时间和跟进记录内容,并把时间和内容写入到线索内容中返回前端
* @param osList 线索 * @param osList 线索
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册