|
@@ -4,7 +4,6 @@ import cn.hutool.core.bean.BeanUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.sun.org.apache.xpath.internal.operations.Bool;
|
|
|
import com.zfire.jiasm.syncdata.constant.ESInstallEnum;
|
|
|
import com.zfire.jiasm.syncdata.data.Token;
|
|
|
import com.zfire.jiasm.syncdata.plus.entity.*;
|
|
@@ -21,7 +20,6 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-import java.sql.Timestamp;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
|
|
@@ -145,14 +143,33 @@ public class AnzhuangGongDanDownloadTask {
|
|
|
// 工单落入本地表
|
|
|
@Scheduled(fixedDelay = 1 * 30 * 1000)
|
|
|
public void inputOrderInstall() throws Exception {
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
List<ItfTblAzAssignLcLsDownload> lcls = new ArrayList<>();
|
|
|
+
|
|
|
+ log.info("安装工单落本地表开始处理: {}",sdf.format(new Date()));
|
|
|
+
|
|
|
+ lcls = itfTblAzAssignLcLsDownloadService.lambdaQuery()
|
|
|
+ .eq(ItfTblAzAssignLcLsDownload::getSynStatus,0)
|
|
|
+ .eq(ItfTblAzAssignLcLsDownload::getSynReqId,167)
|
|
|
+ .list();
|
|
|
+ // 按单处理
|
|
|
+ for (ItfTblAzAssignLcLsDownload item: lcls) {
|
|
|
+ // 处理安装工单主表
|
|
|
+ extractedOrderInstall(item);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ log.info("安装工单落本地表完成: {}",sdf.format(new Date()));
|
|
|
+ }
|
|
|
+
|
|
|
+ private void extractedOrderInstall(ItfTblAzAssignLcLsDownload item) {
|
|
|
List<OrderInstallDetail> recs = new ArrayList<>();
|
|
|
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
Boolean flag = Boolean.FALSE;
|
|
|
Boolean lclsAddFlag = Boolean.FALSE;
|
|
|
OrderApplyDispatch orderapp = null;
|
|
|
OrderApplyDispatch orderApplyDispatch = null;
|
|
|
-
|
|
|
OrderInstallOperatingLog recLog = null;
|
|
|
Integer orderState = 0;
|
|
|
String workerOrderNo = "";
|
|
@@ -162,157 +179,145 @@ public class AnzhuangGongDanDownloadTask {
|
|
|
String xslx = null;
|
|
|
String mainName = null;
|
|
|
Long sxlxid = 0l;
|
|
|
-
|
|
|
- log.info("安装工单落本地表开始处理: {}",sdf.format(new Date()));
|
|
|
-
|
|
|
- lcls = itfTblAzAssignLcLsDownloadService.lambdaQuery()
|
|
|
- .eq(ItfTblAzAssignLcLsDownload::getSynStatus,0)
|
|
|
- .eq(ItfTblAzAssignLcLsDownload::getSynReqId,167)
|
|
|
- .list();
|
|
|
- // 按单处理
|
|
|
- for (ItfTblAzAssignLcLsDownload item: lcls) {
|
|
|
- recLog = null;
|
|
|
- orderapp = null;
|
|
|
- orderApplyDispatch = null;
|
|
|
- sxlxid = 1l;
|
|
|
-
|
|
|
- // 获取销售类型 ID
|
|
|
- sxlxid = getxslxid(item);
|
|
|
- azwdno = getAzwdno(item);
|
|
|
- xslx = null;
|
|
|
- if (BeanUtil.isNotEmpty(item.getXslx())){
|
|
|
- xslx = item.getXslx().trim();
|
|
|
+ recLog = null;
|
|
|
+ orderapp = null;
|
|
|
+ orderApplyDispatch = null;
|
|
|
+ sxlxid = 1l;
|
|
|
+
|
|
|
+ // 获取销售类型 ID
|
|
|
+ sxlxid = getxslxid(item);
|
|
|
+ azwdno = getAzwdno(item);
|
|
|
+ xslx = null;
|
|
|
+ if (BeanUtil.isNotEmpty(item.getXslx())){
|
|
|
+ xslx = item.getXslx().trim();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 判断安装网点编号是否为空或者为公司,如果为空或为公司,就写入接收派工网点
|
|
|
+
|
|
|
+ // 看安装工单是否存在
|
|
|
+ OrderInstall orderItem = orderInstallService.lambdaQuery()
|
|
|
+ .eq(OrderInstall::getPgguid, item.getPgguid()).one();
|
|
|
+
|
|
|
+ if (orderItem !=null){
|
|
|
+ flag = Boolean.FALSE;
|
|
|
+ lclsAddFlag = Boolean.FALSE;
|
|
|
+
|
|
|
+ // 工单已关闭不再做更新操作
|
|
|
+ if (orderItem.getOrderState().equals(10) && item.getLastModifiedDate().compareTo(orderItem.getUpdatetime())<0){
|
|
|
+ item.setSynStatus(99);
|
|
|
+ item.setSynTime(new Date());
|
|
|
+ item.setSynErrMsg("广州系统已关闭或作废忽略更新");
|
|
|
+ itfTblAzAssignLcLsDownloadService.updateById(item);
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
- // 判断安装网点编号是否为空或者为公司,如果为空或为公司,就写入接收派工网点
|
|
|
-
|
|
|
- // 看安装工单是否存在
|
|
|
- OrderInstall orderItem = orderInstallService.lambdaQuery()
|
|
|
- .eq(OrderInstall::getPgguid,item.getPgguid()).one();
|
|
|
-
|
|
|
- if (orderItem !=null){
|
|
|
- flag = Boolean.FALSE;
|
|
|
- lclsAddFlag = Boolean.FALSE;
|
|
|
-
|
|
|
- // 工单已关闭不再做更新操作
|
|
|
- if (orderItem.getOrderState().equals(10) && item.getLastModifiedDate().compareTo(orderItem.getUpdatetime())<0){
|
|
|
- item.setSynStatus(99);
|
|
|
- item.setSynTime(new Date());
|
|
|
- item.setSynErrMsg("广州系统已关闭或作废忽略更新");
|
|
|
- itfTblAzAssignLcLsDownloadService.updateById(item);
|
|
|
- continue;
|
|
|
- }
|
|
|
+ Date reservebegin = orderItem.getReserveBegin();
|
|
|
+ cjDownloadFlag = orderItem.getCjDownloadFlag();
|
|
|
+ mainName = null;
|
|
|
+ if (BeanUtil.isNotEmpty(orderItem.getMainName())){
|
|
|
+ mainName = orderItem.getMainName().trim();
|
|
|
+ }
|
|
|
|
|
|
- Date reservebegin = orderItem.getReserveBegin();
|
|
|
- cjDownloadFlag = orderItem.getCjDownloadFlag();
|
|
|
- mainName = null;
|
|
|
- if (BeanUtil.isNotEmpty(orderItem.getMainName())){
|
|
|
- mainName = orderItem.getMainName().trim();
|
|
|
- }
|
|
|
+ yjhxDownloadFlag = 0;
|
|
|
+ if (BeanUtil.isNotEmpty(orderItem.getYjhxDownloadFlag())){
|
|
|
+ yjhxDownloadFlag = orderItem.getYjhxDownloadFlag();
|
|
|
+ }
|
|
|
|
|
|
- yjhxDownloadFlag = 0;
|
|
|
- if (BeanUtil.isNotEmpty(orderItem.getYjhxDownloadFlag())){
|
|
|
- yjhxDownloadFlag = orderItem.getYjhxDownloadFlag();
|
|
|
- }
|
|
|
+ // 判断京东虚拟号是否总部有更新
|
|
|
+ if (BeanUtil.isNotEmpty(item.getFjhm())){
|
|
|
+ orderItem.setGreeVirtualnumber(item.getFjhm());
|
|
|
+ flag = Boolean.TRUE;
|
|
|
+ }
|
|
|
|
|
|
- // 判断京东虚拟号是否总部有更新
|
|
|
- if (BeanUtil.isNotEmpty(item.getFjhm())){
|
|
|
- orderItem.setGreeVirtualnumber(item.getFjhm());
|
|
|
- flag = Boolean.TRUE;
|
|
|
- }
|
|
|
+ // 1:总部工单的修改时间时间晚于系统修改时间需更新系统订单信息
|
|
|
+ flag = updateOldOrder(item, orderItem,sxlxid);
|
|
|
|
|
|
- // 1:总部工单的修改时间时间晚于系统修改时间需更新系统订单信息
|
|
|
- flag = updateOldOrder(item, orderItem);
|
|
|
+ // 2:网点修改
|
|
|
+ flag = updateOldOrderWD(orderState, item, orderItem);
|
|
|
|
|
|
- // 2:网点修改
|
|
|
- flag = updateOldOrderWD(orderState,item, orderItem);
|
|
|
+ // 3:预约时间更新
|
|
|
+ flag = getUpdateOrderYYSJ(flag, item, orderItem, reservebegin);
|
|
|
|
|
|
- // 3:预约时间更新
|
|
|
- flag = getUpdateOrderYYSJ(flag, item, orderItem, reservebegin);
|
|
|
+ // 4:状态信息更新 获取安装工单的状态是否允许更新
|
|
|
+ flag = getupdateStatus(flag, item, orderItem, orderState);
|
|
|
|
|
|
- // 4:状态信息更新 获取安装工单的状态是否允许更新
|
|
|
- flag = getupdateStatus(flag, item, orderItem, orderState);
|
|
|
+ // 5:预派工标志更新
|
|
|
+ flag = getaBooleanFlag(flag, item, orderItem);
|
|
|
|
|
|
- // 5:预派工标志更新
|
|
|
- flag = getaBooleanFlag(flag, item, orderItem);
|
|
|
+ } else {
|
|
|
+ flag = Boolean.TRUE;
|
|
|
+ // 新增
|
|
|
+ lclsAddFlag = Boolean.TRUE;
|
|
|
+ // 生成订单主表对象
|
|
|
+ orderItem = getOrderInstall(item,sxlxid);
|
|
|
+ // 分销商城订单 写入fa_order_install_operating_log表
|
|
|
+ getOrderInstallLog(item, orderItem, recLog);
|
|
|
+ }
|
|
|
|
|
|
- } else {
|
|
|
- flag = Boolean.TRUE;
|
|
|
- // 新增
|
|
|
- lclsAddFlag = Boolean.TRUE;
|
|
|
- // 生成订单主表对象
|
|
|
- orderItem = getOrderInstall(item);
|
|
|
- // 分销商城订单 写入fa_order_install_operating_log表
|
|
|
- getOrderInstallLog(item, orderItem, recLog);
|
|
|
- }
|
|
|
+ orderState = orderItem.getOrderState();
|
|
|
+ workerOrderNo = orderItem.getWorkerOrderNo();
|
|
|
|
|
|
- orderState = orderItem.getOrderState();
|
|
|
- workerOrderNo = orderItem.getWorkerOrderNo();
|
|
|
+ // 处理1121,1125时判断after_number是否为中心,如果不是则order_state = '3';
|
|
|
+ // 总部下来的关闭工单要修改最后更新时间,否则不会产生结算完工数据
|
|
|
+ extractedOther(orderState, workerOrderNo, item, orderItem);
|
|
|
|
|
|
- // 处理1121,1125时判断after_number是否为中心,如果不是则order_state = '3';
|
|
|
- // 总部下来的关闭工单要修改最后更新时间,否则不会产生结算完工数据
|
|
|
- extractedOther(orderState, workerOrderNo, item, orderItem);
|
|
|
-
|
|
|
- // 改派处理
|
|
|
- orderApplyDispatch = getOrderApplyDispatch(orderapp, workerOrderNo, item, orderItem);
|
|
|
+ // 改派处理
|
|
|
+ orderApplyDispatch = getOrderApplyDispatch(orderapp, workerOrderNo, item, orderItem);
|
|
|
|
|
|
- // 处理跨区,如果接收派工网点与所属区域有差异时,直接修改
|
|
|
- extractedOrderJD(item, orderItem);
|
|
|
+ // 处理跨区,如果接收派工网点与所属区域有差异时,直接修改
|
|
|
+ extractedOrderJD(item, orderItem);
|
|
|
|
|
|
- BrandWebsit brandWebsit = null;
|
|
|
- if (azwdno.equals("99999999")){
|
|
|
- brandWebsit = brandWebsitService.lambdaQuery()
|
|
|
- .eq(BrandWebsit::getBrandWebsitNumber,azwdno)
|
|
|
- .eq(BrandWebsit::getType,"professionazwdno").one();
|
|
|
- } else {
|
|
|
- brandWebsit = brandWebsitService.lambdaQuery()
|
|
|
- .eq(BrandWebsit::getBrandWebsitNumber,item.getJspgwdno()).one();
|
|
|
+ BrandWebsit brandWebsit = null;
|
|
|
+ if (azwdno.equals("99999999")){
|
|
|
+ brandWebsit = brandWebsitService.lambdaQuery()
|
|
|
+ .eq(BrandWebsit::getBrandWebsitNumber,azwdno)
|
|
|
+ .eq(BrandWebsit::getType,"professionazwdno").one();
|
|
|
+ } else {
|
|
|
+ brandWebsit = brandWebsitService.lambdaQuery()
|
|
|
+ .eq(BrandWebsit::getBrandWebsitNumber, item.getJspgwdno()).one();
|
|
|
+ }
|
|
|
+ // 修改销售公司信息 需确认网点信息表 修改订单主表 todo
|
|
|
+
|
|
|
+ //增加处理采集数据下载
|
|
|
+ OrderInstallDetail orderDetailRec = null;
|
|
|
+ OrderInstallDetail delorderDetailRec = null;
|
|
|
+ if ((item.getDqjd().equals(1304L) || item.getDqjd().equals(1309L)) && cjDownloadFlag == 0){
|
|
|
+ orderDetailRec = orderInstallDetailService.lambdaQuery()
|
|
|
+ .eq(OrderInstallDetail::getWorkerOrderNo,workerOrderNo)
|
|
|
+ .eq(OrderInstallDetail::getStatus,1).one();
|
|
|
+ // 存在状态为"已采集"的记录暂时忽略下载
|
|
|
+ if (orderDetailRec !=null && item.getDqjd().equals(1309L) && orderDetailRec.getDetailSource().equals(1)){
|
|
|
+ orderItem.setUploadNotifyFlag(1);
|
|
|
}
|
|
|
- // 修改销售公司信息 需确认网点信息表 修改订单主表 todo
|
|
|
-
|
|
|
- //增加处理采集数据下载
|
|
|
- OrderInstallDetail orderDetailRec = null;
|
|
|
- OrderInstallDetail delorderDetailRec = null;
|
|
|
- if ((item.getDqjd().equals(1304L) || item.getDqjd().equals(1309L)) && cjDownloadFlag == 0){
|
|
|
- orderDetailRec = orderInstallDetailService.lambdaQuery()
|
|
|
- .eq(OrderInstallDetail::getWorkerOrderNo,workerOrderNo)
|
|
|
- .eq(OrderInstallDetail::getStatus,1).one();
|
|
|
- // 存在状态为"已采集"的记录暂时忽略下载
|
|
|
- if (orderDetailRec !=null && item.getDqjd().equals(1309L) && orderDetailRec.getDetailSource().equals(1)){
|
|
|
- orderItem.setUploadNotifyFlag(1);
|
|
|
- }
|
|
|
- } else {
|
|
|
- // 清除本地的采集数据
|
|
|
- delorderDetailRec = orderInstallDetailService.lambdaQuery()
|
|
|
- .eq(OrderInstallDetail::getWorkerOrderNo,workerOrderNo)
|
|
|
- .eq(OrderInstallDetail::getStatus,0).one();
|
|
|
- if (orderDetailRec !=null){
|
|
|
- orderInstallDetailService.removeById(delorderDetailRec);
|
|
|
- }
|
|
|
-
|
|
|
- // 仅向表 itf_gree_to_fa_download_task_list 写数据需确认,暂不处理 todo
|
|
|
- if (BeanUtil.isNotEmpty(mainName)
|
|
|
- && (mainName.equals("家用空调") || mainName.equals("家用空气能热水器") || mainName.equals("驻车空调"))){
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
+ } else {
|
|
|
+ // 清除本地的采集数据
|
|
|
+ delorderDetailRec = orderInstallDetailService.lambdaQuery()
|
|
|
+ .eq(OrderInstallDetail::getWorkerOrderNo,workerOrderNo)
|
|
|
+ .eq(OrderInstallDetail::getStatus,0).one();
|
|
|
+ if (orderDetailRec !=null){
|
|
|
+ orderInstallDetailService.removeById(delorderDetailRec);
|
|
|
}
|
|
|
|
|
|
// 仅向表 itf_gree_to_fa_download_task_list 写数据需确认,暂不处理 todo
|
|
|
- if (BeanUtil.isNotEmpty(xslx) && (xslx.equals("以旧换新") || xslx.equals("格力商城-以旧换新") || xslx.equals("格力商城-以旧换新2"))
|
|
|
- && (yjhxDownloadFlag == 0)) {
|
|
|
+ if (BeanUtil.isNotEmpty(mainName)
|
|
|
+ && (mainName.equals("家用空调") || mainName.equals("家用空气能热水器") || mainName.equals("驻车空调"))){
|
|
|
|
|
|
}
|
|
|
- // // 仅向表 itf_gree_to_fa_download_task_list 写数据需确认,暂不处理 todo
|
|
|
- if (BeanUtil.isNotEmpty(xslx) && (xslx.equals("以旧换新") || xslx.equals("格力商城-以旧换新") || xslx.equals("格力商城-以旧换新2"))) {
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
+ // 仅向表 itf_gree_to_fa_download_task_list 写数据需确认,暂不处理 todo
|
|
|
+ if (BeanUtil.isNotEmpty(xslx) && (xslx.equals("以旧换新") || xslx.equals("格力商城-以旧换新") || xslx.equals("格力商城-以旧换新2"))
|
|
|
+ && (yjhxDownloadFlag == 0)) {
|
|
|
|
|
|
- // 数据插入或修改
|
|
|
- insertOrUpdate(flag, lclsAddFlag, orderapp, orderApplyDispatch, recLog, item, orderItem);
|
|
|
}
|
|
|
+ // // 仅向表 itf_gree_to_fa_download_task_list 写数据需确认,暂不处理 todo
|
|
|
+ if (BeanUtil.isNotEmpty(xslx) && (xslx.equals("以旧换新") || xslx.equals("格力商城-以旧换新") || xslx.equals("格力商城-以旧换新2"))) {
|
|
|
|
|
|
- log.info("安装工单落本地表完成: {}",sdf.format(new Date()));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 数据插入或修改 事务统一处理
|
|
|
+ insertOrUpdate(flag, lclsAddFlag, orderapp, orderApplyDispatch, recLog, item, orderItem);
|
|
|
}
|
|
|
|
|
|
private Boolean getaBooleanFlag(Boolean flag, ItfTblAzAssignLcLsDownload item, OrderInstall orderItem) {
|
|
@@ -327,9 +332,6 @@ public class AnzhuangGongDanDownloadTask {
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void insertOrUpdate(Boolean flag, Boolean lclsAddFlag, OrderApplyDispatch orderapp, OrderApplyDispatch orderApplyDispatch, OrderInstallOperatingLog recLog, ItfTblAzAssignLcLsDownload item, OrderInstall orderItem) {
|
|
|
// 数据落表
|
|
|
-
|
|
|
- // 修改主表处理完成
|
|
|
- upLcLsDownLoad(item);
|
|
|
// 工单主表
|
|
|
if (flag){
|
|
|
if (lclsAddFlag){
|
|
@@ -353,6 +355,9 @@ public class AnzhuangGongDanDownloadTask {
|
|
|
if (orderApplyDispatch != null){
|
|
|
orderApplyDispatchService.updateById(orderApplyDispatch);
|
|
|
}
|
|
|
+
|
|
|
+ // 修改下截的安装工单主表 - 处理完成
|
|
|
+ upLcLsDownLoad(item);
|
|
|
}
|
|
|
|
|
|
private void upLcLsDownLoad(ItfTblAzAssignLcLsDownload item) {
|
|
@@ -698,7 +703,7 @@ public class AnzhuangGongDanDownloadTask {
|
|
|
return Boolean.FALSE;
|
|
|
}
|
|
|
|
|
|
- private Boolean updateOldOrder(ItfTblAzAssignLcLsDownload item, OrderInstall oldOrder) {
|
|
|
+ private Boolean updateOldOrder(ItfTblAzAssignLcLsDownload item, OrderInstall oldOrder, Long sxlxid) {
|
|
|
if (item.getLastModifiedDate().compareTo(oldOrder.getUpdatetime())>0){
|
|
|
oldOrder.setLastUpdSynReqId(String.valueOf(item.getSynReqId()));
|
|
|
oldOrder.setLastUpdSynTime(new Date());
|
|
@@ -739,6 +744,7 @@ public class AnzhuangGongDanDownloadTask {
|
|
|
oldOrder.setGreeVirtualnumber(item.getFjhm());
|
|
|
}
|
|
|
/// 再添加成员变量
|
|
|
+ oldOrder.setSalesTypeId(Integer.valueOf(sxlxid.toString()));
|
|
|
|
|
|
return Boolean.TRUE;
|
|
|
}
|
|
@@ -765,7 +771,7 @@ public class AnzhuangGongDanDownloadTask {
|
|
|
}
|
|
|
|
|
|
@NotNull
|
|
|
- private OrderInstall getOrderInstall(ItfTblAzAssignLcLsDownload item) {
|
|
|
+ private OrderInstall getOrderInstall(ItfTblAzAssignLcLsDownload item,Long sxlxid) {
|
|
|
OrderInstall rec = new OrderInstall();
|
|
|
|
|
|
rec.setWorkerOrderNo(UUID.randomUUID().toString());
|
|
@@ -809,6 +815,7 @@ public class AnzhuangGongDanDownloadTask {
|
|
|
|
|
|
|
|
|
// 增加参数 todo
|
|
|
+ rec.setSalesTypeId(Integer.valueOf(sxlxid.toString()));
|
|
|
|
|
|
|
|
|
// 接收派工网点是否为中心,且下传的当前节点是不是1129或1301,如果是就更新为2待分部派工
|