package com.yc.crm.clues.action; import com.yc.action.BaseAction; import com.yc.crm.clues.entity.AssignCluesEntity; import com.yc.crm.clues.entity.CluesRequestEntity; import com.yc.crm.clues.entity.T481101Entity; import com.yc.crm.clues.entity.T481104Entity; import com.yc.crm.clues.service.CluesServiceIfc; import com.yc.exception.CallBackMessage; import com.yc.multiData.SpObserver; import com.yc.utils.SessionKey; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletRequest; @RestController @RequestMapping("/crm/clues") public class CluesController extends BaseAction { @Autowired CluesServiceIfc cluesServiceIfc; /** * 分配线索 * @param request * @return */ @RequestMapping("/assign.do") public @ResponseBody Object assign(@RequestBody AssignCluesEntity assignClues, HttpServletRequest request){ CallBackMessage callBackMessage = new CallBackMessage(); try { SpObserver.setDBtoInstance("_" + request.getSession().getAttribute(SessionKey.DATA_BASE_ID)); cluesServiceIfc.assign(assignClues,request.getSession().getAttribute(SessionKey.USERNAME)+""); callBackMessage.sendSuccessMessageByDefault(); return callBackMessage.toJSONObject(); }catch (Exception e){ callBackMessage.sendErrorMessage(this.getErrorMsg(e)); return callBackMessage.toJSONObject(); }finally { SpObserver.setDBtoInstance(); } } /** * 新分配线索 * @param request * @return */ @RequestMapping("/newAssign.do") public @ResponseBody Object newAssign(@RequestBody AssignCluesEntity assignClues, HttpServletRequest request){ CallBackMessage callBackMessage = new CallBackMessage(); try { SpObserver.setDBtoInstance("_" + request.getSession().getAttribute(SessionKey.DATA_BASE_ID)); cluesServiceIfc.newAssign(assignClues); callBackMessage.sendSuccessMessageByDefault(); return callBackMessage.toJSONObject(); }catch (Exception e){ callBackMessage.sendErrorMessage(this.getErrorMsg(e)); return callBackMessage.toJSONObject(); }finally { SpObserver.setDBtoInstance(); } } /** * 改变线索状态 * @param request * @return */ @RequestMapping("/changeStatus.do") public @ResponseBody Object changeStatus(@RequestBody T481104Entity entity, HttpServletRequest request){ CallBackMessage callBackMessage = new CallBackMessage(); try { SpObserver.setDBtoInstance("_" + request.getSession().getAttribute(SessionKey.DATA_BASE_ID)); entity.setOwnerCode(request.getSession().getAttribute(SessionKey.USERCODE)+""); cluesServiceIfc.changeStatus(entity); callBackMessage.sendSuccessMessageByDefault(); return callBackMessage.toJSONObject(); }catch (Exception e){ callBackMessage.sendErrorMessage(this.getErrorMsg(e)); return callBackMessage.toJSONObject(); }finally { SpObserver.setDBtoInstance(); } } /** * 关注线索 * @param request * @return */ @RequestMapping("/attention.do") public @ResponseBody Object attention(@RequestBody CluesRequestEntity cluesRequest, HttpServletRequest request){ CallBackMessage callBackMessage = new CallBackMessage(); try { SpObserver.setDBtoInstance("_" + request.getSession().getAttribute(SessionKey.DATA_BASE_ID)); cluesRequest.setCreateUsercode(request.getSession().getAttribute(SessionKey.USERCODE)+"");//指定更新当前用户 cluesServiceIfc.attention(cluesRequest); callBackMessage.sendSuccessMessageByDefault(); return callBackMessage.toJSONObject(); }catch (Exception e){ callBackMessage.sendErrorMessage(this.getErrorMsg(e)); return callBackMessage.toJSONObject(); }finally { SpObserver.setDBtoInstance(); } } /** * 删除联系人 * * @param request * @return */ @RequestMapping("/contact/del.do") public @ResponseBody Object scheduleDel(Integer id, HttpServletRequest request) { CallBackMessage callBackMessage = new CallBackMessage(); try { SpObserver.setDBtoInstance("_" + request.getSession().getAttribute(SessionKey.DATA_BASE_ID)); cluesServiceIfc.contactDel(id); callBackMessage.sendSuccessMessageByDefault(); return callBackMessage.toJSONObject(); } catch (Exception e) { callBackMessage.sendErrorMessage(this.getErrorMsg(e)); return callBackMessage.toJSONObject(); } finally { SpObserver.setDBtoInstance(); } } /** * 获取线索 * @param request * @return */ @RequestMapping("/get.do") public @ResponseBody Object get(@RequestBody CluesRequestEntity cluesRequest, HttpServletRequest request){ CallBackMessage callBackMessage = new CallBackMessage(); try { SpObserver.setDBtoInstance("_" + request.getSession().getAttribute(SessionKey.DATA_BASE_ID)); cluesRequest.setDbid(request.getSession().getAttribute(SessionKey.DATA_BASE_ID)+""); cluesRequest.setFormId(481101); callBackMessage.setInfo(cluesServiceIfc.get(cluesRequest)); callBackMessage.sendSuccessMessageByDefault(); return callBackMessage.toJSONObject(); }catch (Exception e){ callBackMessage.sendErrorMessage(this.getErrorMsg(e)); return callBackMessage.toJSONObject(); }finally { SpObserver.setDBtoInstance(); } } /** * 删除线索 * * @param request * @return */ @RequestMapping("/del.do") public @ResponseBody Object cluesDel(String docCode, HttpServletRequest request) { CallBackMessage callBackMessage = new CallBackMessage(); try { SpObserver.setDBtoInstance("_" + request.getSession().getAttribute(SessionKey.DATA_BASE_ID)); cluesServiceIfc.cluesDel(docCode); callBackMessage.sendSuccessMessageByDefault(); return callBackMessage.toJSONObject(); } catch (Exception e) { callBackMessage.sendErrorMessage(this.getErrorMsg(e)); return callBackMessage.toJSONObject(); } finally { SpObserver.setDBtoInstance(); } } /** * 无效线索 * * @param request * @return */ @RequestMapping("/fail.do") public @ResponseBody Object cluesFail(@RequestBody T481104Entity entity, HttpServletRequest request) { CallBackMessage callBackMessage = new CallBackMessage(); try { SpObserver.setDBtoInstance("_" + request.getSession().getAttribute(SessionKey.DATA_BASE_ID)); cluesServiceIfc.cluesFail(entity); callBackMessage.sendSuccessMessageByDefault(); return callBackMessage.toJSONObject(); } catch (Exception e) { callBackMessage.sendErrorMessage(this.getErrorMsg(e)); return callBackMessage.toJSONObject(); } finally { SpObserver.setDBtoInstance(); } } /** * 线索联系人列表 * @param request * @return */ @RequestMapping("/contactList.do") public @ResponseBody Object contactList(@RequestBody CluesRequestEntity cluesRequest, HttpServletRequest request){ CallBackMessage callBackMessage = new CallBackMessage(); try { SpObserver.setDBtoInstance("_" + request.getSession().getAttribute(SessionKey.DATA_BASE_ID)); cluesRequest.setDbid(request.getSession().getAttribute(SessionKey.DATA_BASE_ID)+""); //当前用户 cluesRequest.setCreateUsercode(request.getSession().getAttribute(SessionKey.USERCODE)+""); //所属部门 cluesRequest.setCccode(request.getSession().getAttribute(SessionKey.CCCODE)+""); cluesRequest.setFormId(481101); callBackMessage.setInfo(cluesServiceIfc.contactList(cluesRequest)); callBackMessage.sendSuccessMessageByDefault(); return callBackMessage.toJSONObject(); }catch (Exception e){ callBackMessage.sendErrorMessage(this.getErrorMsg(e)); return callBackMessage.toJSONObject(); }finally { SpObserver.setDBtoInstance(); } } /** * 线索列表 * @param request * @return */ @RequestMapping("/list.do") public @ResponseBody Object list(@RequestBody CluesRequestEntity cluesRequest, HttpServletRequest request){ CallBackMessage callBackMessage = new CallBackMessage(); try { SpObserver.setDBtoInstance("_" + request.getSession().getAttribute(SessionKey.DATA_BASE_ID)); cluesRequest.setDbid(request.getSession().getAttribute(SessionKey.DATA_BASE_ID)+""); //当前用户 cluesRequest.setCreateUsercode(request.getSession().getAttribute(SessionKey.USERCODE)+""); //所属部门 cluesRequest.setCccode(request.getSession().getAttribute(SessionKey.CCCODE)+""); cluesRequest.setFormId(481101); callBackMessage.setInfo(cluesServiceIfc.getAllClues(cluesRequest)); callBackMessage.sendSuccessMessageByDefault(); return callBackMessage.toJSONObject(); }catch (Exception e){ callBackMessage.sendErrorMessage(this.getErrorMsg(e)); return callBackMessage.toJSONObject(); }finally { SpObserver.setDBtoInstance(); } } /** * 编辑线索 * @param clues * @param request * @param response * @return */ @RequestMapping("/save.do") public @ResponseBody Object saveClues(@RequestBody T481101Entity clues, HttpServletRequest request){ CallBackMessage callBackMessage = new CallBackMessage(); try { SpObserver.setDBtoInstance("_" + request.getSession().getAttribute(SessionKey.DATA_BASE_ID)); clues.setCompanyid(request.getSession().getAttribute(SessionKey.COMPANY_ID)+""); clues.setCompanyname(request.getSession().getAttribute(SessionKey.COMPANY_NAME)+""); clues.setCreateUsercode(request.getSession().getAttribute(SessionKey.USERCODE)+""); clues.setCreateUserName(request.getSession().getAttribute(SessionKey.USERNAME)+""); clues.setCcCode(request.getSession().getAttribute(SessionKey.CCCODE)+""); clues.setCcName(request.getSession().getAttribute(SessionKey.CCNAME)+""); clues.setFormId(481101); cluesServiceIfc.save(clues); callBackMessage.sendSuccessMessageByDefault(); return callBackMessage.toJSONObject(); }catch (Exception e){ callBackMessage.sendErrorMessage(this.getErrorMsg(e)); return callBackMessage.toJSONObject(); }finally { SpObserver.setDBtoInstance(); } } }