package com.yc.open.mutual.controller;
|
|
import com.alibaba.fastjson.JSON;
|
import com.google.gson.Gson;
|
import com.yc.MaintenanceFee.schedule.MaintainPayMessageGate;
|
import com.yc.entity.AttachmentConfig;
|
import com.yc.entity.DataSourceEntity;
|
import com.yc.entity.attachment.AttachmentEntity;
|
import com.yc.entity.attachment.AttachmentWhereEntity;
|
import com.yc.exception.ApplicationException;
|
import com.yc.exception.CallBackMessage;
|
import com.yc.factory.FactoryBean;
|
import com.yc.multiData.MultiDataSource;
|
import com.yc.multiData.SpObserver;
|
import com.yc.open.controller.BaseController;
|
import com.yc.open.init.InitSystemTaks;
|
import com.yc.open.init.Task;
|
import com.yc.open.mutual.entity.*;
|
import com.yc.open.mutual.schedule.CanelProcBy130301;
|
import com.yc.open.mutual.schedule.CanelProcBy150201;
|
import com.yc.open.mutual.schedule.CanelProcBy150206;
|
import com.yc.open.mutual.schedule.MutualSchedule;
|
import com.yc.open.mutual.service.MutualServiceIfc;
|
import com.yc.open.ufida.schedule.UfidaCanelProcBy130301;
|
import com.yc.sdk.WebSocketMessage.entity.MessageType;
|
import com.yc.sdk.jedis.RedisKey;
|
import com.yc.sdk.shopping.action.api.GenerationQrCodeForApp;
|
import com.yc.sdk.shopping.action.api.KdniaoTrackQueryAPI;
|
import com.yc.sdk.shopping.entity.KdniaoOrderEntity;
|
import com.yc.sdk.shopping.entity.KdniaoOrderTracesEntity;
|
import com.yc.sdk.shopping.entity.QrCodeForAppEntity;
|
import com.yc.sdk.shopping.service.imagedata.ShoppingImageDataIfc;
|
import com.yc.sdk.weixincp.util.UploadFiles;
|
import com.yc.service.BaseService;
|
import com.yc.service.upload.AttachmentIfc;
|
import com.yc.utils.SessionKey;
|
import org.apache.commons.lang.RandomStringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.data.redis.core.RedisTemplate;
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
import org.springframework.util.FileCopyUtils;
|
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;
|
import javax.servlet.http.HttpServletResponse;
|
import java.io.IOException;
|
import java.io.InputStream;
|
import java.net.HttpURLConnection;
|
import java.net.URL;
|
import java.net.URLDecoder;
|
import java.net.URLEncoder;
|
import java.util.*;
|
import java.util.concurrent.TimeUnit;
|
|
/**
|
* 总部与经销商相关接口
|
*/
|
@RestController
|
public class MutualController extends BaseController {
|
@Autowired
|
ShoppingImageDataIfc imgData;
|
@Autowired
|
MutualServiceIfc mutualServiceIfc;
|
@Autowired
|
MutualSchedule mutualSchedule;
|
@Autowired
|
ThreadPoolTaskExecutor threadPoolExecutor;
|
@Autowired
|
BaseController baseController;
|
@Autowired
|
KdniaoTrackQueryAPI kdniaoTrackQueryAPI;
|
@Autowired
|
private AttachmentIfc attachmentIfc;
|
|
/**
|
* 更新数据源SystemAccessKey为空的key
|
*
|
* @param request
|
* @param response
|
* @return
|
*/
|
@RequestMapping(value = "/mutual/createkey.do")
|
@ResponseBody
|
public Object createkey(HttpServletRequest request, HttpServletResponse response) {
|
CallBackMessage callBackMessage = new CallBackMessage();
|
try {
|
SpObserver.setDBtoDemo();
|
BaseService baseService = (BaseService) FactoryBean.getBean("BaseService");
|
//取出demo所有数据源的accesskey,只更新accesskey为空的记录
|
final List<Map<String, Object>> list = baseService.getJdbcTemplate().queryForList(" select id from gsystem where isnull(SystemAccessKey,'')=''");
|
|
StringBuilder stringBuilder = new StringBuilder();
|
for (Map map : list) {
|
//key
|
String key = RandomStringUtils.randomAlphanumeric(16);
|
stringBuilder.append(" update a set a.SystemAccessKey='" + key + "' from gsystem a where a.id=" + map.get("id") + "\n");
|
}
|
baseService.getJdbcTemplate().execute(stringBuilder.toString());
|
callBackMessage.sendSuccessMessageByDefault();
|
return callBackMessage.toJSONObject();
|
} catch (Exception ex) {
|
ex.printStackTrace();
|
callBackMessage.sendErrorMessage(ex.getMessage());
|
return callBackMessage.toJSONObject();
|
} finally {
|
SpObserver.setDBtoInstance();
|
}
|
}
|
|
/**
|
* 生成互认二维码图片,内容包括:dbid,域名,公司名称,截图发给另一方进行互认前的身份确认
|
*
|
* @param request
|
* @param response
|
*/
|
@RequestMapping(value = "/mutual/createQrCode.do")
|
@ResponseBody
|
public Object createQrCode(HttpServletRequest request, HttpServletResponse response) {
|
CallBackMessage callBackMessage = new CallBackMessage();
|
try {
|
String dbId = request.getSession().getAttribute(SessionKey.DATA_BASE_ID) + "";
|
SpObserver.setDBtoInstance("_" + dbId);
|
String userCode = request.getSession().getAttribute(SessionKey.USERCODE) + "";
|
String userName = request.getSession().getAttribute(SessionKey.USER_NAME) + "";
|
String companyName = request.getSession().getAttribute(SessionKey.COMPANY_NAME) + "";
|
String domain = request.getSession().getAttribute(SessionKey.DOMAIN) + "";
|
RedisTemplate redisTemplate = (RedisTemplate) FactoryBean.getBean("redisTemplate");
|
Object object = redisTemplate.opsForValue().get(RedisKey.MUTUAL_QRCODE + ":" + dbId + ":" + userCode);
|
if (object != null) {
|
//取缓存
|
callBackMessage.setInfo(object);
|
} else {
|
//生成新的二维码图片
|
QrCodeForAppEntity qrCodeForAppEntity = new QrCodeForAppEntity();
|
qrCodeForAppEntity.setAction(QrCodeForAppEntity.AUTH); // 设置行为 Action
|
//加内容
|
Map map = new HashMap();
|
Map info = new HashMap();
|
map.put("companyName", companyName);
|
map.put("userName", userName);
|
map.put("dbId", dbId);
|
map.put("userCode", userCode);
|
map.put("msgType", MessageType.MUTUAL_AUTH);
|
map.put("domain", domain);
|
map.put("logo", domain + getLogo(dbId));
|
map.put("setup", 0);//第一步
|
info.put("qrCodeType", MessageType.MUTUAL_AUTH);
|
info.put("qrCodeData", map);
|
String txt = JSON.toJSONString(info);
|
qrCodeForAppEntity.setAuthorCode(userCode);
|
qrCodeForAppEntity.setAuthorName(userName);
|
qrCodeForAppEntity = GenerationQrCodeForApp.saveQrCodeForApp(qrCodeForAppEntity, false);
|
String url = imgData.getImageUrl(qrCodeForAppEntity.getQrCodeUnid(), 250, 250, true, false, request);
|
//--写入redis
|
//--写入这个是为了避免重复生成,7天一次。
|
redisTemplate.opsForValue().set(RedisKey.MUTUAL_QRCODE + ":" + dbId + ":" + userCode, url, 7, TimeUnit.DAYS);
|
redisTemplate.opsForValue().set(RedisKey.MUTUAL_QRCODE + ":" + qrCodeForAppEntity.getQrCode(), txt, 7, TimeUnit.DAYS);
|
//----
|
callBackMessage.setInfo(url);
|
}
|
callBackMessage.sendSuccessMessageByDefault();
|
return callBackMessage.toJSONObject();
|
} catch (Exception e) {
|
callBackMessage.sendErrorMessage(e.getCause() != null ? (e.getCause().getMessage()).trim() : e.getMessage());
|
return callBackMessage.toJSONObject();
|
} finally {
|
SpObserver.setDBtoInstance();
|
}
|
}
|
|
public String getLogo(String dbId) {
|
try {
|
SpObserver.setDBtoDemo();
|
String sql = " set nocount on \n declare @dbid int = ? \n";
|
sql += " select case when isnull(CONVERT(varchar(MAX), CONVERT(varbinary(MAX), LogoIcon)),'')='' then 0 else 1 end from gsystem where id= @dbid ";
|
BaseService baseServer = (BaseService) FactoryBean.getBean("BaseService");
|
Integer result = baseServer.getJdbcTemplate().queryForObject(sql, Integer.class, dbId);
|
if (result == 0) {
|
//表示没有上传Logo,取默认
|
return "/images/login/logo.png";
|
} else {
|
//取上传logo
|
return "/images/login/" + dbId + "/logo.png";
|
}
|
} finally {
|
SpObserver.setDBtoInstance();
|
}
|
}
|
|
/**
|
* API认证日志写到onbus系统
|
*
|
* @param request
|
* @param response
|
* @return
|
*/
|
@RequestMapping(value = "/mutual/saveLogToOnbus.do")
|
@ResponseBody
|
public Object saveLogToOnbus(@RequestBody MutualEntity mutualEntity, HttpServletRequest request, HttpServletResponse response) {
|
CallBackMessage callBackMessage = new CallBackMessage();
|
try {
|
SpObserver.setDBtoInstance("_338");
|
mutualServiceIfc.saveLogs(mutualEntity);
|
callBackMessage.sendSuccessMessageByDefault();
|
return callBackMessage.toJSONObject();
|
} finally {
|
SpObserver.setDBtoInstance();
|
}
|
}
|
|
/**
|
* 取客户表
|
*
|
* @param request
|
* @param response
|
* @return
|
*/
|
@RequestMapping(value = "/mutual/get110203List.do")
|
@ResponseBody
|
public Object get110203List(String cltName, Integer pageNumber, HttpServletRequest request, HttpServletResponse response) {
|
CallBackMessage callBackMessage = new CallBackMessage();
|
try {
|
String dbId = request.getSession().getAttribute(SessionKey.DATA_BASE_ID) + "";
|
SpObserver.setDBtoInstance("_" + dbId);
|
if (pageNumber == null || pageNumber <= 0) pageNumber = 1;
|
List list = mutualServiceIfc.get110203List(cltName, pageNumber);
|
callBackMessage.setInfo(list);
|
callBackMessage.sendSuccessMessageByDefault();
|
return callBackMessage.toJSONObject();
|
} catch (Exception e) {
|
callBackMessage.sendErrorMessage(e.getCause() != null ? (e.getCause().getMessage()).trim() : e.getMessage());
|
return callBackMessage.toJSONObject();
|
} finally {
|
SpObserver.setDBtoInstance();
|
}
|
}
|
|
/**
|
* 取供应商表
|
*
|
* @param request
|
* @param response
|
* @return
|
*/
|
@RequestMapping(value = "/mutual/get110302List.do")
|
@ResponseBody
|
public Object get110302List(String vndName, Integer pageNumber, HttpServletRequest request, HttpServletResponse response) {
|
CallBackMessage callBackMessage = new CallBackMessage();
|
try {
|
String dbId = request.getSession().getAttribute(SessionKey.DATA_BASE_ID) + "";
|
SpObserver.setDBtoInstance("_" + dbId);
|
if (pageNumber == null || pageNumber <= 0) pageNumber = 1;
|
List list = mutualServiceIfc.get110302List(vndName, pageNumber);
|
callBackMessage.setInfo(list);
|
callBackMessage.sendSuccessMessageByDefault();
|
return callBackMessage.toJSONObject();
|
} catch (Exception e) {
|
callBackMessage.sendErrorMessage(e.getCause() != null ? (e.getCause().getMessage()).trim() : e.getMessage());
|
return callBackMessage.toJSONObject();
|
} finally {
|
SpObserver.setDBtoInstance();
|
}
|
}
|
|
/**
|
* 供应商同意授权--把客户dbid写到对应的客户表
|
*
|
* @param request
|
* @param response
|
* @return
|
*/
|
@RequestMapping(value = "/mutual/save110203.do")
|
@ResponseBody
|
public Object save110203(@RequestBody SaveEntity saveEntity, HttpServletRequest request, HttpServletResponse response) {
|
CallBackMessage callBackMessage = new CallBackMessage();
|
try {
|
String newDbId = request.getSession().getAttribute(SessionKey.DATA_BASE_ID) + "";
|
SpObserver.setDBtoInstance("_" + newDbId);
|
Integer result = mutualServiceIfc.save110203(saveEntity);
|
if (result == 0) {
|
throw new ApplicationException("绑定【" + saveEntity.getCltCode() + "】客户关系出错!");
|
}
|
//--清除redis离线消息
|
RedisTemplate redisTemplate = (RedisTemplate) FactoryBean.getBean("redisTemplate");
|
redisTemplate.delete(RedisKey.MUTUAL_QRCODE + ":" + newDbId + ":offline:" + request.getSession().getAttribute(SessionKey.USERCODE));
|
callBackMessage.sendSuccessMessageByDefault();
|
return callBackMessage.toJSONObject();
|
} catch (Exception e) {
|
callBackMessage.sendErrorMessage(e.getCause() != null ? (e.getCause().getMessage()).trim() : e.getMessage());
|
return callBackMessage.toJSONObject();
|
} finally {
|
SpObserver.setDBtoInstance();
|
}
|
}
|
|
/**
|
* 经销商同意授权--把供应商dbid写到对应的供应商表
|
*
|
* @param request
|
* @param response
|
* @return
|
*/
|
@RequestMapping(value = "/mutual/save110302.do")
|
@ResponseBody
|
public Object save110302(@RequestBody SaveEntity saveEntity, HttpServletRequest request, HttpServletResponse response) {
|
CallBackMessage callBackMessage = new CallBackMessage();
|
try {
|
String newDbId = request.getSession().getAttribute(SessionKey.DATA_BASE_ID) + "";
|
SpObserver.setDBtoInstance("_" + newDbId);
|
Integer result = mutualServiceIfc.save110302(saveEntity);
|
if (result == 0) {
|
throw new ApplicationException("绑定【" + saveEntity.getVndCode() + "】供应商关系出错!");
|
}
|
//--清除redis离线消息
|
RedisTemplate redisTemplate = (RedisTemplate) FactoryBean.getBean("redisTemplate");
|
redisTemplate.delete(RedisKey.MUTUAL_QRCODE + ":" + newDbId + ":offline:" + request.getSession().getAttribute(SessionKey.USERCODE));
|
callBackMessage.sendSuccessMessageByDefault();
|
return callBackMessage.toJSONObject();
|
} catch (Exception e) {
|
callBackMessage.sendErrorMessage(e.getCause() != null ? (e.getCause().getMessage()).trim() : e.getMessage());
|
return callBackMessage.toJSONObject();
|
} finally {
|
SpObserver.setDBtoInstance();
|
}
|
}
|
|
/**
|
* 根据action获取已绑定的供应商,客户列表
|
*
|
* @param request
|
* @param response
|
* @return
|
*/
|
@RequestMapping(value = "/mutual/authList.do")
|
@ResponseBody
|
public Object authList(Integer pageNumber, Integer action, String searchTxt, HttpServletRequest request, HttpServletResponse response) {
|
CallBackMessage callBackMessage = new CallBackMessage();
|
try {
|
String newDbId = request.getSession().getAttribute(SessionKey.DATA_BASE_ID) + "";
|
SpObserver.setDBtoInstance("_" + newDbId);
|
if (action == null || (action.intValue() != 110203 && action.intValue() != 110302)) {
|
throw new ApplicationException("action参数取值只能取110203或110302");
|
}
|
List list = null;
|
if (pageNumber == null || pageNumber <= 0) pageNumber = 1;
|
if (action.intValue() == 110203) {
|
//--已绑定客户表
|
list = mutualServiceIfc.get110203ListByMutualed(searchTxt, pageNumber);
|
} else {
|
//已绑定供应商表
|
list = mutualServiceIfc.get110302ListByMutualed(searchTxt, pageNumber);
|
}
|
callBackMessage.setInfo(list);
|
callBackMessage.sendSuccessMessageByDefault();
|
return callBackMessage.toJSONObject();
|
} catch (Exception e) {
|
callBackMessage.sendErrorMessage(e.getCause() != null ? (e.getCause().getMessage()).trim() : e.getMessage());
|
return callBackMessage.toJSONObject();
|
} finally {
|
SpObserver.setDBtoInstance();
|
}
|
}
|
|
/**
|
* 变更供应商关系
|
*
|
* @param oldVndCode --已绑定的供应商
|
* @param newVndCode --要变更的供应商
|
* @return
|
*/
|
@RequestMapping(value = "/mutual/changeRef110302.do")
|
@ResponseBody
|
public Object changeRef110302(Integer dbId, String oldVndCode, String newVndCode, HttpServletRequest request, HttpServletResponse response) {
|
CallBackMessage callBackMessage = new CallBackMessage();
|
try {
|
String newDbId = request.getSession().getAttribute(SessionKey.DATA_BASE_ID) + "";
|
SpObserver.setDBtoInstance("_" + newDbId);
|
if (StringUtils.isBlank(newVndCode)) {
|
throw new ApplicationException("newVndCode参数不能为空");
|
}
|
if (StringUtils.isBlank(oldVndCode)) {
|
throw new ApplicationException("oldVndCode参数不能为空");
|
}
|
if (dbId == null || dbId.intValue() <= 0) {
|
throw new ApplicationException("dbId参数值要大于0");
|
}
|
Integer result = mutualServiceIfc.doChangeRef110302(dbId, oldVndCode, newVndCode);
|
if (result == 0) {
|
throw new ApplicationException("变更【" + oldVndCode + "】供应商关系出错!");
|
}
|
callBackMessage.sendSuccessMessageByDefault();
|
return callBackMessage.toJSONObject();
|
} catch (Exception e) {
|
callBackMessage.sendErrorMessage(e.getCause() != null ? (e.getCause().getMessage()).trim() : e.getMessage());
|
return callBackMessage.toJSONObject();
|
} finally {
|
SpObserver.setDBtoInstance();
|
}
|
}
|
|
/**
|
* 变更客户关系
|
*
|
* @param oldCltCode --已绑定的客户
|
* @param newCltCode --要变更的客户
|
* @return
|
*/
|
@RequestMapping(value = "/mutual/changeRef110203.do")
|
@ResponseBody
|
public Object changeRef110203(Integer dbId, String oldCltCode, String newCltCode, HttpServletRequest request, HttpServletResponse response) {
|
CallBackMessage callBackMessage = new CallBackMessage();
|
try {
|
String newDbId = request.getSession().getAttribute(SessionKey.DATA_BASE_ID) + "";
|
SpObserver.setDBtoInstance("_" + newDbId);
|
if (StringUtils.isBlank(newCltCode)) {
|
throw new ApplicationException("oldCltCode参数不能为空");
|
}
|
if (StringUtils.isBlank(oldCltCode)) {
|
throw new ApplicationException("oldCltCode参数不能为空");
|
}
|
if (dbId == null || dbId.intValue() <= 0) {
|
throw new ApplicationException("dbId参数值要大于0");
|
}
|
Integer result = mutualServiceIfc.doChangeRef110203(dbId, oldCltCode, newCltCode);
|
if (result == 0) {
|
throw new ApplicationException("变更【" + oldCltCode + "】客户关系出错!");
|
}
|
callBackMessage.sendSuccessMessageByDefault();
|
return callBackMessage.toJSONObject();
|
} catch (Exception e) {
|
callBackMessage.sendErrorMessage(e.getCause() != null ? (e.getCause().getMessage()).trim() : e.getMessage());
|
return callBackMessage.toJSONObject();
|
} finally {
|
SpObserver.setDBtoInstance();
|
}
|
}
|
|
/**
|
* 获取公司,部门列表
|
*
|
* @return
|
*/
|
@RequestMapping(value = "/mutual/getCompanyInfo.do")
|
@ResponseBody
|
public Object getCompanyInfo(HttpServletRequest request, HttpServletResponse response) {
|
CallBackMessage callBackMessage = new CallBackMessage();
|
try {
|
String dbid = request.getSession().getAttribute(SessionKey.DATA_BASE_ID) + "";
|
SpObserver.setDBtoInstance("_" + dbid);
|
final Map companyInfo = mutualServiceIfc.getCompanyInfo();
|
callBackMessage.setInfo(companyInfo);
|
callBackMessage.sendSuccessMessageByDefault();
|
return callBackMessage.toJSONObject();
|
} catch (Exception e) {
|
callBackMessage.sendErrorMessage(e.getCause() != null ? (e.getCause().getMessage()).trim() : e.getMessage());
|
return callBackMessage.toJSONObject();
|
} finally {
|
SpObserver.setDBtoInstance();
|
}
|
}
|
|
/**
|
* 获取部门列表
|
*
|
* @return
|
*/
|
@RequestMapping(value = "/mutual/getDepartmentInfo.do")
|
@ResponseBody
|
public Object getDepartmentInfo(String companyId, HttpServletRequest request, HttpServletResponse response) {
|
CallBackMessage callBackMessage = new CallBackMessage();
|
try {
|
String dbid = request.getSession().getAttribute(SessionKey.DATA_BASE_ID) + "";
|
SpObserver.setDBtoInstance("_" + dbid);
|
if (StringUtils.isBlank(companyId)) {
|
throw new ApplicationException("companyId参数不能为空");
|
}
|
final List departmentInfo = mutualServiceIfc.getDepartmentInfo(companyId);
|
callBackMessage.setInfo(departmentInfo);
|
callBackMessage.sendSuccessMessageByDefault();
|
return callBackMessage.toJSONObject();
|
} catch (Exception e) {
|
callBackMessage.sendErrorMessage(e.getCause() != null ? (e.getCause().getMessage()).trim() : e.getMessage());
|
return callBackMessage.toJSONObject();
|
} finally {
|
SpObserver.setDBtoInstance();
|
}
|
}
|
|
/**
|
* 接收总部回写状态到预付款单
|
*
|
* @return
|
*/
|
@RequestMapping(value = "/open/mutual/get150170.do")
|
@ResponseBody
|
public Object get150170(HttpServletRequest request, HttpServletResponse response) {
|
//验证已在filter里面做,这里只需要处理业务逻辑
|
CallBackMessage callBackMessage = new CallBackMessage();
|
String data = null;
|
T150201Entity entity = null;
|
try {
|
String dbid = request.getAttribute(SessionKey.SHOPPING_DBID) + "";
|
SpObserver.setDBtoInstance("_" + dbid);
|
data = URLDecoder.decode(request.getParameter("data"), "utf-8");
|
entity = JSON.parseObject(data, T150201Entity.class);
|
mutualServiceIfc.do150206(entity);
|
callBackMessage.sendSuccessMessageByDefault();
|
return callBackMessage.toJSONObject();
|
} catch (Exception e) {
|
//写错误日志
|
this.sendErrorLog(150206, (entity != null) ? entity.getDocCode() : null, e);
|
callBackMessage.sendErrorMessage(e.getCause() != null ? (e.getCause().getMessage()).trim() : e.getMessage());
|
return callBackMessage.toJSONObject();
|
} finally {
|
SpObserver.setDBtoInstance();
|
}
|
}
|
|
/**
|
* 接收总部回写状态到付款单
|
*
|
* @return
|
*/
|
@RequestMapping(value = "/open/mutual/get150101.do")
|
@ResponseBody
|
public Object get150101(HttpServletRequest request, HttpServletResponse response) {
|
//验证已在filter里面做,这里只需要处理业务逻辑
|
CallBackMessage callBackMessage = new CallBackMessage();
|
String data = null;
|
T150201Entity entity = null;
|
try {
|
String dbid = request.getAttribute(SessionKey.SHOPPING_DBID) + "";
|
SpObserver.setDBtoInstance("_" + dbid);
|
data = URLDecoder.decode(request.getParameter("data"), "utf-8");
|
entity = JSON.parseObject(data, T150201Entity.class);
|
mutualServiceIfc.do150201(entity);
|
callBackMessage.sendSuccessMessageByDefault();
|
return callBackMessage.toJSONObject();
|
} catch (Exception e) {
|
//写错误日志
|
this.sendErrorLog(150201, (entity != null) ? entity.getDocCode() : null, e);
|
callBackMessage.sendErrorMessage(e.getCause() != null ? (e.getCause().getMessage()).trim() : e.getMessage());
|
return callBackMessage.toJSONObject();
|
} finally {
|
SpObserver.setDBtoInstance();
|
}
|
}
|
|
/**
|
* 接收销售订单回写状态及更新采购价格
|
*
|
* @return
|
*/
|
@RequestMapping(value = "/open/mutual/get120201.do")
|
@ResponseBody
|
public Object get120201(HttpServletRequest request, HttpServletResponse response) {
|
//验证已在filter里面做,这里只需要处理业务逻辑
|
CallBackMessage callBackMessage = new CallBackMessage();
|
String data = null;
|
T120201Entity entity = null;
|
try {
|
String dbid = request.getAttribute(SessionKey.SHOPPING_DBID) + "";
|
SpObserver.setDBtoInstance("_" + dbid);
|
data = URLDecoder.decode(request.getParameter("data"), "utf-8");
|
entity = JSON.parseObject(data, T120201Entity.class);
|
//--处理附件,把附件拼接url,通过下载方式取得附件
|
String unid = this.saveAttachment(entity.getVndDbid() + "", entity.getAttachmentHostUrl(), entity.getAttachmentList(), "uploads");
|
entity.setUploads(unid);
|
mutualServiceIfc.do130301(entity);
|
callBackMessage.sendSuccessMessageByDefault();
|
return callBackMessage.toJSONObject();
|
} catch (Exception e) {
|
//写错误日志
|
this.sendErrorLog(130301, entity.getDistributorPoDocCode(), e);
|
callBackMessage.sendErrorMessage(e.getCause() != null ? (e.getCause().getMessage()).trim() : e.getMessage());
|
return callBackMessage.toJSONObject();
|
} finally {
|
SpObserver.setDBtoInstance();
|
}
|
}
|
|
/**
|
* 查询物流单的轨迹
|
*
|
* @param request
|
* @param response
|
*/
|
@RequestMapping("/mutual/getTraces.do")
|
@ResponseBody
|
public Object getLogisticCodeTraces(@RequestBody TranceEntity tranceEntity, HttpServletRequest request, HttpServletResponse response) {
|
CallBackMessage callBackMessage = new CallBackMessage();
|
try {
|
DataSourceEntity dataSourceEntity = MultiDataSource.getDataSourceMap(request);
|
SpObserver.setDBtoInstance("_" + dataSourceEntity.getDbId());// 切换数据源
|
String tel=tranceEntity.getReceipterTelephone();
|
if (StringUtils.isBlank(tranceEntity.getLogisticsCode())) {
|
callBackMessage.sendErrorMessage("物流运单号不能为空");
|
return callBackMessage.toJSONObject();
|
}
|
if (StringUtils.isBlank(tranceEntity.getShipperCode())) {
|
callBackMessage.sendErrorMessage("物流公司编号不能为空");
|
return callBackMessage.toJSONObject();
|
}
|
if ("SF".equals(tranceEntity.getShipperCode().trim()) && StringUtils.isBlank(tel)) {
|
callBackMessage.sendErrorMessage("查询【顺丰速运】物流信息时收货人电话不能为空");
|
return callBackMessage.toJSONObject();
|
}
|
if("SF".equals(tranceEntity.getShipperCode().trim())){
|
tel=StringUtils.right(tel,4);
|
}
|
String result = kdniaoTrackQueryAPI.getOrderTracesByJson(tranceEntity.getShipperCode(), tranceEntity.getLogisticsCode(), tel);
|
Gson gson = new Gson();
|
KdniaoOrderEntity kdniaoOrderEntity = gson.fromJson(result, new com.google.gson.reflect.TypeToken<KdniaoOrderEntity>() {
|
}.getType());
|
|
if (kdniaoOrderEntity == null) {
|
callBackMessage.sendErrorMessage("查询物流跟踪记录失败,请联系第三方【快递鸟】客服");
|
return callBackMessage.toJSONObject();
|
}
|
if (!kdniaoOrderEntity.getSuccess()) {
|
//失败
|
callBackMessage.sendErrorMessage(kdniaoOrderEntity.getState() + ":" + kdniaoOrderEntity.getReason());
|
return callBackMessage.toJSONObject();
|
}
|
//物流状态:2-在途中,3-签收,4-问题件
|
String stateDesc = "待收件";
|
if (kdniaoOrderEntity.getState() != null) {
|
if ("2".equals(kdniaoOrderEntity.getState())) {
|
stateDesc = "在途中";
|
} else if ("3".equals(kdniaoOrderEntity.getState())) {
|
stateDesc = "已签收";
|
} else if ("4".equals(kdniaoOrderEntity.getState())) {
|
stateDesc = "问题件";
|
}
|
}
|
//--更新单据物流状态
|
tranceEntity.setLogisticsState(stateDesc);
|
mutualServiceIfc.updateLogisticState(tranceEntity);
|
//----
|
List traceListJsonArray = new ArrayList();
|
kdniaoOrderEntity.getTraces().stream().sorted(Comparator.comparing(KdniaoOrderTracesEntity::getAcceptTime).reversed()).forEach(x -> {
|
Map traceJsonObject = new HashMap<>();
|
traceJsonObject.put("acceptTime", x.getAcceptTime());
|
traceJsonObject.put("acceptStation", x.getAcceptStation());
|
traceListJsonArray.add(traceJsonObject);
|
});
|
Map map = new HashMap();
|
map.put("shipperCode", tranceEntity.getShipperCode()); //快递公司编号
|
map.put("shipperName", tranceEntity.getShipperName()); //快递公司名称
|
map.put("logisticCode", tranceEntity.getLogisticsCode()); //物流运单号
|
map.put("stateDesc", stateDesc);
|
map.put("traces", traceListJsonArray);
|
map.put("reason", kdniaoOrderEntity.getReason());
|
callBackMessage.sendSuccessMessageByDefault();
|
callBackMessage.setInfo(map);
|
return callBackMessage.toJSONObject();
|
} catch (Exception e) {
|
callBackMessage.sendErrorMessage((e.getCause() != null ? e.getCause().getMessage() : e.getMessage()));
|
return callBackMessage.toJSONObject();
|
} finally {
|
SpObserver.setDBtoInstance();
|
}
|
}
|
|
/**
|
* 接收商品发货单回写状态
|
*
|
* @return
|
*/
|
@RequestMapping(value = "/open/mutual/get140201.do")
|
@ResponseBody
|
public Object get140201(HttpServletRequest request, HttpServletResponse response) {
|
//验证已在filter里面做,这里只需要处理业务逻辑
|
CallBackMessage callBackMessage = new CallBackMessage();
|
String data = null;
|
T140201Entity t140201Entity = new T140201Entity();
|
try {
|
String dbid = request.getAttribute(SessionKey.SHOPPING_DBID) + "";
|
SpObserver.setDBtoInstance("_" + dbid);
|
data = URLDecoder.decode(request.getParameter("data"), "utf-8");
|
t140201Entity = JSON.parseObject(data, T140201Entity.class);
|
mutualServiceIfc.do140201(t140201Entity);
|
callBackMessage.sendSuccessMessageByDefault();
|
return callBackMessage.toJSONObject();
|
} catch (Exception e) {
|
//写错误日志
|
this.sendErrorLog(140201, t140201Entity.getDocCode(), e);
|
callBackMessage.sendErrorMessage(e.getCause() != null ? (e.getCause().getMessage()).trim() : e.getMessage());
|
return callBackMessage.toJSONObject();
|
} finally {
|
SpObserver.setDBtoInstance();
|
}
|
}
|
|
/**
|
* 接收还原定金单指令
|
*
|
* @return
|
*/
|
@RequestMapping(value = "/open/mutual/reduction150170.do")
|
@ResponseBody
|
public Object reduction150170(HttpServletRequest request, HttpServletResponse response) {
|
//验证已在filter里面做,这里只需要处理业务逻辑
|
CallBackMessage callBackMessage = new CallBackMessage();
|
String data = null;
|
T150201Entity entity = new T150201Entity();
|
try {
|
String dbid = request.getAttribute(SessionKey.SHOPPING_DBID) + "";
|
SpObserver.setDBtoInstance("_" + dbid);
|
data = URLDecoder.decode(request.getParameter("data"), "utf-8");
|
entity = JSON.parseObject(data, T150201Entity.class);
|
if (entity != null) {
|
//执行还原收款订单
|
final Map map = mutualServiceIfc.reduction150170(entity);
|
callBackMessage.sendSuccessMessageByDefault();
|
return callBackMessage.toJSONObject();
|
} else {
|
callBackMessage.sendErrorMessage("执行预付款订单取消确认,所传数据为空,不能执行删除预收款单操作");
|
return callBackMessage.toJSONObject();
|
}
|
} catch (Exception e) {
|
//写错误日志
|
this.sendErrorLog(150170, entity.getDocCode(), e);
|
callBackMessage.sendErrorMessage(e.getCause() != null ? (e.getCause().getMessage()).trim() : e.getMessage());
|
return callBackMessage.toJSONObject();
|
} finally {
|
SpObserver.setDBtoInstance();
|
}
|
}
|
|
/**
|
* 接收还原收款单指令
|
*
|
* @return
|
*/
|
@RequestMapping(value = "/open/mutual/reduction150101.do")
|
@ResponseBody
|
public Object reduction150101(HttpServletRequest request, HttpServletResponse response) {
|
//验证已在filter里面做,这里只需要处理业务逻辑
|
CallBackMessage callBackMessage = new CallBackMessage();
|
String data = null;
|
T150201Entity entity = new T150201Entity();
|
try {
|
String dbid = request.getAttribute(SessionKey.SHOPPING_DBID) + "";
|
SpObserver.setDBtoInstance("_" + dbid);
|
data = URLDecoder.decode(request.getParameter("data"), "utf-8");
|
entity = JSON.parseObject(data, T150201Entity.class);
|
if (entity != null) {
|
//执行还原收款订单
|
final Map map = mutualServiceIfc.reduction150101(entity);
|
callBackMessage.sendSuccessMessageByDefault();
|
return callBackMessage.toJSONObject();
|
} else {
|
callBackMessage.sendErrorMessage("执行付款订单取消确认,所传数据为空,不能执行删除收款单操作");
|
return callBackMessage.toJSONObject();
|
}
|
} catch (Exception e) {
|
//写错误日志
|
this.sendErrorLog(150101, entity.getDocCode(), e);
|
callBackMessage.sendErrorMessage(e.getCause() != null ? (e.getCause().getMessage()).trim() : e.getMessage());
|
return callBackMessage.toJSONObject();
|
} finally {
|
SpObserver.setDBtoInstance();
|
}
|
}
|
|
/**
|
* 接收还原销售订单指令
|
*
|
* @return
|
*/
|
@RequestMapping(value = "/open/mutual/reduction120201.do")
|
@ResponseBody
|
public Object reduction120201(HttpServletRequest request, HttpServletResponse response) {
|
//验证已在filter里面做,这里只需要处理业务逻辑
|
CallBackMessage callBackMessage = new CallBackMessage();
|
String data = null;
|
T120201Entity t120201Entity = new T120201Entity();
|
try {
|
String dbid = request.getAttribute(SessionKey.SHOPPING_DBID) + "";
|
SpObserver.setDBtoInstance("_" + dbid);
|
data = URLDecoder.decode(request.getParameter("data"), "utf-8");
|
t120201Entity = JSON.parseObject(data, T120201Entity.class);
|
if (t120201Entity != null && t120201Entity.getCltDbid()!=null) {
|
//执行还原销售订单
|
final Map map = mutualServiceIfc.reduction120201(t120201Entity);
|
callBackMessage.sendSuccessMessageByDefault();
|
return callBackMessage.toJSONObject();
|
} else {
|
//--未有数据源id
|
callBackMessage.sendErrorMessage("执行采购订单取消确认后内部推送传过来的dbid不能为空,不能执行删除销售订单操作");
|
return callBackMessage.toJSONObject();
|
}
|
} catch (Exception e) {
|
//写错误日志
|
this.sendErrorLog(120201, t120201Entity.getDocCode(), e);
|
callBackMessage.sendErrorMessage(e.getCause() != null ? (e.getCause().getMessage()).trim() : e.getMessage());
|
return callBackMessage.toJSONObject();
|
} finally {
|
SpObserver.setDBtoInstance();
|
}
|
}
|
|
/**
|
* 接收经销商推送过来删除预收定金单(150170)指令
|
*
|
* @return
|
*/
|
@RequestMapping(value = "/open/mutual/del150170.do")
|
@ResponseBody
|
public Object del150170(HttpServletRequest request, HttpServletResponse response) {
|
//验证已在filter里面做,这里只需要处理业务逻辑
|
CallBackMessage callBackMessage = new CallBackMessage();
|
String data = null;
|
T150201Entity entity = new T150201Entity();
|
try {
|
String dbid = request.getAttribute(SessionKey.SHOPPING_DBID) + "";
|
SpObserver.setDBtoInstance("_" + dbid);
|
data = URLDecoder.decode(request.getParameter("data"), "utf-8");
|
entity = JSON.parseObject(data, T150201Entity.class);
|
final Integer result = mutualServiceIfc.del150170(entity);
|
if (result.intValue() == -2) {
|
final DataSourceEntity dataSourceMap = MultiDataSource.getDataSourceMap(entity.getVndDbid() + "");
|
callBackMessage.sendErrorMessage("【" + dataSourceMap.getSystemDescribe() + "】预收定金单:" + entity.getDocCode() + " 已审核,不能执行取消确认操作");
|
callBackMessage.setState(-2);
|
} else {
|
callBackMessage.sendSuccessMessageByDefault();
|
}
|
return callBackMessage.toJSONObject();
|
} catch (Exception e) {
|
//写错误日志
|
this.sendErrorLog(150170, entity.getDocCode(), e);
|
callBackMessage.sendErrorMessage(e.getCause() != null ? (e.getCause().getMessage()).trim() : e.getMessage());
|
return callBackMessage.toJSONObject();
|
} finally {
|
SpObserver.setDBtoInstance();
|
}
|
}
|
|
/**
|
* 接收经销商推送过来删除收款单(150101)指令
|
*
|
* @return
|
*/
|
@RequestMapping(value = "/open/mutual/del150101.do")
|
@ResponseBody
|
public Object del150101(HttpServletRequest request, HttpServletResponse response) {
|
//验证已在filter里面做,这里只需要处理业务逻辑
|
CallBackMessage callBackMessage = new CallBackMessage();
|
String data = null;
|
T150201Entity entity = new T150201Entity();
|
try {
|
String dbid = request.getAttribute(SessionKey.SHOPPING_DBID) + "";
|
SpObserver.setDBtoInstance("_" + dbid);
|
data = URLDecoder.decode(request.getParameter("data"), "utf-8");
|
entity = JSON.parseObject(data, T150201Entity.class);
|
final Integer result = mutualServiceIfc.del150101(entity);
|
if (result.intValue() == -2) {
|
final DataSourceEntity dataSourceMap = MultiDataSource.getDataSourceMap(entity.getVndDbid() + "");
|
callBackMessage.sendErrorMessage("【" + dataSourceMap.getSystemDescribe() + "】收款单:" + entity.getDocCode() + " 已审核,不能执行取消确认操作");
|
callBackMessage.setState(-2);
|
} else {
|
callBackMessage.sendSuccessMessageByDefault();
|
}
|
return callBackMessage.toJSONObject();
|
} catch (Exception e) {
|
//写错误日志
|
this.sendErrorLog(150101, entity.getDocCode(), e);
|
callBackMessage.sendErrorMessage(e.getCause() != null ? (e.getCause().getMessage()).trim() : e.getMessage());
|
return callBackMessage.toJSONObject();
|
} finally {
|
SpObserver.setDBtoInstance();
|
}
|
}
|
|
/**
|
* 接收经销商推送过来删除121501指令
|
*
|
* @return
|
*/
|
@RequestMapping(value = "/open/mutual/del121501.do")
|
@ResponseBody
|
public Object del121501(HttpServletRequest request, HttpServletResponse response) {
|
//验证已在filter里面做,这里只需要处理业务逻辑
|
CallBackMessage callBackMessage = new CallBackMessage();
|
String data = null;
|
T120201Entity t120201Entity = new T120201Entity();
|
try {
|
String dbid = request.getAttribute(SessionKey.SHOPPING_DBID) + "";
|
SpObserver.setDBtoInstance("_" + dbid);
|
data = URLDecoder.decode(request.getParameter("data"), "utf-8");
|
t120201Entity = JSON.parseObject(data, T120201Entity.class);
|
final Integer integer = mutualServiceIfc.del121501(t120201Entity);
|
callBackMessage.sendSuccessMessageByDefault();
|
return callBackMessage.toJSONObject();
|
} catch (Exception e) {
|
//写错误日志
|
this.sendErrorLog(121501, t120201Entity.getDocCode(), e);
|
callBackMessage.sendErrorMessage(e.getCause() != null ? (e.getCause().getMessage()).trim() : e.getMessage());
|
return callBackMessage.toJSONObject();
|
} finally {
|
SpObserver.setDBtoInstance();
|
}
|
}
|
|
/**
|
* 接收删除销售订单指令
|
*
|
* @return
|
*/
|
@RequestMapping(value = "/open/mutual/del120201.do")
|
@ResponseBody
|
public Object del120201(HttpServletRequest request, HttpServletResponse response) {
|
//验证已在filter里面做,这里只需要处理业务逻辑
|
CallBackMessage callBackMessage = new CallBackMessage();
|
String data = null;
|
T120201Entity t120201Entity = new T120201Entity();
|
try {
|
String dbid = request.getAttribute(SessionKey.SHOPPING_DBID) + "";
|
SpObserver.setDBtoInstance("_" + dbid);
|
data = URLDecoder.decode(request.getParameter("data"), "utf-8");
|
t120201Entity = JSON.parseObject(data, T120201Entity.class);
|
if (t120201Entity != null) {
|
//执行未确认的删单
|
final Integer integer = mutualServiceIfc.del120201(t120201Entity);
|
final DataSourceEntity dataSourceMap = MultiDataSource.getDataSourceMap(t120201Entity.getVndDbid()+"");
|
if (integer.intValue() == -2) {
|
callBackMessage.sendErrorMessage("【" + dataSourceMap.getSystemDescribe() + "】单据:" + t120201Entity.getDocCode() + " 已审核,不能删除");
|
callBackMessage.setState(-2);
|
} else {
|
callBackMessage.sendSuccessMessageByDefault();
|
}
|
}
|
return callBackMessage.toJSONObject();
|
} catch (Exception e) {
|
//写错误日志
|
this.sendErrorLog(120201, t120201Entity.getDocCode(), e);
|
callBackMessage.sendErrorMessage(e.getCause() != null ? (e.getCause().getMessage()).trim() : e.getMessage());
|
return callBackMessage.toJSONObject();
|
} finally {
|
SpObserver.setDBtoInstance();
|
}
|
}
|
|
/**
|
* 接收各经销商的通知消息回调 210610
|
*
|
* @return
|
*/
|
@RequestMapping(value = "/open/mutual/callBack210610.do")
|
@ResponseBody
|
public Object callBack210610(HttpServletRequest request, HttpServletResponse response) {
|
//验证已在filter里面做,这里只需要处理业务逻辑
|
CallBackMessage callBackMessage = new CallBackMessage();
|
String data = null;
|
try {
|
String dbid = request.getAttribute(SessionKey.SHOPPING_DBID) + "";
|
SpObserver.setDBtoInstance("_" + dbid);
|
data = URLDecoder.decode(request.getParameter("data"), "utf-8");
|
T210610Entity entity = JSON.parseObject(data, T210610Entity.class);
|
Integer result = mutualServiceIfc.callBack210610(entity);
|
callBackMessage.sendSuccessMessageByDefault();
|
return callBackMessage.toJSONObject();
|
} catch (Exception e) {
|
//写错误日志
|
this.sendErrorLog(210610, null, e);
|
callBackMessage.sendErrorMessage(e.getCause() != null ? (e.getCause().getMessage()).trim() : e.getMessage());
|
return callBackMessage.toJSONObject();
|
} finally {
|
SpObserver.setDBtoInstance();
|
}
|
}
|
|
/**
|
* 更新预付款单成功状态
|
*
|
* @return
|
*/
|
@RequestMapping(value = "/open/mutual/update150206Status.do")
|
@ResponseBody
|
public Object update150206Status(HttpServletRequest request, HttpServletResponse response) {
|
//验证已在filter里面做,这里只需要处理业务逻辑
|
CallBackMessage callBackMessage = new CallBackMessage();
|
String data = null;
|
try {
|
String dbid = request.getAttribute(SessionKey.SHOPPING_DBID) + "";
|
SpObserver.setDBtoInstance("_" + dbid);
|
data = URLDecoder.decode(request.getParameter("data"), "utf-8");
|
T150201Entity entity = JSON.parseObject(data, T150201Entity.class);
|
mutualServiceIfc.update150206Status(entity);
|
callBackMessage.sendSuccessMessageByDefault();
|
return callBackMessage.toJSONObject();
|
} catch (Exception e) {
|
//写错误日志
|
this.sendErrorLog(150206, null, e);
|
callBackMessage.sendErrorMessage(e.getCause() != null ? (e.getCause().getMessage()).trim() : e.getMessage());
|
return callBackMessage.toJSONObject();
|
} finally {
|
SpObserver.setDBtoInstance();
|
}
|
}
|
|
/**
|
* 更新付款单成功状态
|
*
|
* @return
|
*/
|
@RequestMapping(value = "/open/mutual/update150201Status.do")
|
@ResponseBody
|
public Object update150201Status(HttpServletRequest request, HttpServletResponse response) {
|
//验证已在filter里面做,这里只需要处理业务逻辑
|
CallBackMessage callBackMessage = new CallBackMessage();
|
String data = null;
|
try {
|
String dbid = request.getAttribute(SessionKey.SHOPPING_DBID) + "";
|
SpObserver.setDBtoInstance("_" + dbid);
|
data = URLDecoder.decode(request.getParameter("data"), "utf-8");
|
T150201Entity entity = JSON.parseObject(data, T150201Entity.class);
|
mutualServiceIfc.update150201Status(entity);
|
callBackMessage.sendSuccessMessageByDefault();
|
return callBackMessage.toJSONObject();
|
} catch (Exception e) {
|
//写错误日志
|
this.sendErrorLog(150201, null, e);
|
callBackMessage.sendErrorMessage(e.getCause() != null ? (e.getCause().getMessage()).trim() : e.getMessage());
|
return callBackMessage.toJSONObject();
|
} finally {
|
SpObserver.setDBtoInstance();
|
}
|
}
|
|
/**
|
* 回写经销商销售订单成功状态
|
*
|
* @return
|
*/
|
@RequestMapping(value = "/open/mutual/update130301Status.do")
|
@ResponseBody
|
public Object update130301Status(HttpServletRequest request, HttpServletResponse response) {
|
//验证已在filter里面做,这里只需要处理业务逻辑
|
CallBackMessage callBackMessage = new CallBackMessage();
|
String data = null;
|
try {
|
String dbid = request.getAttribute(SessionKey.SHOPPING_DBID) + "";
|
SpObserver.setDBtoInstance("_" + dbid);
|
data = URLDecoder.decode(request.getParameter("data"), "utf-8");
|
T120201Entity entity = JSON.parseObject(data, T120201Entity.class);
|
mutualServiceIfc.update130301Status(entity);
|
callBackMessage.sendSuccessMessageByDefault();
|
return callBackMessage.toJSONObject();
|
} catch (Exception e) {
|
//写错误日志
|
this.sendErrorLog(120201, null, e);
|
callBackMessage.sendErrorMessage(e.getCause() != null ? (e.getCause().getMessage()).trim() : e.getMessage());
|
return callBackMessage.toJSONObject();
|
} finally {
|
SpObserver.setDBtoInstance();
|
}
|
}
|
|
/**
|
* 更新总部拉取经销商销售订单成功回写状态
|
*
|
* @return
|
*/
|
@RequestMapping(value = "/open/mutual/update120201.do")
|
@ResponseBody
|
public Object update120201(HttpServletRequest request, HttpServletResponse response) {
|
//验证已在filter里面做,这里只需要处理业务逻辑
|
CallBackMessage callBackMessage = new CallBackMessage();
|
String data = null;
|
try {
|
String dbid = request.getAttribute(SessionKey.SHOPPING_DBID) + "";
|
SpObserver.setDBtoInstance("_" + dbid);
|
data = URLDecoder.decode(request.getParameter("data"), "utf-8");
|
CallBack120201Entity entity = JSON.parseObject(data, CallBack120201Entity.class);
|
Integer result = mutualServiceIfc.update120201ByVndCode(entity);
|
callBackMessage.sendSuccessMessageByDefault();
|
return callBackMessage.toJSONObject();
|
} catch (Exception e) {
|
//写错误日志
|
this.sendErrorLog(120201, null, e);
|
callBackMessage.sendErrorMessage(e.getCause() != null ? (e.getCause().getMessage()).trim() : e.getMessage());
|
return callBackMessage.toJSONObject();
|
} finally {
|
SpObserver.setDBtoInstance();
|
}
|
}
|
|
/**
|
* 更新经销商接收物料数据的时间
|
*
|
* @return
|
*/
|
@RequestMapping(value = "/open/mutual/updateLastDateTimeBy110503.do")
|
@ResponseBody
|
public Object updateLastDateTimeBy110503(HttpServletRequest request, HttpServletResponse response) {
|
//验证已在filter里面做,这里只需要处理业务逻辑
|
CallBackMessage callBackMessage = new CallBackMessage();
|
String data = null;
|
try {
|
String dbid = request.getAttribute(SessionKey.SHOPPING_DBID) + "";
|
SpObserver.setDBtoInstance("_" + dbid);
|
data = URLDecoder.decode(request.getParameter("data"), "utf-8");
|
T110503Entity entity = JSON.parseObject(data, T110503Entity.class);
|
Integer result = mutualServiceIfc.updateLastDateTimeBy110503(entity);
|
callBackMessage.sendSuccessMessageByDefault();
|
return callBackMessage.toJSONObject();
|
} catch (Exception e) {
|
//写错误日志
|
this.sendErrorLog(110503, null, e);
|
callBackMessage.sendErrorMessage(e.getCause() != null ? (e.getCause().getMessage()).trim() : e.getMessage());
|
return callBackMessage.toJSONObject();
|
} finally {
|
SpObserver.setDBtoInstance();
|
}
|
}
|
|
/**
|
* 经销商接收物料数据
|
*
|
* @return
|
*/
|
@RequestMapping(value = "/open/mutual/get110503.do")
|
@ResponseBody
|
public Object get110503(HttpServletRequest request, HttpServletResponse response) {
|
//验证已在filter里面做,这里只需要处理业务逻辑
|
CallBackMessage callBackMessage = new CallBackMessage();
|
String data = null;
|
try {
|
String dbid = request.getAttribute(SessionKey.SHOPPING_DBID) + "";
|
SpObserver.setDBtoInstance("_" + dbid);
|
data = URLDecoder.decode(request.getParameter("data"), "utf-8");
|
T110503Entity entity = JSON.parseObject(data, T110503Entity.class);
|
//--处理附件,把附件拼接url,通过下载方式取得附件
|
if (entity.getList() != null && entity.getList().size() > 0) {
|
entity.getList().stream().forEach(x -> {
|
try {
|
String unid = this.saveAttachment(entity.getVndDbid() + "", x.getAttachmentHostUrl(), x.getAttachmentList(), "photoPath");
|
x.setPhotoPath(unid);
|
} catch (Exception e) {
|
e.printStackTrace();
|
throw new ApplicationException(e.getMessage());
|
}
|
});
|
}
|
mutualServiceIfc.do110503(entity);
|
//--回调给总部更新推送时间
|
entity.setList(null);
|
this.createDataAndPush(entity.getVndDbid() + "", 110503, null, "updateLastDateTimeBy110503.do", entity);
|
callBackMessage.sendSuccessMessageByDefault();
|
return callBackMessage.toJSONObject();
|
} catch (Exception e) {
|
//写错误日志
|
this.sendErrorLog(110503, null, e);
|
callBackMessage.sendErrorMessage(e.getCause() != null ? (e.getCause().getMessage()).trim() : e.getMessage());
|
return callBackMessage.toJSONObject();
|
} finally {
|
SpObserver.setDBtoInstance();
|
}
|
}
|
|
/**
|
* 删除各经销商的通知消息 210610
|
*
|
* @return
|
*/
|
@RequestMapping(value = "/open/mutual/del210610.do")
|
@ResponseBody
|
public Object del210610(HttpServletRequest request, HttpServletResponse response) {
|
//验证已在filter里面做,这里只需要处理业务逻辑
|
CallBackMessage callBackMessage = new CallBackMessage();
|
String data = null;
|
try {
|
String dbid = request.getAttribute(SessionKey.SHOPPING_DBID) + "";
|
SpObserver.setDBtoInstance("_" + dbid);
|
data = URLDecoder.decode(request.getParameter("data"), "utf-8");
|
T210610Entity entity = JSON.parseObject(data, T210610Entity.class);
|
Integer result = mutualServiceIfc.del210610(entity);
|
callBackMessage.sendSuccessMessageByDefault();
|
return callBackMessage.toJSONObject();
|
} catch (Exception e) {
|
//写错误日志
|
this.sendErrorLog(210610, null, e);
|
callBackMessage.sendErrorMessage(e.getCause() != null ? (e.getCause().getMessage()).trim() : e.getMessage());
|
return callBackMessage.toJSONObject();
|
} finally {
|
SpObserver.setDBtoInstance();
|
}
|
}
|
|
/**
|
* 获取客户系统活跃情况写到onbus系统
|
*
|
* @return
|
*/
|
@RequestMapping(value = "/open/mutual/push170424.do")
|
@ResponseBody
|
public Object push170424(HttpServletRequest request, HttpServletResponse response) {
|
//验证已在filter里面做,这里只需要处理业务逻辑
|
CallBackMessage callBackMessage = new CallBackMessage();
|
String data = null;
|
try {
|
String dbid = request.getAttribute(SessionKey.SHOPPING_DBID) + "";
|
SpObserver.setDBtoInstance("_" + dbid);
|
data = URLDecoder.decode(request.getParameter("data"), "utf-8");
|
List<T170424Entity> list = JSON.parseArray(data, T170424Entity.class);
|
Integer result = mutualServiceIfc.do170424(list);
|
callBackMessage.sendSuccessMessageByDefault();
|
return callBackMessage.toJSONObject();
|
} catch (Exception e) {
|
//写错误日志
|
this.sendErrorLog(170424, null, e);
|
callBackMessage.sendErrorMessage(e.getCause() != null ? (e.getCause().getMessage()).trim() : e.getMessage());
|
return callBackMessage.toJSONObject();
|
} finally {
|
SpObserver.setDBtoInstance();
|
}
|
}
|
|
/**
|
* 取上次收集客户系统活跃情况到今天为止的天数
|
*
|
* @return
|
*/
|
@RequestMapping(value = "/open/mutual/getCheckDays.do")
|
@ResponseBody
|
public Object getCheckDays(HttpServletRequest request, HttpServletResponse response) {
|
//验证已在filter里面做,这里只需要处理业务逻辑
|
CallBackMessage callBackMessage = new CallBackMessage();
|
String data = null;
|
try {
|
String dbid = request.getAttribute(SessionKey.SHOPPING_DBID) + "";
|
SpObserver.setDBtoInstance("_" + dbid);
|
data = URLDecoder.decode(request.getParameter("data"), "utf-8");
|
Map<String, Integer> dbidMap = JSON.parseObject(data, Map.class);
|
Integer result = mutualServiceIfc.getCheckDays(dbidMap.get("cltDbid"));
|
callBackMessage.setData(result + "");
|
return callBackMessage.toJSONObject();
|
} catch (Exception e) {
|
//写错误日志
|
this.sendErrorLog(170424, null, e);
|
callBackMessage.sendErrorMessage(e.getCause() != null ? (e.getCause().getMessage()).trim() : e.getMessage());
|
return callBackMessage.toJSONObject();
|
} finally {
|
SpObserver.setDBtoInstance();
|
}
|
}
|
|
/**
|
* 获取附件
|
*
|
* @param imageHostUrl
|
* @return
|
* @throws IOException
|
*/
|
private byte[] getAttachment(String imageHostUrl) throws IOException {
|
URL url = new URL(imageHostUrl);
|
//打开链接
|
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
//设置请求方式为"GET"
|
conn.setRequestMethod("GET");
|
//超时响应时间为5秒
|
conn.setConnectTimeout(5 * 1000);
|
//通过输入流获取图片数据
|
InputStream inStream = conn.getInputStream();
|
//得到图片的二进制数据,以二进制封装得到数据,具有通用性
|
byte[] bytes = FileCopyUtils.copyToByteArray(inStream);
|
conn.disconnect();
|
return bytes;
|
}
|
|
public String saveAttachment(String dbid, String domain, List<com.yc.open.mutual.entity.AttachmentEntity> list, String fieldId) throws Exception {
|
if (list == null || list.size() == 0) return "";
|
String uuid = UUID.randomUUID().toString().toUpperCase();
|
String seqString = "";
|
//存在附件需要处理
|
int index = 0;
|
for (com.yc.open.mutual.entity.AttachmentEntity entity : list) {
|
|
String url = "/uploads/attachment/" + dbid + "/" + entity.getFormid() + "/" + entity.getUnid() + "@p@" + entity.getSeq() + "." + entity.getFileType();
|
//源文件二进制
|
byte[] orgBinaryimages = getAttachment(domain + url);
|
|
com.yc.entity.attachment.AttachmentEntity attachmentEntity = new AttachmentEntity();
|
attachmentEntity.setUnid(uuid);
|
attachmentEntity.setSeq(null);
|
attachmentEntity.setFormId(entity.getFormid());
|
attachmentEntity.setDoccode(null);
|
attachmentEntity.setFieldId(fieldId);
|
attachmentEntity.setRowId(null);
|
attachmentEntity.setPhysicalFile(null);
|
attachmentEntity.setPhysicalPath(null);
|
attachmentEntity.setOriginalFileName(entity.getOriginalFileName());
|
attachmentEntity.setFileSize(entity.getFileSize());
|
attachmentEntity.setFileType(entity.getFileType());
|
attachmentEntity.setAuthorCode("SYSTEM");
|
attachmentEntity.setAuthorName("管理员");
|
UploadFiles uploadFiles = new UploadFiles();
|
uploadFiles.setOrgBinaryimages(orgBinaryimages);
|
uploadFiles.setSmallBinaryimages(orgBinaryimages);
|
AttachmentWhereEntity attachmentWhereEntity = attachmentIfc.saveAttachment(uploadFiles, attachmentEntity, entity.getAttachemntType());
|
index++;
|
if (index == list.size())
|
seqString += attachmentWhereEntity.getSeq();
|
else {
|
seqString += attachmentWhereEntity.getSeq() + ";";
|
}
|
}
|
|
return uuid + ";" + seqString;
|
}
|
|
/**
|
* 接收通知消息 210610
|
*
|
* @return
|
*/
|
@RequestMapping(value = "/open/mutual/get210610.do")
|
@ResponseBody
|
public Object get210610(HttpServletRequest request, HttpServletResponse response) {
|
//验证已在filter里面做,这里只需要处理业务逻辑
|
CallBackMessage callBackMessage = new CallBackMessage();
|
String data = null;
|
try {
|
String dbid = request.getAttribute(SessionKey.SHOPPING_DBID) + "";
|
SpObserver.setDBtoInstance("_" + dbid);
|
data = URLDecoder.decode(request.getParameter("data"), "utf-8");
|
T210610Entity entity = JSON.parseObject(data, T210610Entity.class);
|
//--处理附件,把附件拼接url,通过下载方式取得附件
|
String unid = this.saveAttachment(entity.getVndDbid() + "", entity.getAttachmentHostUrl(), entity.getAttachmentList(), "upload");
|
entity.setUpload(unid);
|
Integer result = mutualServiceIfc.do210610(entity);
|
|
//--执行回调
|
entity.setCltDbid(Integer.parseInt(dbid));
|
entity.setContent(null);
|
entity.setTheme(null);
|
entity.setUpload(null);
|
this.createDataAndPush(entity.getVndDbid() + "", 216010, entity.getDocCode(), "callBack210610.do", entity);
|
callBackMessage.sendSuccessMessageByDefault();
|
return callBackMessage.toJSONObject();
|
} catch (Exception e) {
|
//写错误日志
|
this.sendErrorLog(210610, null, e);
|
callBackMessage.sendErrorMessage(e.getCause() != null ? (e.getCause().getMessage()).trim() : e.getMessage());
|
return callBackMessage.toJSONObject();
|
} finally {
|
SpObserver.setDBtoInstance();
|
}
|
}
|
|
/**
|
* 拉取经销商销售数据
|
*
|
* @return
|
*/
|
@RequestMapping(value = "/open/mutual/pull120201.do")
|
@ResponseBody
|
public Object pull120201(HttpServletRequest request, HttpServletResponse response) {
|
//验证已在filter里面做,这里只需要处理业务逻辑
|
CallBackMessage callBackMessage = new CallBackMessage();
|
String data = null;
|
try {
|
String dbid = request.getAttribute(SessionKey.SHOPPING_DBID) + "";
|
SpObserver.setDBtoInstance("_" + dbid);
|
data = URLDecoder.decode(request.getParameter("data"), "utf-8");
|
T110203VO t110203 = JSON.parseObject(data, T110203VO.class);
|
T110302 t110302 = new T110302();
|
t110302.setBrands(t110203.getBrands());
|
t110302.setVndDbid(t110203.getVndDbid());
|
t110302.setPullSalesOrderFromDistributorLastDateTime(t110203.getPullSalesOrderFromDistributorLastDateTime());
|
final List<T121501Entity> list = mutualServiceIfc.get120201List(t110302);
|
if (list != null && list.size() > 0) {
|
list.stream().forEach(x -> {
|
//取出附件拼接url需要的数据
|
final List<com.yc.open.mutual.entity.AttachmentEntity> attachmentInfo = mutualServiceIfc.getAttachmentInfo(x.getHead().getUploads(), 120201, "uploads", 0);
|
if (attachmentInfo != null && attachmentInfo.size() > 0) {
|
x.setAttachmentHostUrl(AttachmentConfig.get("attachment.server"));
|
x.setAttachmentList(attachmentInfo);
|
}
|
});
|
callBackMessage.setInfo(list);
|
}
|
callBackMessage.sendSuccessMessageByDefault();
|
return callBackMessage.toJSONObject();
|
} catch (Exception e) {
|
//写错误日志
|
this.sendErrorLog(120201, null, e);
|
callBackMessage.sendErrorMessage(e.getCause() != null ? (e.getCause().getMessage()).trim() : e.getMessage());
|
return callBackMessage.toJSONObject();
|
} finally {
|
SpObserver.setDBtoInstance();
|
}
|
}
|
|
/**
|
* 拉取经销商库存数据
|
*
|
* @return
|
*/
|
@RequestMapping(value = "/open/mutual/pull140902.do")
|
@ResponseBody
|
public Object pull140902(HttpServletRequest request, HttpServletResponse response) {
|
//验证已在filter里面做,这里只需要处理业务逻辑
|
CallBackMessage callBackMessage = new CallBackMessage();
|
String data = null;
|
try {
|
String dbid = request.getAttribute(SessionKey.SHOPPING_DBID) + "";
|
SpObserver.setDBtoInstance("_" + dbid);
|
data = URLDecoder.decode(request.getParameter("data"), "utf-8");
|
T110203VO t110203 = JSON.parseObject(data, T110203VO.class);
|
final List<T140902> t140902List = mutualServiceIfc.get140902(t110203);
|
callBackMessage.setInfo(t140902List);
|
callBackMessage.sendSuccessMessageByDefault();
|
return callBackMessage.toJSONObject();
|
} catch (Exception e) {
|
//写错误日志
|
this.sendErrorLog(141002, null, e);
|
callBackMessage.sendErrorMessage(e.getCause() != null ? (e.getCause().getMessage()).trim() : e.getMessage());
|
return callBackMessage.toJSONObject();
|
} finally {
|
SpObserver.setDBtoInstance();
|
}
|
}
|
|
/**
|
* 接收库存数据
|
*
|
* @return
|
*/
|
@RequestMapping(value = "/open/mutual/get140902.do")
|
@ResponseBody
|
public Object get140902(HttpServletRequest request, HttpServletResponse response) {
|
//验证已在filter里面做,这里只需要处理业务逻辑
|
CallBackMessage callBackMessage = new CallBackMessage();
|
String data = null;
|
try {
|
String dbid = request.getAttribute(SessionKey.SHOPPING_DBID) + "";
|
SpObserver.setDBtoInstance("_" + dbid);
|
data = URLDecoder.decode(request.getParameter("data"), "utf-8");
|
T140902Entity t140902Entity = JSON.parseObject(data, T140902Entity.class);
|
Integer result = mutualServiceIfc.do140902(t140902Entity);
|
//回写单据状态
|
//threadPoolExecutor.execute(new T120201PushDataThread(t120201Entity, this, baseController));
|
callBackMessage.sendSuccessMessageByDefault();
|
return callBackMessage.toJSONObject();
|
} catch (Exception e) {
|
//写错误日志
|
this.sendErrorLog(141002, null, e);
|
callBackMessage.sendErrorMessage(e.getCause() != null ? (e.getCause().getMessage()).trim() : e.getMessage());
|
return callBackMessage.toJSONObject();
|
} finally {
|
SpObserver.setDBtoInstance();
|
}
|
}
|
|
/**
|
* 接收经销商推送过来的付款单
|
*
|
* @return
|
*/
|
@RequestMapping(value = "/open/mutual/push150201.do")
|
@ResponseBody
|
public Object push150201(HttpServletRequest request, HttpServletResponse response) {
|
//验证已在filter里面做,这里只需要处理业务逻辑
|
CallBackMessage callBackMessage = new CallBackMessage();
|
String data = null;
|
try {
|
String dbid = request.getAttribute(SessionKey.SHOPPING_DBID) + "";
|
SpObserver.setDBtoInstance("_" + dbid);
|
data = URLDecoder.decode(request.getParameter("data"), "utf-8");
|
T150201Entity entity = JSON.parseObject(data, T150201Entity.class);
|
if (entity != null) {
|
//--处理附件,把附件拼接url,通过下载方式取得附件
|
String unid = this.saveAttachment(entity.getCltDbid() + "", entity.getAttachmentHostUrl(), entity.getAttachmentList(), "attachment");
|
entity.setUploads(unid);
|
//生成客户收款订单
|
String docCode = mutualServiceIfc.do150101(entity);
|
//回写状态
|
entity.setT150344(null);
|
entity.setList150232(null);
|
entity.setList150348(null);
|
entity.setAttachmentList(null);
|
entity.setHeadqSoDocCode(docCode);
|
this.createDataAndPush(entity.getCltDbid() + "", 150101, entity.getDocCode(), "update150201Status.do", entity);
|
}
|
callBackMessage.sendSuccessMessageByDefault();
|
return callBackMessage.toJSONObject();
|
} catch (Exception e) {
|
//写错误日志
|
this.sendErrorLog(150201, null, e);
|
callBackMessage.sendErrorMessage(e.getCause() != null ? (e.getCause().getMessage()).trim() : e.getMessage());
|
return callBackMessage.toJSONObject();
|
} finally {
|
SpObserver.setDBtoInstance();
|
}
|
}
|
|
/**
|
* 接收经销商推送过来的预付款单
|
*
|
* @return
|
*/
|
@RequestMapping(value = "/open/mutual/push150206.do")
|
@ResponseBody
|
public Object push150206(HttpServletRequest request, HttpServletResponse response) {
|
//验证已在filter里面做,这里只需要处理业务逻辑
|
CallBackMessage callBackMessage = new CallBackMessage();
|
String data = null;
|
try {
|
String dbid = request.getAttribute(SessionKey.SHOPPING_DBID) + "";
|
SpObserver.setDBtoInstance("_" + dbid);
|
data = URLDecoder.decode(request.getParameter("data"), "utf-8");
|
T150201Entity entity = JSON.parseObject(data, T150201Entity.class);
|
if (entity != null) {
|
//--处理附件,把附件拼接url,通过下载方式取得附件
|
String unid = this.saveAttachment(entity.getCltDbid() + "", entity.getAttachmentHostUrl(), entity.getAttachmentList(), "uploads");
|
entity.setUploads(unid);
|
//生成客户收款订单
|
String docCode = mutualServiceIfc.do150170(entity);
|
//回写状态
|
entity.setT150344(null);
|
entity.setList150232(null);
|
entity.setList150348(null);
|
entity.setAttachmentList(null);
|
entity.setHeadqSoDocCode(docCode);
|
this.createDataAndPush(entity.getCltDbid() + "", 150101, entity.getDocCode(), "update150206Status.do", entity);
|
}
|
callBackMessage.sendSuccessMessageByDefault();
|
return callBackMessage.toJSONObject();
|
} catch (Exception e) {
|
//写错误日志
|
this.sendErrorLog(150201, null, e);
|
callBackMessage.sendErrorMessage(e.getCause() != null ? (e.getCause().getMessage()).trim() : e.getMessage());
|
return callBackMessage.toJSONObject();
|
} finally {
|
SpObserver.setDBtoInstance();
|
}
|
}
|
|
/**
|
* 接收采购订单生成销售订单
|
*
|
* @return
|
*/
|
@RequestMapping(value = "/open/mutual/get130301.do")
|
@ResponseBody
|
public Object get130301(HttpServletRequest request, HttpServletResponse response) {
|
//验证已在filter里面做,这里只需要处理业务逻辑
|
CallBackMessage callBackMessage = new CallBackMessage();
|
String data = null;
|
T130301Entity t130301Entity = new T130301Entity();
|
try {
|
String dbid = request.getAttribute(SessionKey.SHOPPING_DBID) + "";
|
SpObserver.setDBtoInstance("_" + dbid);
|
data = URLDecoder.decode(request.getParameter("data"), "utf-8");
|
t130301Entity = JSON.parseObject(data, T130301Entity.class);
|
//--处理附件,把附件拼接url,通过下载方式取得附件
|
String unid = this.saveAttachment(t130301Entity.getCltDbid() + "", t130301Entity.getAttachmentHostUrl(), t130301Entity.getAttachmentList(), "uploads");
|
t130301Entity.setUploads(unid);
|
//由refDbId取得对应的客户资料,生成销售订单
|
String docCode = mutualServiceIfc.do120201(t130301Entity);
|
//回写状态,以便在对方没确认前,但这边又执行取消确认可以删除未确认的单
|
T120201Entity t120201Entity = new T120201Entity();
|
t120201Entity.setCltDbid(t130301Entity.getCltDbid());
|
t120201Entity.setVndDbid(t130301Entity.getVndDbid());
|
t120201Entity.setDocCode(t130301Entity.getDocCode());
|
t120201Entity.setHeadqSoDocCode(docCode);
|
t120201Entity.setDocCode(t130301Entity.getRefCode());
|
this.createDataAndPush(t120201Entity.getCltDbid() + "", 120201, t120201Entity.getDocCode(), "update130301Status.do", t120201Entity);
|
callBackMessage.sendSuccessMessageByDefault();
|
return callBackMessage.toJSONObject();
|
} catch (Exception e) {
|
//写错误日志
|
this.sendErrorLog(120201, t130301Entity.getRefCode(), e);
|
callBackMessage.sendErrorMessage(e.getCause() != null ? (e.getCause().getMessage()).trim() : e.getMessage());
|
return callBackMessage.toJSONObject();
|
} finally {
|
SpObserver.setDBtoInstance();
|
}
|
}
|
|
/**
|
* 解绑关系
|
*
|
* @param request
|
* @param response
|
* @return
|
*/
|
@RequestMapping(value = "/mutual/unbind.do")
|
@ResponseBody
|
public Object unbind(Integer dbId, String code, Integer action, HttpServletRequest request, HttpServletResponse response) {
|
CallBackMessage callBackMessage = new CallBackMessage();
|
try {
|
String newDbId = request.getSession().getAttribute(SessionKey.DATA_BASE_ID) + "";
|
SpObserver.setDBtoInstance("_" + newDbId);
|
if (StringUtils.isBlank(code)) {
|
throw new ApplicationException("code参数不能为空");
|
}
|
if (dbId == null || dbId.intValue() <= 0) {
|
throw new ApplicationException("dbId参数值要大于0");
|
}
|
BaseController baseController = (BaseController) FactoryBean.getBean("baseController");
|
String url = "";
|
if (action.intValue() == 110203) {
|
//-解除本地客户
|
SaveEntity saveEntity = new SaveEntity();
|
saveEntity.setCltCode(code);
|
saveEntity.setUnbind(true);
|
mutualServiceIfc.save110203(saveEntity);
|
//--解除外部系统对应供应商,取出dbId对应的域名,组装url对外推送
|
final DataSourceEntity dataSourceMap = MultiDataSource.getDataSourceMap(dbId + "");
|
url = getSystemUrlByDataSource(dataSourceMap) + "/mutual/unbind110302.do?dbId=" + dbId + "&refDbId=" + newDbId;
|
|
} else {
|
//已绑定供应商表
|
SaveEntity saveEntity = new SaveEntity();
|
saveEntity.setVndCode(code);
|
saveEntity.setUnbind(true);
|
mutualServiceIfc.save110302(saveEntity);
|
//--解除外部系统对应客户,取出dbId对应的域名,组装url对外推送
|
final DataSourceEntity dataSourceMap = MultiDataSource.getDataSourceMap(dbId + "");
|
url = getSystemUrlByDataSource(dataSourceMap) + "/mutual/unbind110203.do?dbId=" + dbId + "&refDbId=" + newDbId;
|
}
|
final String result = baseController.doGetByParameter(url);
|
Map message = JSON.parseObject(result, Map.class);
|
return message;
|
} catch (Exception e) {
|
callBackMessage.sendErrorMessage(e.getCause() != null ? (e.getCause().getMessage()).trim() : e.getMessage());
|
return callBackMessage.toJSONObject();
|
} finally {
|
SpObserver.setDBtoInstance();
|
}
|
}
|
|
/**
|
* 解绑客户
|
*
|
* @param dbId --操作哪一个数据源
|
* @param refDbId ---解绑哪一个客户
|
* @return
|
*/
|
@RequestMapping(value = "/mutual/unbind110203.do")
|
@ResponseBody
|
public Object unbind110203(Integer dbId, Integer refDbId, HttpServletRequest request, HttpServletResponse response) {
|
CallBackMessage callBackMessage = new CallBackMessage();
|
try {
|
SpObserver.setDBtoInstance("_" + dbId);
|
Integer result = mutualServiceIfc.unbind110203(refDbId);
|
if (result == 0) {
|
throw new ApplicationException("解绑【" + refDbId + "】客户关系出错!");
|
}
|
callBackMessage.sendSuccessMessageByDefault();
|
return callBackMessage.toJSONObject();
|
} catch (Exception e) {
|
callBackMessage.sendErrorMessage(e.getCause() != null ? (e.getCause().getMessage()).trim() : e.getMessage());
|
return callBackMessage.toJSONObject();
|
} finally {
|
SpObserver.setDBtoInstance();
|
}
|
}
|
|
/**
|
* 解绑经销商
|
*
|
* @param dbId --操作哪一个数据源
|
* @param refDbId ---解绑哪一个供应商
|
* @return
|
*/
|
@RequestMapping(value = "/mutual/unbind110302.do")
|
@ResponseBody
|
public Object unbind110302(Integer dbId, Integer refDbId, HttpServletRequest request, HttpServletResponse response) {
|
CallBackMessage callBackMessage = new CallBackMessage();
|
try {
|
SpObserver.setDBtoInstance("_" + dbId);
|
Integer result = mutualServiceIfc.unbind110302(refDbId);
|
if (result == 0) {
|
throw new ApplicationException("绑定【" + refDbId + "】供应商关系出错!");
|
}
|
callBackMessage.sendSuccessMessageByDefault();
|
return callBackMessage.toJSONObject();
|
} catch (Exception e) {
|
callBackMessage.sendErrorMessage(e.getCause() != null ? (e.getCause().getMessage()).trim() : e.getMessage());
|
return callBackMessage.toJSONObject();
|
} finally {
|
SpObserver.setDBtoInstance();
|
}
|
}
|
|
/**
|
* 获取系统Logo
|
*
|
* @param dbId --操作哪一个数据源
|
* @return
|
*/
|
@RequestMapping(value = "/mutual/getLogo.do")
|
@ResponseBody
|
public Object getLogoByDbid(Integer dbId, HttpServletRequest request, HttpServletResponse response) {
|
CallBackMessage callBackMessage = new CallBackMessage();
|
try {
|
final DataSourceEntity dataSourceMap = MultiDataSource.getDataSourceMap(dbId + "");
|
callBackMessage.setInfo(getSystemUrlByDataSource(dataSourceMap) + getLogo(dbId + ""));
|
callBackMessage.sendSuccessMessageByDefault();
|
return callBackMessage.toJSONObject();
|
} catch (Exception e) {
|
callBackMessage.sendErrorMessage(e.getCause() != null ? (e.getCause().getMessage()).trim() : e.getMessage());
|
return callBackMessage.toJSONObject();
|
}
|
}
|
|
public String getSystemUrlByDataSource(DataSourceEntity dataSourceMap) {
|
String url = "";
|
boolean isHttps;//是否已开启https
|
if (!"https".equalsIgnoreCase(dataSourceMap.getProtocol())) {
|
isHttps = false;
|
} else {
|
isHttps = true;
|
}
|
String domain = dataSourceMap.getDomain();
|
String[] domainList = domain.split(";");
|
boolean isfound = false;
|
if (isHttps) {
|
if (!isfound) {//查找443 https
|
for (String s : domainList) {
|
if (s.indexOf(":") < 0) {// 取443端口
|
// s = getProtocol(map, s);
|
url = "https://" + s;
|
isfound = true;
|
break;
|
}
|
}
|
}
|
} else {
|
if (!isfound && domain.indexOf(":9001") > 0) {
|
for (String s : domainList) {
|
if (s.indexOf(":9001") > 0) {// 优先9001,&&s.startsWith("192.168.100.202")
|
//s = getProtocol(map, s);
|
url = "http://" + s;
|
isfound = true;
|
break;
|
}
|
}
|
}
|
if (!isfound && domain.indexOf(":80") > 0) {
|
for (String s : domainList) {
|
if (s.indexOf(":80") > 0) {
|
//s = getProtocol(map, s);
|
url = "http://" + s;
|
isfound = true;
|
break;
|
}
|
}
|
}
|
}
|
return url;
|
}
|
|
/**
|
* 执行取消确认前先删除对方的单据
|
* 如:采购订单取消确认,则需要把对方未确认的销售订单删除,如果已确认则不能删除,提示已审核需要对方手动取消确认
|
*/
|
public void proccessCanelProc(String dbId, int formid, String docCode, String action,String checkPoint) throws Exception {
|
final Task task = InitSystemTaks.getTaskByFormid(dbId, formid);
|
if(task==null){
|
return;
|
}
|
switch (task.getApiCode()){
|
case "OP0016":
|
CanelProcBy130301 canelProcBy130301 =(CanelProcBy130301)FactoryBean.getBean("canelProcBy130301");
|
canelProcBy130301.run(dbId,action,formid,docCode,checkPoint,this,mutualServiceIfc);
|
break;
|
case "OP0018" :
|
CanelProcBy150201 canelProcBy150201 =(CanelProcBy150201)FactoryBean.getBean("canelProcBy150201");
|
canelProcBy150201.run(dbId,formid,docCode,action,checkPoint,this,mutualServiceIfc);
|
break;
|
case "OP0019":
|
CanelProcBy150206 canelProcBy150206 =(CanelProcBy150206)FactoryBean.getBean("canelProcBy150206");
|
canelProcBy150206.run(dbId,formid,docCode,action,checkPoint,this,mutualServiceIfc);
|
break;
|
case "OP0035":
|
MaintainPayMessageGate maintainPayMessageGate= (MaintainPayMessageGate) FactoryBean.getBean("maintainPayMessageGate");
|
maintainPayMessageGate.run(dbId,formid,docCode,action,checkPoint);
|
break;
|
case "OP0037":
|
UfidaCanelProcBy130301 ufidaCanelProcBy130301 =(UfidaCanelProcBy130301)FactoryBean.getBean("ufidaCanelProcBy130301");
|
ufidaCanelProcBy130301.run(dbId ,action,formid,docCode,checkPoint);
|
break;
|
}
|
|
}
|
|
/**
|
* 统一推送
|
*
|
* @param dbId--对方的dbid
|
* @param formId--本身的功能号
|
* @param docCode--本身的单号
|
* @param object--对方接收需要的数据,包括对方的单号,自身的dbid
|
*/
|
public String createDataAndPush(String dbId, int formId, String docCode, String action, Object object) throws Exception {
|
//取得对应数据源中的accessKey,api调用使用
|
final DataSourceEntity dataSourceMap = MultiDataSource.getDataSourceMap(dbId);
|
String url = this.getSystemUrlByDataSource(dataSourceMap);
|
//------TODO 测试用,正式时 需要去掉
|
// if (url.startsWith("https:")) {
|
// url = url.replace("https:", "http:") + ":9010";
|
//
|
// } else {
|
// url = url.replace(":9001", ":9010");
|
// }
|
//------------
|
//url="http://localhost:9001";
|
String data = JSON.toJSONString(object);
|
url += "/open/mutual/" + action + baseController.getSignV2(data, dbId);
|
//log.info("内部推送url:"+url);
|
//log.info("内部推送data:"+data);
|
return baseController.doPostByParameter(url, URLEncoder.encode(data, "UTF-8"));
|
|
}
|
}
|