diff --git a/x_wcrm_assemble_control/src/main/java/com/x/wcrm/assemble/control/factory/LeadsFactory.java b/x_wcrm_assemble_control/src/main/java/com/x/wcrm/assemble/control/factory/LeadsFactory.java index 438e0f05b78111e5885bc600f09690b012bba341..9a18620a9c410f20c2b4a2a90784d3a0cccc4627 100644 --- a/x_wcrm_assemble_control/src/main/java/com/x/wcrm/assemble/control/factory/LeadsFactory.java +++ b/x_wcrm_assemble_control/src/main/java/com/x/wcrm/assemble/control/factory/LeadsFactory.java @@ -215,4 +215,64 @@ public class LeadsFactory extends AbstractFactory { return em.createQuery(cq).getSingleResult(); } + //根据责任人列表获得线索列表 (未转化) + public List ListByOwnerList_NoTransform(List _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 cq = cb.createQuery(Leads.class); + Root 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 _distinguishNameList, String keyString) + throws Exception { + EntityManager em = this.entityManagerContainer().get(Leads.class); + CriteriaBuilder cb = em.getCriteriaBuilder(); + CriteriaQuery cq = cb.createQuery(Long.class); + Root 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(); + } } diff --git a/x_wcrm_assemble_control/src/main/java/com/x/wcrm/assemble/control/jaxrs/leads/ActionListMyNoTransform.java b/x_wcrm_assemble_control/src/main/java/com/x/wcrm/assemble/control/jaxrs/leads/ActionListMyNoTransform.java new file mode 100644 index 0000000000000000000000000000000000000000..a834a0c632a4798be1a2ba05eb87c86e83ea4746 --- /dev/null +++ b/x_wcrm_assemble_control/src/main/java/com/x/wcrm/assemble/control/jaxrs/leads/ActionListMyNoTransform.java @@ -0,0 +1,48 @@ +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> execute(EffectivePerson effectivePerson, Integer adjustPage, Integer adjustPageSize, JsonElement jsonElement) + throws Exception { + try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) { + ActionResult> result = new ActionResult<>(); + Wi wi = this.convertToWrapIn(jsonElement, Wi.class); + Business business = new Business(emc); + List os = leadsPermissionService.getList_MyDuty_And_SubNestedDuty_NoTransform(ThisApplication.context(), business, + effectivePerson, adjustPage, adjustPageSize, wi.getKey(), wi.getOrderFieldName(), wi.getOrderType()); + List 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 copier = WrapCopierFactory.wo(Leads.class, Wo.class, null, JpaObject.FieldsInvisible, false); + } + + public static class Wi extends ListPagingWi { + + } +} diff --git a/x_wcrm_assemble_control/src/main/java/com/x/wcrm/assemble/control/jaxrs/leads/LeadsAction.java b/x_wcrm_assemble_control/src/main/java/com/x/wcrm/assemble/control/jaxrs/leads/LeadsAction.java index 16ae00a236074e3b7672add0be402c946065cbb3..f5a353c83a78241d5760a1bd80be94147f9503ea 100644 --- a/x_wcrm_assemble_control/src/main/java/com/x/wcrm/assemble/control/jaxrs/leads/LeadsAction.java +++ b/x_wcrm_assemble_control/src/main/java/com/x/wcrm/assemble/control/jaxrs/leads/LeadsAction.java @@ -329,4 +329,23 @@ public class LeadsAction extends StandardJaxrsAction { 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> 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)); + } + } diff --git a/x_wcrm_assemble_control/src/main/java/com/x/wcrm/assemble/control/service/LeadsPermissionService.java b/x_wcrm_assemble_control/src/main/java/com/x/wcrm/assemble/control/service/LeadsPermissionService.java index 8488ed2a569910c9b0355c45f1e8883b7aaf71f7..ec1900cd577407e4f5db64499820c13fc1b13f45 100644 --- a/x_wcrm_assemble_control/src/main/java/com/x/wcrm/assemble/control/service/LeadsPermissionService.java +++ b/x_wcrm_assemble_control/src/main/java/com/x/wcrm/assemble/control/service/LeadsPermissionService.java @@ -189,6 +189,49 @@ public class LeadsPermissionService extends PermissionServiceBase { return count; } + // 获得自己负责的,和我的下属负责线索(未转化):列表 + public List 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 _me_collection = new ArrayList(); + _me_collection.add(effectivePerson.getDistinguishedName()); + + List _persons = new ArrayList(); + _persons.add(_me); + List _subNestedPersons = getListWithPersonSubNested(context, effectivePerson, _me_collection); // 所有下属 + if (ListTools.isNotEmpty(_subNestedPersons)) { + _persons = ListTools.add(_persons, true, true, _subNestedPersons); + } + // List os = business.leadsFactory().ListByOwnerList(_persons); + List 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 _me_collection = new ArrayList(); + _me_collection.add(effectivePerson.getDistinguishedName()); + + List _persons = new ArrayList(); + _persons.add(_me); + List _subNestedPersons = getListWithPersonSubNested(context, effectivePerson, _me_collection); // 所有下属 + if (ListTools.isNotEmpty(_subNestedPersons)) { + _persons = ListTools.add(_persons, true, true, _subNestedPersons); + } + // List os = business.leadsFactory().ListByOwnerList(_persons); + long count = business.leadsFactory().ListByOwnerList_NoTransform_Count(_persons, keyString); + return count; + } + /** * 根据线索的ID,获取对应的跟进记录中的最新跟进记录时间和跟进记录内容,并把时间和内容写入到线索内容中返回前端 * @param osList 线索 diff --git a/x_wcrm_assemble_control/x_wcrm_assemble_control.iml b/x_wcrm_assemble_control/x_wcrm_assemble_control.iml index 35868360cb05e86dccc337e43a61447b531720f4..a8be6b31bfaa3ea9d91048b21ed048efe5dcb885 100644 --- a/x_wcrm_assemble_control/x_wcrm_assemble_control.iml +++ b/x_wcrm_assemble_control/x_wcrm_assemble_control.iml @@ -12,7 +12,7 @@ - + @@ -21,274 +21,5 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file