📄 relationmanageimpl.java
字号:
/**
* 更新实体状态
* @param entityCode实体编码
* @param entityId实体ID
* @param flag 状态
* @param relationStatus 关联实体状态
* @throws ApplicationException
*/
public void updateEntitysStates(int modifyManId, String modifyTime, int entityCode, int entityId, int flag, int relationStatus) throws ApplicationException {
try{
switch(entityCode) {
case ClassCodeMgr.CUSTOMERINT ://若是客户
logger.debug("有到这里吗..."+entityId);
//先更改其联系人的状态
contactDao.updateContacts(modifyManId, modifyTime, entityId, relationStatus);
//更改业务机会的状态---间接删除
busiOpportDao.updateBusiOpports(modifyManId, modifyTime, entityId, relationStatus);
//更新活动--任务的状态---间接删除
taskDAO.updateTasks(modifyManId, modifyTime, CorrelationConstant.CUSTOMERRELATION, entityId, relationStatus);
//更新事件的状态---间接删除
eventDAO.updateEvents(modifyManId, modifyTime, CorrelationConstant.CUSTOMERRELATION, entityId, relationStatus);
//更新客户的状态---直接删除
customerDao.updateCustomers(modifyManId, modifyTime, entityId, flag);
break;
case ClassCodeMgr.CUSTOMER_CONTACTINT ://若是联系人
//删除相关的任务---间接删除
taskDAO.updateTasksByContactId(modifyManId, modifyTime, entityId, relationStatus);
//删除相关的事件---间接删除
eventDAO.updateEventsByContactId(modifyManId, modifyTime, entityId, relationStatus);
//删除联系人
contactDao.updateContactById(modifyManId, modifyTime, entityId, flag);
break;
case ClassCodeMgr.BUSINESS_OPPORTINT ://诺是业务机会
//更新活动--任务的状态---间接删除
taskDAO.updateTasks(modifyManId, modifyTime, CorrelationConstant.BUSIOPPORTRELATION, entityId, relationStatus);
//更新事件的状态---间接删除
eventDAO.updateEvents(modifyManId, modifyTime, CorrelationConstant.BUSIOPPORTRELATION, entityId, relationStatus);
//删除业务机会本身
busiOpportDao.updateBusiOpportById(modifyManId, modifyTime, entityId, flag);
break;
case ClassCodeMgr.ACTIVITYRASKINT ://诺是任务
//更新活动--任务的状态
logger.debug("任务的状态..."+flag);
taskDAO.updateTaskById(modifyManId, modifyTime, entityId, flag);
break;
case ClassCodeMgr.EVENTCODEINT :
//更新事件的状态
logger.debug("事件的状态..."+flag);
eventDAO.updateEventById(modifyManId, modifyTime, entityId, flag);
break;
default :break;
}
}catch(Exception e) {
e.printStackTrace();
logger.error("update entity failure !");
throw new ApplicationException("update entity failure !");
}
}
/**
* 查找所有的删除项
* @param flag删除标记
* @return
* @throws ApplicationException
*/
public List<DeleteItemVo> getAllDeleteItem(User user, int flag) throws ApplicationException {
try{
//初始化被删除项
List<DeleteItemVo> deleteItems = new ArrayList<DeleteItemVo>();
//查找所有删除状态的客户
List customers = customerDao.getCustomerByDelete(user, flag);
if(customers != null) {
for(Object o : customers) {
Customer cust = (Customer)o;
//查找删除人
User deleteMan = customerDao.getUserById(cust.getModifyManId());
deleteItems.add(new DeleteItemVo(cust.getId(), cust.getCustomerName(), ClassCodeMgr.CUSTOMERINT,
deleteMan.getFamilyName(), cust.getLastModifyTime()));
}
}
//查找所有被删除的联系人
List contacts = contactDao.getContactByDelete(user, flag);
if(contacts != null) {
for(Object o : contacts) {
CustomerContact contact = (CustomerContact)o;
//查找删除人
User deleteMan = contactDao.getUserById(contact.getModifyManId());
deleteItems.add(new DeleteItemVo(contact.getId(), contact.getName(), ClassCodeMgr.CUSTOMER_CONTACTINT,
deleteMan.getFamilyName(), contact.getLastModifyTime()));
}
}
//查找所有被删除的业务机会
List busiOpports = busiOpportDao.getBusiOpportByDelete(user, flag);
if(busiOpports != null) {
for(Object o : busiOpports) {
BusinessOpportunity busiOpport = (BusinessOpportunity)o;
User deleteMan = contactDao.getUserById(busiOpport.getModifyManId());
deleteItems.add(new DeleteItemVo(busiOpport.getId(), busiOpport.getBusiOpportName(), ClassCodeMgr.BUSINESS_OPPORTINT,
deleteMan.getFamilyName(), busiOpport.getLastModifyTime()));
}
}
//查找所有被删除的任务
List tasks = taskDAO.getTasksByDelete(user, flag);
if(tasks != null) {
for(Object o : tasks) {
ActivityTask task = (ActivityTask)o;
User deleteMan = contactDao.getUserById(task.getModifyManId());
deleteItems.add(new DeleteItemVo(task.getId(), task.getSubject(), ClassCodeMgr.ACTIVITYRASKINT,
deleteMan.getFamilyName(), task.getLastModifyTime()));
}
}
//查找所有删除的事件
List events = eventDAO.getEventByDelete(user, flag);
logger.debug("有几个已经删除的事件.."+events);
if(events != null) {
for(Object o : events) {
Event event = (Event)o;
User deleteMan = contactDao.getUserById(event.getModifyManId());
deleteItems.add(new DeleteItemVo(event.getId(), event.getSubject(), ClassCodeMgr.EVENTCODEINT,
deleteMan.getFamilyName(), event.getLastModifyTime()));
}
}
return deleteItems;
}catch(Exception e) {
e.printStackTrace();
logger.error("get delete item failure !");
throw new ApplicationException("get delete item failure !");
}
}
/**
* 根据类型删除数据
* @param user
* @param flag
* @param name
* @param type
* @throws ApplicationException
*/
public void deleteDatas(int customerId, int flag, int type) throws ApplicationException {
try{
//若是客户
switch(type) {
case ClassCodeMgr.CUSTOMERINT ://若是客户
//先删除其联系人
logger.debug("要删除联系人吗...");
contactDao.deleteByCustomerId(customerId, flag);
//删除其业务机会
busiOpportDao.deleteByCustomerId(customerId, flag);
//删除任务
//删除事件
//删除客户本身
break;
case ClassCodeMgr.CUSTOMER_CONTACTINT:
logger.debug("dddddddddddddddd");
//删除任务
//删除事件
//删除联系人本身
break;
case ClassCodeMgr.BUSINESS_OPPORTINT:
//by 张明强
//删除业务机会
int busiOpportID = customerId;
BusinessOpportunity busiOpport = busiOpportDao.getById(busiOpportID);
//通过主键(busiOpportID)删除业务机会
busiOpportDao.deleteByObject(busiOpport);
//删除阶段历史
List<BusinessOpportunityStageHistory> boshList = boshDAO.getByBusiOpportID(busiOpportID);
for(int i = 0; i< boshList.size() ; i++){
boshDAO.deleteByObject(boshList.get(i));
logger.debug("删除第"+(i+1)+"条阶段历史记录");
}
break;
case ClassCodeMgr.ACTIVITYRASKINT:
logger.debug("bbbbbbbbbbb");
//by 张明强
//删除任务
int activityTaskID = customerId;
ActivityTask at = taskDAO.getTsakById(activityTaskID);
taskDAO.deleteByObject(at);
break;
case ClassCodeMgr.EVENTCODEINT:
logger.debug("ccccccccccccccc");
//删除事件
break;
}
}catch(SystemException e) {
e.printStackTrace();
logger.debug(e.getMessage());
throw new ApplicationException(e.getMessage());
}
}
/**
* 根据类型查找搜索数据
* @param user 用户
* @param flag 标记
* @param name 搜索名称
* @param type 类型
* @return
* @throws ApplicationException
*/
public List getSearchDataByData(User user, int flag, String name, int type) throws ApplicationException {
try{
List datas = new ArrayList();
switch(type) {
case ClassCodeMgr.CUSTOMERINT ://若是客户
List customers = customerDao.getCustoemrsByNameLike(flag, user, name);
if(customers != null) {
for(Object o : customers) {
Customer c = (Customer)o;
//取得客户所有人
User userof = c.getUser();
datas.add(new CustomerVo(c.getId(), c.getCustomerName(), c.getPhone(), userof));
}
}
break;
case ClassCodeMgr.CUSTOMER_CONTACTINT ://若是联系人
List contacts = contactDao.getContactsByName(user, name, flag);
if(contacts != null) {
for(Object o : contacts) {
CustomerContact contact = (CustomerContact)o;
//联系人所有人
User userof = contact.getUser();
//联系人的所属客户
Customer customer = contact.getCustomer();
if(customer != null) {//若客户不为空
datas.add(new ContactVo(contact.getId(), contact.getName(), contact.getComPhone(),
contact.getEmail(), customer.getId(), customer.getCustomerName(),
userof));
}else {//若客户为空
datas.add(new ContactVo(contact.getId(), contact.getName(), contact.getComPhone(),
contact.getEmail(), userof));
}
}
}
break;
case ClassCodeMgr.BUSINESS_OPPORTINT ://若是业务机会
List busiOpports = busiOpportDao.getBusiOpportsByNameLike(user, flag, name);
if(busiOpports != null) {
for(Object o : busiOpports) {
BusinessOpportunity busiOpport = (BusinessOpportunity)o;
//查找业务机会对应的客户
Customer customer = busiOpport.getCustomer();
//业务机会所有人
User userof = busiOpport.getUser();
datas.add(new BusinessOpportunityVo(busiOpport.getId(), busiOpport.getBusiOpportName(),
busiOpport.getPreTransactionDate(), busiOpport.getStageOf(), customer.getId(),
customer.getCustomerName(), userof));
}
}
break;
case ClassCodeMgr.ACTIVITYRASKINT ://若是任务
List tasks = taskDAO.getTasksBySubjectLike(user, flag, name);
if(tasks != null) {
for(Object o : tasks) {
ActivityTask task = (ActivityTask)o;
//被分配人
User assigner = customerDao.getUserById(task.getAssignerId());
CustomerContact contact = task.getCustomerContact();
if(contact != null) {//若联系人不为空
datas.add(new ActivityTaskVo(task.getId(), task.getSubject(), task.getExecuteState(),
task.getFunctionId(), task.getRecordId(),getRecordName(task.getFunctionId(), task.getRecordId()), task.getFinalTime(), task.getBeFirst(), assigner.getId(), assigner.getFamilyName(), task.getLastModifyTime(),
contact.getId(), contact.getName()));
}else {
datas.add(new ActivityTaskVo(task.getId(), task.getSubject(), task.getExecuteState(),
task.getFunctionId(), task.getRecordId(),getRecordName(task.getFunctionId(), task.getRecordId()), task.getFinalTime(), task.getBeFirst(), assigner.getId(), assigner.getFamilyName(), task.getLastModifyTime()));
}
}
}
break;
case ClassCodeMgr.EVENTCODEINT ://若是事件
List events = eventDAO.getEventsBySujectLike(user, flag, name);
if(events != null) {
for(Object o : events) {
Event event = (Event)o;
//被分配人
User assigner = customerDao.getUserById(event.getAssignerId());
//联系人
CustomerContact contact = event.getCustomerContact();
if(contact != null) {
datas.add(new EventVo(event.getId(), event.getUser(), event.getSubject(),
event.getEndTime(), event.getFunctionId(), event.getRecordId(), getRecordName(event.getFunctionId(), event.getRecordId()),
contact.getId(), contact.getName(),
event.getLastModifyTime(), event.getModifyManId(), assigner.getId(), assigner.getFamilyName()));
}else {
datas.add(new EventVo(event.getId(), event.getUser(), event.getSubject(),
event.getEndTime(), event.getFunctionId(), event.getRecordId(), getRecordName(event.getFunctionId(), event.getRecordId()),
event.getLastModifyTime(), event.getModifyManId(), assigner.getId(), assigner.getFamilyName()));
}
}
}
break;
default:
break;
}
return datas;
}catch(Exception e) {
e.printStackTrace();
logger.error("find the search data error!");
throw new ApplicationException("find the search data error!");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -