| | |
| | | package com.yc.crm.base.action; |
| | | |
| | | import com.yc.action.BaseAction; |
| | | import com.yc.crm.base.entity.Page; |
| | | import com.yc.crm.base.entity.*; |
| | | import com.yc.crm.base.service.CrmServiceIfc; |
| | | import com.yc.exception.CallBackMessage; |
| | | import com.yc.multiData.SpObserver; |
| | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | @RequestMapping("/crm/base") |
| | | @RestController |
| | | public class CrmController extends BaseAction { |
| | | @Autowired |
| | | CrmServiceIfc crmServiceIfc; |
| | | |
| | | /** |
| | | * 输出下拉相关数据 |
| | | * ,-48013000:公司类型 |
| | |
| | | * 7,-48013007:社交平台 |
| | | * 8,-48013008:电话区号 |
| | | * 9,-48013009:职级 |
| | | * |
| | | * @param request |
| | | * @return |
| | | */ |
| | | @RequestMapping("/selectInfo.do") |
| | | public @ResponseBody Object selectInfo(HttpServletRequest request){ |
| | | public @ResponseBody Object selectInfo(HttpServletRequest request) { |
| | | CallBackMessage callBackMessage = new CallBackMessage(); |
| | | try { |
| | | SpObserver.setDBtoInstance("_" + request.getSession().getAttribute(SessionKey.DATA_BASE_ID)); |
| | | callBackMessage.setInfo(crmServiceIfc.getBaseInfo(request.getSession().getAttribute(SessionKey.USERCODE)+"")); |
| | | callBackMessage.setInfo(crmServiceIfc.getBaseInfo(request.getSession().getAttribute(SessionKey.USERCODE) + "")); |
| | | callBackMessage.sendSuccessMessageByDefault(); |
| | | return callBackMessage.toJSONObject(); |
| | | }catch (Exception e){ |
| | | } catch (Exception e) { |
| | | callBackMessage.sendErrorMessage(this.getErrorMsg(e)); |
| | | return callBackMessage.toJSONObject(); |
| | | }finally { |
| | | } finally { |
| | | SpObserver.setDBtoInstance(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取用户,以部门分组树形结构显示 |
| | | * |
| | | * @param request |
| | | * @return |
| | | */ |
| | | @RequestMapping("/userInfo.do") |
| | | public @ResponseBody Object userInfo(@RequestBody @Nullable Page page, HttpServletRequest request){ |
| | | public @ResponseBody Object userInfo(@RequestBody @Nullable Page page, HttpServletRequest request) { |
| | | CallBackMessage callBackMessage = new CallBackMessage(); |
| | | try { |
| | | SpObserver.setDBtoInstance("_" + request.getSession().getAttribute(SessionKey.DATA_BASE_ID)); |
| | | callBackMessage.setInfo(crmServiceIfc.getUserInfo(request.getSession(),page)); |
| | | callBackMessage.setInfo(crmServiceIfc.getUserInfo(request.getSession(), page)); |
| | | callBackMessage.sendSuccessMessageByDefault(); |
| | | return callBackMessage.toJSONObject(); |
| | | }catch (Exception e){ |
| | | } catch (Exception e) { |
| | | callBackMessage.sendErrorMessage(this.getErrorMsg(e)); |
| | | return callBackMessage.toJSONObject(); |
| | | }finally { |
| | | } finally { |
| | | SpObserver.setDBtoInstance(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 保存跟进信息 |
| | | * |
| | | * @param request |
| | | * @return |
| | | */ |
| | | @RequestMapping("/followUp/save.do") |
| | | public @ResponseBody Object followUpSave(@RequestBody T482105Entity entity, HttpServletRequest request) { |
| | | CallBackMessage callBackMessage = new CallBackMessage(); |
| | | try { |
| | | SpObserver.setDBtoInstance("_" + request.getSession().getAttribute(SessionKey.DATA_BASE_ID)); |
| | | entity.setCompanyId(request.getSession().getAttribute(SessionKey.COMPANY_ID) + ""); |
| | | entity.setCompanyName(request.getSession().getAttribute(SessionKey.COMPANY_NAME) + ""); |
| | | entity.setUserCode(request.getSession().getAttribute(SessionKey.USERCODE) + ""); |
| | | entity.setUserName(request.getSession().getAttribute(SessionKey.USERNAME) + ""); |
| | | crmServiceIfc.followUpSave(entity); |
| | | callBackMessage.sendSuccessMessageByDefault(); |
| | | return callBackMessage.toJSONObject(); |
| | | } catch (Exception e) { |
| | | callBackMessage.sendErrorMessage(this.getErrorMsg(e)); |
| | | return callBackMessage.toJSONObject(); |
| | | } finally { |
| | | SpObserver.setDBtoInstance(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 跟进列表 |
| | | * |
| | | * @param request |
| | | * @return |
| | | */ |
| | | @RequestMapping("/followUp/list.do") |
| | | public @ResponseBody Object followUpList(@RequestBody FollowUpRequestEntity entity, HttpServletRequest request) { |
| | | CallBackMessage callBackMessage = new CallBackMessage(); |
| | | try { |
| | | SpObserver.setDBtoInstance("_" + request.getSession().getAttribute(SessionKey.DATA_BASE_ID)); |
| | | entity.setDbid(request.getSession().getAttribute(SessionKey.DATA_BASE_ID) + ""); |
| | | entity.setFormid("482105"); |
| | | Response response = crmServiceIfc.followUpList(entity); |
| | | callBackMessage.setInfo(response); |
| | | callBackMessage.sendSuccessMessageByDefault(); |
| | | return callBackMessage.toJSONObject(); |
| | | } catch (Exception e) { |
| | | callBackMessage.sendErrorMessage(this.getErrorMsg(e)); |
| | | return callBackMessage.toJSONObject(); |
| | | } finally { |
| | | SpObserver.setDBtoInstance(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 删除跟进 |
| | | * |
| | | * @param request |
| | | * @return |
| | | */ |
| | | @RequestMapping("/followUp/del.do") |
| | | public @ResponseBody Object followUpDel(Integer id, HttpServletRequest request) { |
| | | CallBackMessage callBackMessage = new CallBackMessage(); |
| | | try { |
| | | SpObserver.setDBtoInstance("_" + request.getSession().getAttribute(SessionKey.DATA_BASE_ID)); |
| | | crmServiceIfc.followUpDel(id); |
| | | callBackMessage.sendSuccessMessageByDefault(); |
| | | return callBackMessage.toJSONObject(); |
| | | } catch (Exception e) { |
| | | callBackMessage.sendErrorMessage(this.getErrorMsg(e)); |
| | | return callBackMessage.toJSONObject(); |
| | | } finally { |
| | | SpObserver.setDBtoInstance(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 审计内容列表 |
| | | * |
| | | * @param request |
| | | * @return |
| | | */ |
| | | @RequestMapping("/audit/list.do") |
| | | public @ResponseBody Object personalList(@RequestBody AuditRequestEntity entity, HttpServletRequest request) { |
| | | CallBackMessage callBackMessage = new CallBackMessage(); |
| | | try { |
| | | SpObserver.setDBtoInstance("_" + request.getSession().getAttribute(SessionKey.DATA_BASE_ID)); |
| | | String userCode = request.getSession().getAttribute(SessionKey.USERCODE) + ""; |
| | | Response response = crmServiceIfc.auditList(userCode, entity); |
| | | callBackMessage.setInfo(response); |
| | | callBackMessage.sendSuccessMessageByDefault(); |
| | | return callBackMessage.toJSONObject(); |
| | | } catch (Exception e) { |
| | | callBackMessage.sendErrorMessage(this.getErrorMsg(e)); |
| | | return callBackMessage.toJSONObject(); |
| | | } finally { |
| | | SpObserver.setDBtoInstance(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 个人分组列表 |
| | | * |
| | | * @param request |
| | | * @return |
| | | */ |
| | | @RequestMapping("/personal/list.do") |
| | | public @ResponseBody Object personalList(@RequestBody T482117Entity entity, HttpServletRequest request) { |
| | | CallBackMessage callBackMessage = new CallBackMessage(); |
| | | try { |
| | | SpObserver.setDBtoInstance("_" + request.getSession().getAttribute(SessionKey.DATA_BASE_ID)); |
| | | String userCode = request.getSession().getAttribute(SessionKey.USERCODE) + ""; |
| | | List<T482117Entity> list = crmServiceIfc.personalList(userCode, entity.getGroupid()); |
| | | callBackMessage.setInfo(list); |
| | | callBackMessage.sendSuccessMessageByDefault(); |
| | | return callBackMessage.toJSONObject(); |
| | | } catch (Exception e) { |
| | | callBackMessage.sendErrorMessage(this.getErrorMsg(e)); |
| | | return callBackMessage.toJSONObject(); |
| | | } finally { |
| | | SpObserver.setDBtoInstance(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 保存个人分组 |
| | | * |
| | | * @param request |
| | | * @return |
| | | */ |
| | | @RequestMapping("/personal/save.do") |
| | | public @ResponseBody Object personalSave(@RequestBody @Nullable List<T482117Entity> list, HttpServletRequest request) { |
| | | CallBackMessage callBackMessage = new CallBackMessage(); |
| | | try { |
| | | if (list == null) { |
| | | list = new ArrayList<T482117Entity>(); |
| | | } |
| | | SpObserver.setDBtoInstance("_" + request.getSession().getAttribute(SessionKey.DATA_BASE_ID)); |
| | | String userCode = request.getSession().getAttribute(SessionKey.USERCODE) + ""; |
| | | list.stream().forEach(x -> { |
| | | x.setCompanyId(request.getSession().getAttribute(SessionKey.COMPANY_ID) + ""); |
| | | x.setCompanyName(request.getSession().getAttribute(SessionKey.COMPANY_NAME) + ""); |
| | | x.setUserCode(request.getSession().getAttribute(SessionKey.USERCODE) + ""); |
| | | x.setUserName(request.getSession().getAttribute(SessionKey.USERNAME) + ""); |
| | | }); |
| | | crmServiceIfc.personalSave(list, userCode); |
| | | callBackMessage.sendSuccessMessageByDefault(); |
| | | return callBackMessage.toJSONObject(); |
| | | } catch (Exception e) { |
| | | callBackMessage.sendErrorMessage(this.getErrorMsg(e)); |
| | | return callBackMessage.toJSONObject(); |
| | | } finally { |
| | | SpObserver.setDBtoInstance(); |
| | | } |
| | | } |
| | | /** |
| | | * 日程列表 |
| | | * |
| | | * @param request |
| | | * @return |
| | | */ |
| | | @RequestMapping("/schedule/list.do") |
| | | public @ResponseBody Object scheduleList(@RequestBody ScheduleRequestEntity entity, HttpServletRequest request) { |
| | | CallBackMessage callBackMessage = new CallBackMessage(); |
| | | try { |
| | | SpObserver.setDBtoInstance("_" + request.getSession().getAttribute(SessionKey.DATA_BASE_ID)); |
| | | String userCode = request.getSession().getAttribute(SessionKey.USERCODE) + ""; |
| | | entity.setDbid(request.getSession().getAttribute(SessionKey.DATA_BASE_ID)+""); |
| | | entity.setFormId("482112"); |
| | | Response response = crmServiceIfc.scheduleList(entity); |
| | | callBackMessage.setInfo(response); |
| | | callBackMessage.sendSuccessMessageByDefault(); |
| | | return callBackMessage.toJSONObject(); |
| | | } catch (Exception e) { |
| | | callBackMessage.sendErrorMessage(this.getErrorMsg(e)); |
| | | return callBackMessage.toJSONObject(); |
| | | } finally { |
| | | SpObserver.setDBtoInstance(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 保存日程 |
| | | * |
| | | * @param request |
| | | * @return |
| | | */ |
| | | @RequestMapping("/schedule/save.do") |
| | | public @ResponseBody Object scheduleSave(@RequestBody T482112Entity entity, HttpServletRequest request) { |
| | | CallBackMessage callBackMessage = new CallBackMessage(); |
| | | try { |
| | | SpObserver.setDBtoInstance("_" + request.getSession().getAttribute(SessionKey.DATA_BASE_ID)); |
| | | // String userCode = request.getSession().getAttribute(SessionKey.USERCODE) + ""; |
| | | entity.setCompanyId(request.getSession().getAttribute(SessionKey.COMPANY_ID) + ""); |
| | | entity.setCompanyName(request.getSession().getAttribute(SessionKey.COMPANY_NAME) + ""); |
| | | entity.setUserCode(request.getSession().getAttribute(SessionKey.USERCODE) + ""); |
| | | entity.setUserName(request.getSession().getAttribute(SessionKey.USERNAME) + ""); |
| | | crmServiceIfc.scheduleSave(entity); |
| | | callBackMessage.sendSuccessMessageByDefault(); |
| | | return callBackMessage.toJSONObject(); |
| | | } catch (Exception e) { |
| | | callBackMessage.sendErrorMessage(this.getErrorMsg(e)); |
| | | return callBackMessage.toJSONObject(); |
| | | } finally { |
| | | SpObserver.setDBtoInstance(); |
| | | } |
| | | } |
| | | /** |
| | | * 删除日程 |
| | | * |
| | | * @param request |
| | | * @return |
| | | */ |
| | | @RequestMapping("/schedule/del.do") |
| | | public @ResponseBody Object scheduleDel(Integer id, HttpServletRequest request) { |
| | | CallBackMessage callBackMessage = new CallBackMessage(); |
| | | try { |
| | | SpObserver.setDBtoInstance("_" + request.getSession().getAttribute(SessionKey.DATA_BASE_ID)); |
| | | crmServiceIfc.scheduleDel(id); |
| | | callBackMessage.sendSuccessMessageByDefault(); |
| | | return callBackMessage.toJSONObject(); |
| | | } catch (Exception e) { |
| | | callBackMessage.sendErrorMessage(this.getErrorMsg(e)); |
| | | return callBackMessage.toJSONObject(); |
| | | } finally { |
| | | SpObserver.setDBtoInstance(); |
| | | } |
| | | } |
| | | /** |
| | | * 关注日程 |
| | | * |
| | | * @param request |
| | | * @return |
| | | */ |
| | | @RequestMapping("/schedule/attention.do") |
| | | public @ResponseBody Object scheduleAttention(@RequestBody T482112Entity entity, HttpServletRequest request) { |
| | | CallBackMessage callBackMessage = new CallBackMessage(); |
| | | try { |
| | | SpObserver.setDBtoInstance("_" + request.getSession().getAttribute(SessionKey.DATA_BASE_ID)); |
| | | crmServiceIfc.scheduleAttention(entity); |
| | | callBackMessage.sendSuccessMessageByDefault(); |
| | | return callBackMessage.toJSONObject(); |
| | | } catch (Exception e) { |
| | | callBackMessage.sendErrorMessage(this.getErrorMsg(e)); |
| | | return callBackMessage.toJSONObject(); |
| | | } finally { |
| | | SpObserver.setDBtoInstance(); |
| | | } |
| | | } |
| | | /** |
| | | * 关注日程 |
| | | * |
| | | * @param request |
| | | * @return |
| | | */ |
| | | @RequestMapping("/schedule/completed.do") |
| | | public @ResponseBody Object scheduleCompleted(Integer id, HttpServletRequest request) { |
| | | CallBackMessage callBackMessage = new CallBackMessage(); |
| | | try { |
| | | SpObserver.setDBtoInstance("_" + request.getSession().getAttribute(SessionKey.DATA_BASE_ID)); |
| | | crmServiceIfc.scheduleCompleted(id); |
| | | callBackMessage.sendSuccessMessageByDefault(); |
| | | return callBackMessage.toJSONObject(); |
| | | } catch (Exception e) { |
| | | callBackMessage.sendErrorMessage(this.getErrorMsg(e)); |
| | | return callBackMessage.toJSONObject(); |
| | | } finally { |
| | | SpObserver.setDBtoInstance(); |
| | | } |
| | | } |
| | | /** |
| | | * 评论列表 |
| | | * |
| | | * @param request |
| | | * @return |
| | | */ |
| | | @RequestMapping("/comment/list.do") |
| | | public @ResponseBody Object commentList(@RequestBody CommentRequestEntity entity, HttpServletRequest request) { |
| | | CallBackMessage callBackMessage = new CallBackMessage(); |
| | | try { |
| | | SpObserver.setDBtoInstance("_" + request.getSession().getAttribute(SessionKey.DATA_BASE_ID)); |
| | | String userCode = request.getSession().getAttribute(SessionKey.USERCODE) + ""; |
| | | entity.setDbid(request.getSession().getAttribute(SessionKey.DATA_BASE_ID)+""); |
| | | entity.setUserCode(userCode); |
| | | entity.setFormId("482104"); |
| | | Response response = crmServiceIfc.commentList(entity); |
| | | callBackMessage.setInfo(response); |
| | | callBackMessage.sendSuccessMessageByDefault(); |
| | | return callBackMessage.toJSONObject(); |
| | | } catch (Exception e) { |
| | | callBackMessage.sendErrorMessage(this.getErrorMsg(e)); |
| | | return callBackMessage.toJSONObject(); |
| | | } finally { |
| | | SpObserver.setDBtoInstance(); |
| | | } |
| | | } |
| | | /** |
| | | * 删除评论 |
| | | * |
| | | * @param request |
| | | * @return |
| | | */ |
| | | @RequestMapping("/comment/del.do") |
| | | public @ResponseBody Object commentDel(Integer id, HttpServletRequest request) { |
| | | CallBackMessage callBackMessage = new CallBackMessage(); |
| | | try { |
| | | SpObserver.setDBtoInstance("_" + request.getSession().getAttribute(SessionKey.DATA_BASE_ID)); |
| | | crmServiceIfc.commentDel(id); |
| | | callBackMessage.sendSuccessMessageByDefault(); |
| | | return callBackMessage.toJSONObject(); |
| | | } catch (Exception e) { |
| | | callBackMessage.sendErrorMessage(this.getErrorMsg(e)); |
| | | return callBackMessage.toJSONObject(); |
| | | } finally { |
| | | SpObserver.setDBtoInstance(); |
| | | } |
| | | } |
| | | /** |
| | | * 保存评论 |
| | | * |
| | | * @param request |
| | | * @return |
| | | */ |
| | | @RequestMapping("/comment/save.do") |
| | | public @ResponseBody Object commentSave(@RequestBody T482104Entity entity, HttpServletRequest request) { |
| | | CallBackMessage callBackMessage = new CallBackMessage(); |
| | | try { |
| | | SpObserver.setDBtoInstance("_" + request.getSession().getAttribute(SessionKey.DATA_BASE_ID)); |
| | | // String userCode = request.getSession().getAttribute(SessionKey.USERCODE) + ""; |
| | | entity.setUserCode(request.getSession().getAttribute(SessionKey.USERCODE) + ""); |
| | | entity.setUserName(request.getSession().getAttribute(SessionKey.USERNAME) + ""); |
| | | crmServiceIfc.commentSave(entity); |
| | | callBackMessage.sendSuccessMessageByDefault(); |
| | | return callBackMessage.toJSONObject(); |
| | | } catch (Exception e) { |
| | | callBackMessage.sendErrorMessage(this.getErrorMsg(e)); |
| | | return callBackMessage.toJSONObject(); |
| | | } finally { |
| | | SpObserver.setDBtoInstance(); |
| | | } |
| | | } |