|
|
@@ -0,0 +1,1329 @@
|
|
|
+package com.zfire.jiasm.syncdata.download.order;
|
|
|
+
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
+import com.zfire.jiasm.syncdata.base.BaseService;
|
|
|
+import com.zfire.jiasm.syncdata.constant.ESInstallEnum;
|
|
|
+import com.zfire.jiasm.syncdata.dao.mapper.AzGDLcLsDownloadMapper;
|
|
|
+import com.zfire.jiasm.syncdata.data.Token;
|
|
|
+import com.zfire.jiasm.syncdata.plus.entity.*;
|
|
|
+import com.zfire.jiasm.syncdata.plus.service.*;
|
|
|
+import com.zfire.jiasm.syncdata.utils.DataUtil;
|
|
|
+import com.zfire.jiasm.syncdata.utils.HttpUtil;
|
|
|
+import com.zfire.jiasm.syncdata.utils.JSONResult;
|
|
|
+import com.zfire.jiasm.syncdata.utils.TokenCenter;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.jetbrains.annotations.NotNull;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.scheduling.annotation.Scheduled;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 格力品牌安装工单下载后落本地数据表
|
|
|
+ * 3:落业务表
|
|
|
+ *:4:修改下载主表处理结果
|
|
|
+ * 3-4需增加单独任务,确保中断异常
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+@Component
|
|
|
+public class AnzhuangGongDanBusiness {
|
|
|
+ @Value("${baseurl}")
|
|
|
+ private String baseurl = "";
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private TokenCenter tokenCenter;
|
|
|
+ @Resource
|
|
|
+ ItfInstallBatchDownloadRecService itfInstallBatchDownloadRecService;
|
|
|
+ @Resource
|
|
|
+ ItfTblAzAssignLcLsDownloadService itfTblAzAssignLcLsDownloadService;
|
|
|
+ @Resource
|
|
|
+ ItfTblAzAssignMxDownloadService itfTblAzAssignMxDownloadService;
|
|
|
+ @Resource
|
|
|
+ ItfTblAzAssignFkmxDownloadService itfTblAzAssignFkMxDownloadService;
|
|
|
+ @Resource
|
|
|
+ ItfTblAzAssignFeeDownloadService itfTblAzAssignFeeDownloadService;
|
|
|
+ @Resource
|
|
|
+ ItfTblAzAssignAppointmentDownloadService itfTblAzAssignAppointmentDownloadService;
|
|
|
+ @Resource
|
|
|
+ ItfTblAzAssignLcFzryDownloadService itfTblAzAssignLcFzryDownloadService;
|
|
|
+ @Resource
|
|
|
+ ItfTblAzAssignSatisfactionDownloadService itfTblAzAssignSatisfactionDownloadService;
|
|
|
+ @Resource
|
|
|
+ ItfTblAzAssignPlatformDownloadService itfTblAzAssignPlatformDownloadService;
|
|
|
+ @Resource
|
|
|
+ AzGDLcLsDownloadMapper azGDLcLsDownloadMapper;
|
|
|
+ @Resource
|
|
|
+ BaseService baseService;
|
|
|
+
|
|
|
+
|
|
|
+ // 3:工单落入本地表
|
|
|
+ @Scheduled(fixedDelay = 1 * 30 * 1000)
|
|
|
+ public void inputOrderInstall() throws Exception {
|
|
|
+
|
|
|
+ if (1 == 1) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ List<ItfTblAzAssignLcLsDownload> lcls = new ArrayList<>();
|
|
|
+ OrderBase orderBase = new OrderBase();
|
|
|
+
|
|
|
+ log.info("安装工单落本地表开始处理: {}",sdf.format(new Date()));
|
|
|
+
|
|
|
+ lcls = itfTblAzAssignLcLsDownloadService.lambdaQuery()
|
|
|
+ .eq(ItfTblAzAssignLcLsDownload::getSynStatus,0)
|
|
|
+ .eq(ItfTblAzAssignLcLsDownload::getSynReqId,1)
|
|
|
+ .list();
|
|
|
+ // 按单处理
|
|
|
+ for (ItfTblAzAssignLcLsDownload item: lcls) {
|
|
|
+ // 处理安装工单主表
|
|
|
+ extractedOrderInstall(item);
|
|
|
+
|
|
|
+ // 省市区单独处理
|
|
|
+ /*select aa.area,aa.area_id,aa.city_id,aa.province_id,
|
|
|
+ bb.lbs_province_id,bb.lbs_province_name,bb.lbs_city_id,bb.lbs_city_name,bb.lbs_district_id,bb.lbs_district_name
|
|
|
+ from area aa
|
|
|
+ left join brand_lbs_relate bb on aa.area_id=bb.area_id and bb.lbs_district_id is not null
|
|
|
+ where area = '天河区' limit 1;*/
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ log.info("安装工单落本地表完成: {}",sdf.format(new Date()));
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private Boolean extractedOrderInstall(ItfTblAzAssignLcLsDownload item) {
|
|
|
+ OrderBase orderBase = new OrderBase();
|
|
|
+ // 提取品牌信息
|
|
|
+ Brand brand = baseService.getBrand();
|
|
|
+ if (brand == null) {
|
|
|
+ return Boolean.FALSE;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // 生成工单基础表 对象
|
|
|
+ orderBase = azGDLcLsDownloadMapper.getOrderBase(item.getSynReqId());
|
|
|
+
|
|
|
+ // 重置部分数据
|
|
|
+ // 品牌信息
|
|
|
+ orderBase.setBrandId(brand.getBrandId());
|
|
|
+ orderBase.setBrandName(brand.getBrand());
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ return Boolean.TRUE;
|
|
|
+ }
|
|
|
+
|
|
|
+/*
|
|
|
+ // 3:工单落入本地表
|
|
|
+ @Scheduled(fixedDelay = 1 * 30 * 1000)
|
|
|
+ public void inputOrderInstall() throws Exception {
|
|
|
+ if (1 == 1) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ 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 Boolean extractedOrderInstall(ItfTblAzAssignLcLsDownload item) {
|
|
|
+ List<OrderInstallDetail> recs = new ArrayList<>();
|
|
|
+ Boolean flag = Boolean.FALSE;
|
|
|
+ Boolean lclsAddFlag = Boolean.FALSE;
|
|
|
+ OrderApplyDispatch orderapp = null;
|
|
|
+ OrderApplyDispatch orderApplyDispatch = null;
|
|
|
+ OrderInstallOperatingLog recLog = null;
|
|
|
+ Integer orderState = 0;
|
|
|
+ String workerOrderNo = "";
|
|
|
+ String azwdno ="";
|
|
|
+ Integer cjDownloadFlag = -1;
|
|
|
+ Integer yjhxDownloadFlag = 0;
|
|
|
+ String xslx = null;
|
|
|
+ String mainName = null;
|
|
|
+ Long sxlxid = 0l;
|
|
|
+ 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 Boolean.FALSE;
|
|
|
+ }
|
|
|
+
|
|
|
+ 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();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 判断京东虚拟号是否总部有更新
|
|
|
+ if (BeanUtil.isNotEmpty(item.getFjhm())){
|
|
|
+ orderItem.setGreeVirtualnumber(item.getFjhm());
|
|
|
+ flag = Boolean.TRUE;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 1:总部工单的修改时间时间晚于系统修改时间需更新系统订单信息
|
|
|
+ flag = updateOldOrder(item, orderItem,sxlxid);
|
|
|
+
|
|
|
+ // 2:网点修改
|
|
|
+ flag = updateOldOrderWD(orderState, item, orderItem);
|
|
|
+
|
|
|
+ // 3:预约时间更新
|
|
|
+ flag = getUpdateOrderYYSJ(flag, item, orderItem, reservebegin);
|
|
|
+
|
|
|
+ // 4:状态信息更新 获取安装工单的状态是否允许更新
|
|
|
+ flag = getupdateStatus(flag, item, orderItem, orderState);
|
|
|
+
|
|
|
+ // 5:预派工标志更新
|
|
|
+ flag = getaBooleanFlag(flag, item, orderItem);
|
|
|
+
|
|
|
+ } else {
|
|
|
+ flag = Boolean.TRUE;
|
|
|
+ // 新增
|
|
|
+ lclsAddFlag = Boolean.TRUE;
|
|
|
+
|
|
|
+ // 生成订单主表对象
|
|
|
+ orderItem = getOrderInstall(item,sxlxid);
|
|
|
+ if (orderItem == null){
|
|
|
+ return Boolean.FALSE;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 分销商城订单 写入fa_order_install_operating_log表
|
|
|
+ getOrderInstallLog(item, orderItem, recLog);
|
|
|
+ }
|
|
|
+
|
|
|
+ orderState = orderItem.getOrderState();
|
|
|
+ workerOrderNo = orderItem.getWorkerOrderNo();
|
|
|
+
|
|
|
+ // 处理1121,1125时判断after_number是否为中心,如果不是则order_state = '3';
|
|
|
+ // 总部下来的关闭工单要修改最后更新时间,否则不会产生结算完工数据
|
|
|
+ extractedOther(orderState, workerOrderNo, item, orderItem);
|
|
|
+
|
|
|
+ // 改派处理
|
|
|
+ orderApplyDispatch = getOrderApplyDispatch(orderapp, workerOrderNo, 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();
|
|
|
+ }
|
|
|
+ // 修改销售公司信息 需确认网点信息表 修改订单主表 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("驻车空调"))){
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ // 仅向表 itf_gree_to_fa_download_task_list 写数据需确认,暂不处理 todo
|
|
|
+ if (BeanUtil.isNotEmpty(xslx) && (xslx.equals("以旧换新") || xslx.equals("格力商城-以旧换新") || xslx.equals("格力商城-以旧换新2"))
|
|
|
+ && (yjhxDownloadFlag == 0)) {
|
|
|
+
|
|
|
+ }
|
|
|
+ // // 仅向表 itf_gree_to_fa_download_task_list 写数据需确认,暂不处理 todo
|
|
|
+ if (BeanUtil.isNotEmpty(xslx) && (xslx.equals("以旧换新") || xslx.equals("格力商城-以旧换新") || xslx.equals("格力商城-以旧换新2"))) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ // 数据插入或修改 事务统一处理
|
|
|
+ insertOrUpdate(flag, lclsAddFlag, orderapp, orderApplyDispatch, recLog, item, orderItem);
|
|
|
+
|
|
|
+ return Boolean.TRUE;
|
|
|
+ }
|
|
|
+
|
|
|
+ private Boolean getaBooleanFlag(Boolean flag, ItfTblAzAssignLcLsDownload item, OrderInstall orderItem) {
|
|
|
+ if (orderItem.getIsReservation().equals("1") && item.getSfwcps().equals("已配送")
|
|
|
+ && (item.getDqjd().equals(1100) || item.getDqjd().equals(1122) || item.getDqjd().equals(1130))){
|
|
|
+ orderItem.setIsReservation("0");
|
|
|
+ flag = Boolean.TRUE;
|
|
|
+ }
|
|
|
+ return flag;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void insertOrUpdate(Boolean flag, Boolean lclsAddFlag, OrderApplyDispatch orderapp, OrderApplyDispatch orderApplyDispatch, OrderInstallOperatingLog recLog, ItfTblAzAssignLcLsDownload item, OrderInstall orderItem) {
|
|
|
+ // 数据落表
|
|
|
+ // 工单主表
|
|
|
+ if (flag){
|
|
|
+ if (lclsAddFlag){
|
|
|
+ orderInstallService.save(orderItem);
|
|
|
+ log.info("新增安装工单完成-工单号: {}", orderItem.getPgid());
|
|
|
+ } else {
|
|
|
+ orderInstallService.updateById(orderItem);
|
|
|
+ log.info("修改安装工单完成-工单号: {}", orderItem.getPgid());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 分销商城订单 写入fa_order_install_operating_log表
|
|
|
+ if (recLog != null){
|
|
|
+ orderInstallOperatingLogService.save(recLog);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 改派
|
|
|
+ if (orderapp !=null){
|
|
|
+ orderApplyDispatchService.save(orderapp);
|
|
|
+ }
|
|
|
+ if (orderApplyDispatch != null){
|
|
|
+ orderApplyDispatchService.updateById(orderApplyDispatch);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 修改下截的安装工单主表 - 处理完成
|
|
|
+ upLcLsDownLoad(item);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void upLcLsDownLoad(ItfTblAzAssignLcLsDownload item) {
|
|
|
+ item.setSynStatus(1);
|
|
|
+ item.setSynTime(new Date());
|
|
|
+ item.setSynErrMsg("新增数据成功");
|
|
|
+ itfTblAzAssignLcLsDownloadService.updateById(item);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void extractedOrderJD(ItfTblAzAssignLcLsDownload item, OrderInstall orderItem) {
|
|
|
+ if (item.getJspgwdno().equals("S9219801")
|
|
|
+ && (!item.getSsqy().equals("广州") || !item.getSsqy().equals("S9219801"))){
|
|
|
+ orderItem.setBelongCompanyId(2);
|
|
|
+ orderItem.setBelongCompany("S9219801");
|
|
|
+ orderItem.setOrderState(getState(item.getDqjd()));
|
|
|
+ orderItem.setLastAppointState(getAState(item.getDqjd()));
|
|
|
+ } else if (item.getJspgwdno().equals("S9219807")
|
|
|
+ && (!item.getSsqy().equals("广州") || !item.getSsqy().equals("S9219807"))){
|
|
|
+ orderItem.setBelongCompanyId(1);
|
|
|
+ orderItem.setBelongCompany("S9219807");
|
|
|
+ orderItem.setOrderState(getState(item.getDqjd()));
|
|
|
+ orderItem.setLastAppointState(getAState(item.getDqjd()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Nullable
|
|
|
+ private OrderApplyDispatch getOrderApplyDispatch(OrderApplyDispatch orderapp, String workerOrderNo, ItfTblAzAssignLcLsDownload item, OrderInstall orderItem) {
|
|
|
+ OrderApplyDispatch orderApplyDispatch;
|
|
|
+ if (item.getDqjd().equals(1135)){
|
|
|
+ orderApplyDispatch = orderApplyDispatchService.lambdaQuery()
|
|
|
+ .eq(OrderApplyDispatch::getWorkerOrderNo, workerOrderNo)
|
|
|
+ .eq(OrderApplyDispatch::getAuditState,"0").one();
|
|
|
+ if (orderApplyDispatch == null){
|
|
|
+ BeanUtil.copyProperties(orderItem, orderapp);
|
|
|
+ // 工单类型:install=安装工单,repair=维修工单
|
|
|
+ orderapp.setType("install");
|
|
|
+ orderapp.setWebsitNumber(orderItem.getAfterNumber());
|
|
|
+ orderapp.setWebsitName(orderItem.getAfterWname());
|
|
|
+ orderapp.setApplyContent("申请改派");
|
|
|
+ orderapp.setCustomerName(orderItem.getUserName());
|
|
|
+ orderapp.setCustomerPhone(orderItem.getContactPhone());
|
|
|
+ orderapp.setCreatetime(new Date());
|
|
|
+ orderapp.setUpdatetime(new Date());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 判断是否有正在改派的工单,如果没有就更新改派请求
|
|
|
+ orderApplyDispatch = orderApplyDispatchService.lambdaQuery()
|
|
|
+ .eq(OrderApplyDispatch::getWorkerOrderNo, workerOrderNo)
|
|
|
+ .eq(OrderApplyDispatch::getAuditState,"0").one();
|
|
|
+ if (orderApplyDispatch !=null){
|
|
|
+ orderApplyDispatch.setAuditState("2");
|
|
|
+ orderApplyDispatch.setAuditDesc("无效申请记录,系统自动拒绝");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return orderApplyDispatch;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void extractedOther(Integer orderState, String workerOrderNo, ItfTblAzAssignLcLsDownload item, OrderInstall orderItem) {
|
|
|
+ // 处理1121,1125时判断after_number是否为中心,如果不是则order_state = '3';
|
|
|
+ if (item.getDqjd().equals(1121) || item.getDqjd().equals(1125)){
|
|
|
+ // 这里的判断需要再增加条件
|
|
|
+ if (!(orderItem.getAfterNumber().equals("S9219801")
|
|
|
+ || orderItem.getAfterNumber().equals("S9219807")) && (orderState <6) ){
|
|
|
+ // 修改
|
|
|
+ orderItem.setOrderState(3);
|
|
|
+ orderItem.setAppointState(0);
|
|
|
+ }
|
|
|
+ // 修改时这里需要再处理
|
|
|
+ if (item.getDqjd().equals(1125) && !orderItem.getInstallWid().equals(orderItem.getAfterWid())){
|
|
|
+ orderItem.setInstallWid(Integer.valueOf(orderItem.getAfterWid()));
|
|
|
+ orderItem.setInstallNumber(orderItem.getAfterNumber());
|
|
|
+ orderItem.setInstallName(orderItem.getAfterWname());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (item.getDqjd().equals(1129) || item.getDqjd().equals(1135)){
|
|
|
+ OrderInstall oldrec = orderInstallService.lambdaQuery().eq(OrderInstall::getPgguid, item.getPgguid()).one();
|
|
|
+ if (oldrec.getAfterNumber().equals("S9219801") || oldrec.getAfterNumber().equals("S9219807")){
|
|
|
+ // 修改
|
|
|
+ oldrec.setOrderState(2);
|
|
|
+ oldrec.setAppointState(0);
|
|
|
+ orderInstallService.updateById(oldrec);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 总部下来的关闭工单要修改最后更新时间,否则不会产生结算完工数据
|
|
|
+ // 采集明细 有历史单再处理
|
|
|
+ if (item.getDqjd().equals(1309)){
|
|
|
+ List<OrderInstallDetail> recs = orderInstallDetailService.lambdaQuery()
|
|
|
+ .eq(OrderInstallDetail::getWorkerOrderNo, workerOrderNo)
|
|
|
+ .eq(OrderInstallDetail::getStatus,1).list();
|
|
|
+ if (recs.size()>0 && recs.size()== orderItem.getMachineNum()){
|
|
|
+ orderItem.setOrderState(10);
|
|
|
+ orderItem.setAppointState(4);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private String getAzwdno (ItfTblAzAssignLcLsDownload item){
|
|
|
+ String azwdno ="";
|
|
|
+ if (BeanUtil.isNotEmpty(item.getAzwdno())){
|
|
|
+ azwdno = item.getAzwdno();
|
|
|
+ }
|
|
|
+ if (StringUtils.isEmpty(azwdno) || azwdno.equals("S9219801") || azwdno.equals("S9219807")){
|
|
|
+ azwdno = item.getJspgwdno();
|
|
|
+ }
|
|
|
+
|
|
|
+ return azwdno;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void getOrderInstallLog(ItfTblAzAssignLcLsDownload item, OrderInstall rec, OrderInstallOperatingLog recLog) {
|
|
|
+ if (item.getShopno().equals("88888888")){
|
|
|
+ recLog = new OrderInstallOperatingLog();
|
|
|
+
|
|
|
+ recLog.setBelongCompanyId(rec.getBelongCompanyId());
|
|
|
+ recLog.setBelongCompany(rec.getBelongCompany());
|
|
|
+ recLog.setWebsitNumber(rec.getSalesNumber());
|
|
|
+ recLog.setWorkerOrderNo(rec.getWorkerOrderNo());
|
|
|
+ recLog.setBeforeOrderState(0);
|
|
|
+ recLog.setBeforeAppointState(0);
|
|
|
+ recLog.setOrderState(0);
|
|
|
+ recLog.setAppointState(0);
|
|
|
+ recLog.setType("创建工单");
|
|
|
+ recLog.setContent("[GF](家用空调)分销商城新增工单,操作网点:"+ rec.getSalesNumber());
|
|
|
+ recLog.setFeedback("保存");
|
|
|
+ recLog.setOperator(rec.getSalesWname());
|
|
|
+ recLog.setOperateWebsit(rec.getSalesNumber());
|
|
|
+ recLog.setStatus("1");
|
|
|
+ recLog.setCreatetime(new Date());
|
|
|
+ recLog.setUpdatetime(new Date());
|
|
|
+ recLog.setPgguid(rec.getPgguid());
|
|
|
+ recLog.setPgid(rec.getPgid());
|
|
|
+ recLog.setDataSource("2");
|
|
|
+ recLog.setUploadNotifyFlag(1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private boolean getupdateStatus(Boolean flag, ItfTblAzAssignLcLsDownload item, OrderInstall oldOrder, Integer orderState) {
|
|
|
+ Boolean orderf = getOrderStatFlag(oldOrder, orderState, item);
|
|
|
+
|
|
|
+ if (orderf && item.getLastModifiedDate().compareTo(oldOrder.getUpdatetime())>0){
|
|
|
+ oldOrder.setLastOrderState(getState(item.getSyjd()));
|
|
|
+ oldOrder.setLastAppointState(getAState(item.getSyjd()));
|
|
|
+
|
|
|
+ if (getOrderUpdatef(orderState, item.getDqjd())){
|
|
|
+ oldOrder.setOrderState(getState(item.getDqjd()));
|
|
|
+ }
|
|
|
+ if (!item.getDqjd().equals(1301)){
|
|
|
+ oldOrder.setAppointState(getAState(item.getDqjd()));
|
|
|
+ }
|
|
|
+
|
|
|
+ flag = Boolean.TRUE;
|
|
|
+ }
|
|
|
+
|
|
|
+ return flag;
|
|
|
+ }
|
|
|
+
|
|
|
+ private Boolean getOrderUpdatef(Integer orderState, Long dqjd){
|
|
|
+ Boolean f = Boolean.FALSE;
|
|
|
+ if (orderState>4 && (dqjd.equals(1304) || dqjd.equals(1306) || dqjd.equals(1307)
|
|
|
+ || dqjd.equals(1308) || dqjd.equals(1309) || dqjd.equals(1135))){
|
|
|
+ f = Boolean.TRUE;
|
|
|
+ }
|
|
|
+ if (orderState.equals(5) && dqjd.equals(1301)){
|
|
|
+ f = Boolean.TRUE;
|
|
|
+ }
|
|
|
+ if (orderState <=4 ){
|
|
|
+ f = Boolean.TRUE;
|
|
|
+ }
|
|
|
+ if (orderState.equals(9) && (dqjd.equals(1121) || dqjd.equals(1125) || dqjd.equals(1129))){
|
|
|
+ f = Boolean.TRUE;
|
|
|
+ }
|
|
|
+ return f;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 工单状态:1=已保存工单,2=待分部派工,3=待分中心派工,4=待网点派工,5=待审批改派,6=待服务人员处理,7=服务人员报完工,8=申请售后处理,9=已作废工单,10=已关闭工单,99=非广佛作废
|
|
|
+ private Integer getState(Long i){
|
|
|
+ Integer outf = 1;
|
|
|
+ if (i.equals(1100)){
|
|
|
+ outf = 1;
|
|
|
+ } else if (i.equals(1101)){
|
|
|
+ outf = 1;
|
|
|
+ } else if (i.equals(1121)){
|
|
|
+ outf = 2;
|
|
|
+ } else if (i.equals(1122)){
|
|
|
+ outf = 2;
|
|
|
+ } else if (i.equals(1125)){
|
|
|
+ outf = 3;
|
|
|
+ } else if (i.equals(1129)){
|
|
|
+ outf = 4;
|
|
|
+ } else if (i.equals(1130)){
|
|
|
+ outf = 4;
|
|
|
+ } else if (i.equals(1135)){
|
|
|
+ outf = 5;
|
|
|
+ } else if (i.equals(1301)){
|
|
|
+ outf = 6;
|
|
|
+ } else if (i.equals(1304)){
|
|
|
+ outf = 7;
|
|
|
+ } else if (i.equals(1307)){
|
|
|
+ outf = 8;
|
|
|
+ } else if (i.equals(1308)){
|
|
|
+ outf = 9;
|
|
|
+ } else if (i.equals(1309)){
|
|
|
+ outf = 10;
|
|
|
+ }
|
|
|
+ return outf;
|
|
|
+ }
|
|
|
+
|
|
|
+ private Integer getAState(Long i){
|
|
|
+ Integer outf = 0;
|
|
|
+ if (i.equals(1100) || i.equals(1101) || i.equals(1121) || i.equals(1122) || i.equals(1125)
|
|
|
+ || i.equals(1129) || i.equals(1130) || i.equals(1135) || i.equals(1301)
|
|
|
+ || i.equals(1307) || i.equals(1308)){
|
|
|
+ outf = 0;
|
|
|
+ } else if (i.equals(1304) || i.equals(1309)){
|
|
|
+ outf = 4;
|
|
|
+ }
|
|
|
+
|
|
|
+ return outf;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ // 判断广州本地的安装工单的状态是否允许更新
|
|
|
+ private Boolean getOrderStatFlag(OrderInstall oldOrder, Integer orderState, ItfTblAzAssignLcLsDownload item){
|
|
|
+ Boolean orderf = Boolean.FALSE;
|
|
|
+ Integer curAppointState = oldOrder.getAppointState();
|
|
|
+
|
|
|
+ if (orderState.equals(1) || orderState.equals(2) || orderState.equals(3)){
|
|
|
+ curAppointState = 0;
|
|
|
+ } else {
|
|
|
+ orderf = Boolean.TRUE;
|
|
|
+ }
|
|
|
+ if (orderState.equals(3) && curAppointState.equals(0)
|
|
|
+ && (item.getDqjd().equals(1125) || item.getDqjd().equals(1129) || item.getDqjd().equals(1301))){
|
|
|
+ orderf = Boolean.TRUE;
|
|
|
+ }
|
|
|
+ if (orderState.equals(4) && curAppointState.equals(0)
|
|
|
+ && (item.getDqjd().equals(1304) || item.getDqjd().equals(1306)
|
|
|
+ || item.getDqjd().equals(1307) || item.getDqjd().equals(1308) || item.getDqjd().equals(1309))){
|
|
|
+ orderf = Boolean.TRUE;
|
|
|
+ }
|
|
|
+ if (orderState.equals(6)
|
|
|
+ && (curAppointState.equals(0) || curAppointState.equals(1)
|
|
|
+ || curAppointState.equals(2) || curAppointState.equals(3))
|
|
|
+ && (item.getDqjd().equals(1304) || item.getDqjd().equals(1306)
|
|
|
+ || item.getDqjd().equals(1307) || item.getDqjd().equals(1308) || item.getDqjd().equals(1309))){
|
|
|
+ orderf = Boolean.TRUE;
|
|
|
+ }
|
|
|
+ if (orderState.equals(7) && curAppointState.equals(4)
|
|
|
+ && (item.getDqjd().equals(1307) || item.getDqjd().equals(1308) || item.getDqjd().equals(1309))){
|
|
|
+ orderf = Boolean.TRUE;
|
|
|
+ }
|
|
|
+ if (orderState.equals(5) && curAppointState.equals(5)
|
|
|
+ && (item.getDqjd().equals(1307) || item.getDqjd().equals(1308) || item.getDqjd().equals(1309))){
|
|
|
+ orderf = Boolean.TRUE;
|
|
|
+ }
|
|
|
+ if (orderState.equals(2) && curAppointState.equals(2)
|
|
|
+ && (item.getDqjd().equals(1125) || item.getDqjd().equals(1129)
|
|
|
+ || item.getDqjd().equals(1301) || item.getDqjd().equals(1308))){
|
|
|
+ orderf = Boolean.TRUE;
|
|
|
+ }
|
|
|
+ if (orderState.equals(9) || orderState.equals(10)|| orderState.equals(99)){
|
|
|
+ if (item.getDqjd().equals(1121) || item.getDqjd().equals(1125) || item.getDqjd().equals(1129)){
|
|
|
+ orderf = Boolean.TRUE;
|
|
|
+ } else {
|
|
|
+ orderf = Boolean.FALSE;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ orderf = Boolean.TRUE;
|
|
|
+ }
|
|
|
+ if (orderState.equals(6) && curAppointState.equals(2)
|
|
|
+ && (item.getDqjd().equals(1121) || item.getDqjd().equals(1125) || item.getDqjd().equals(1301))){
|
|
|
+ orderf = Boolean.FALSE;
|
|
|
+ }
|
|
|
+
|
|
|
+ return orderf;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ private Boolean getUpdateOrderYYSJ(Boolean flag, ItfTblAzAssignLcLsDownload item, OrderInstall oldOrder, Date reservebegin) {
|
|
|
+ Integer isReserve =-1;
|
|
|
+ Date yysj = new Date();
|
|
|
+ Date orderReservebegin = new Date();
|
|
|
+ Date orderReserveEnd = new Date();
|
|
|
+
|
|
|
+ if (BeanUtil.isNotEmpty(oldOrder.getIsReserve())){
|
|
|
+ isReserve=oldOrder.getIsReserve();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 预约时间(优先以预约安装时间为准,不存在时取用户期望上门开始时间)
|
|
|
+ if (StringUtils.isEmpty(item.getYyazsj())){
|
|
|
+ yysj = item.getYhqwkssj();
|
|
|
+ orderReservebegin = item.getYhqwkssj();
|
|
|
+ orderReserveEnd = item.getYhqwjssj();
|
|
|
+ } else {
|
|
|
+ yysj = item.getYyazsj();
|
|
|
+ orderReservebegin = item.getYyazsj();
|
|
|
+ orderReserveEnd = item.getYyazsj();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 已做用户预约不能更新 (0=未预约,1=已预约)
|
|
|
+ if (isReserve.equals(0)){
|
|
|
+ if (BeanUtil.isNotEmpty(item.getYyazsj())){
|
|
|
+ oldOrder.setReserveDatetime(item.getYyazsj());
|
|
|
+ }
|
|
|
+ oldOrder.setReservePeriod(MyBeanUtils.getDateXS(yysj));
|
|
|
+ oldOrder.setReserveBegin(orderReservebegin);
|
|
|
+ oldOrder.setReserveEnd(orderReserveEnd);
|
|
|
+ flag = Boolean.TRUE;
|
|
|
+ }
|
|
|
+ // 天猫工单,允许天猫自已预约
|
|
|
+ if (BeanUtil.isNotEmpty(item.getYyazsj()) && item.getQqlymc().equals("TBL_TMALL_ORDERINFO")
|
|
|
+ && reservebegin.compareTo(orderReservebegin) !=0 ){
|
|
|
+ oldOrder.setIsReserve(1);
|
|
|
+ if (BeanUtil.isNotEmpty(item.getYyazsj())){
|
|
|
+ oldOrder.setReserveDatetime(item.getYyazsj());
|
|
|
+ }
|
|
|
+ oldOrder.setReservePeriod(MyBeanUtils.getDateXS(yysj));
|
|
|
+ oldOrder.setReserveBegin(orderReservebegin);
|
|
|
+ oldOrder.setReserveEnd(orderReserveEnd);
|
|
|
+ flag = Boolean.TRUE;
|
|
|
+ }
|
|
|
+ return flag;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private Boolean updateOldOrderWD(Integer orderState, ItfTblAzAssignLcLsDownload item, OrderInstall oldOrder) {
|
|
|
+ // 需排除个例(如果广佛已待服务人员处理,不允更新网点)
|
|
|
+ if (!(orderState.equals(6) || orderState.equals(7) || orderState.equals(10))){
|
|
|
+ oldOrder.setAfterNumber(item.getJspgwdno());
|
|
|
+ oldOrder.setAfterWname(item.getJspgwdmc());
|
|
|
+ oldOrder.setAfterXtbh(item.getJspgwdxtbh());
|
|
|
+ oldOrder.setInstallNumber(item.getAzwdno());
|
|
|
+ oldOrder.setInstallName(item.getAzwdmc());
|
|
|
+ oldOrder.setInstallXtbh(item.getAzwdxtbh());
|
|
|
+ return Boolean.TRUE;
|
|
|
+ }
|
|
|
+
|
|
|
+ return Boolean.FALSE;
|
|
|
+ }
|
|
|
+
|
|
|
+ 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());
|
|
|
+ oldOrder.setUserPhone("");
|
|
|
+ if (StringUtils.isEmpty(item.getYddh())){
|
|
|
+ if (StringUtils.isEmpty(item.getYddh2())){
|
|
|
+ oldOrder.setUserPhone(item.getYddh2());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ oldOrder.setUserPhone(item.getYddh());
|
|
|
+ }
|
|
|
+ oldOrder.setUserPhone2("");
|
|
|
+ if (BeanUtil.isNotEmpty(item.getYddh2())){
|
|
|
+ oldOrder.setUserPhone2(item.getYddh2());
|
|
|
+ }
|
|
|
+ oldOrder.setUserName("");
|
|
|
+ if (BeanUtil.isNotEmpty(item.getYhmc())){
|
|
|
+ oldOrder.setUserName(item.getYhmc());
|
|
|
+ }
|
|
|
+ oldOrder.setUserContact("");
|
|
|
+ if (BeanUtil.isNotEmpty(item.getLxren())){
|
|
|
+ oldOrder.setUserContact(item.getLxren());
|
|
|
+ }
|
|
|
+ oldOrder.setAreacode("");
|
|
|
+ if (BeanUtil.isNotEmpty(item.getQuhao())){
|
|
|
+ oldOrder.setAreacode(item.getQuhao());
|
|
|
+ }
|
|
|
+ oldOrder.setContactPhone("");
|
|
|
+ if (BeanUtil.isNotEmpty(item.getDhhm())){
|
|
|
+ oldOrder.setContactPhone(item.getDhhm());
|
|
|
+ }
|
|
|
+ oldOrder.setGreeVirtualnumber("");
|
|
|
+ if (BeanUtil.isNotEmpty(item.getFjhm())){
|
|
|
+ oldOrder.setGreeVirtualnumber(item.getFjhm());
|
|
|
+ }
|
|
|
+ oldOrder.setGreeVirtualnumber("");
|
|
|
+ if (BeanUtil.isNotEmpty(item.getFjhm())){
|
|
|
+ oldOrder.setGreeVirtualnumber(item.getFjhm());
|
|
|
+ }
|
|
|
+ /// 再添加成员变量
|
|
|
+ oldOrder.setSalesTypeId(Integer.valueOf(sxlxid.toString()));
|
|
|
+
|
|
|
+ return Boolean.TRUE;
|
|
|
+ }
|
|
|
+
|
|
|
+ return Boolean.FALSE;
|
|
|
+ }
|
|
|
+
|
|
|
+ private Long getxslxid(ItfTblAzAssignLcLsDownload item) {
|
|
|
+ Long sxlxid = 1l;
|
|
|
+ if (StringUtils.isEmpty(item.getXslxid()) || item.getXslxid() == 0) {
|
|
|
+ SalesType rec = salesTypeService.lambdaQuery().eq(SalesType::getXslxmc, item.getXslx()).one();
|
|
|
+ if (rec != null) {
|
|
|
+ sxlxid = rec.getXslxid();
|
|
|
+ } else {
|
|
|
+ sxlxid = 1l;
|
|
|
+ }
|
|
|
+ if (sxlxid == 0 || StringUtils.isEmpty(sxlxid)) {
|
|
|
+ sxlxid = 1l;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ sxlxid = item.getXslxid();
|
|
|
+ }
|
|
|
+ return sxlxid;
|
|
|
+ }
|
|
|
+
|
|
|
+ @NotNull
|
|
|
+ private OrderInstall getOrderInstall(ItfTblAzAssignLcLsDownload item,Long sxlxid) {
|
|
|
+ OrderInstall rec = new OrderInstall();
|
|
|
+ String workerOrderNo = UUID.randomUUID().toString();
|
|
|
+
|
|
|
+ // shopno: 销售网点编号 88888888为分销商城特殊单号 todo
|
|
|
+ if (item.getShopno().equals("88888888")){
|
|
|
+ ItfFxInstallReq itfFxInstallReq = itfFxInstallReqService.lambdaQuery().eq(ItfFxInstallReq::getPgguid,item.getPgguid()).one();
|
|
|
+ if (itfFxInstallReq ==null || StringUtils.isEmpty(itfFxInstallReq.getWorkerOrderNo())){
|
|
|
+ log.info("分销商城订单生成失败,工单号为空:{}",item.getPgguid());
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ workerOrderNo = itfFxInstallReq.getWorkerOrderNo();
|
|
|
+ }
|
|
|
+
|
|
|
+ rec.setWorkerOrderNo(workerOrderNo);
|
|
|
+ rec.setUploadNotifyFlag(0);
|
|
|
+ rec.setLastUpdSynReqId(String.valueOf(item.getSynReqId()));
|
|
|
+ rec.setLastUpdSynTime(new Date());
|
|
|
+ // 所属公司编号Id belongCompanyId,belongCompany
|
|
|
+ getBelongCompany(item, rec);
|
|
|
+ // 销售网点id
|
|
|
+ setSalesWid(item, rec);
|
|
|
+
|
|
|
+ if (BeanUtil.isNotEmpty(item.getXsdwno())){
|
|
|
+ rec.setSalesNumber(item.getXsdwno());
|
|
|
+ }
|
|
|
+ if (BeanUtil.isNotEmpty(item.getXswdmc())){
|
|
|
+ rec.setSalesWname(item.getXswdmc());
|
|
|
+ }
|
|
|
+ if (BeanUtil.isNotEmpty(item.getXsdwxtbh())){
|
|
|
+ rec.setSalesXtbh(item.getXsdwxtbh());
|
|
|
+ }
|
|
|
+ // 接收派工网点id
|
|
|
+ setAfterWid(item, rec);
|
|
|
+ if (BeanUtil.isNotEmpty(item.getJspgwdno())){
|
|
|
+ rec.setAfterNumber(item.getJspgwdno());
|
|
|
+ }
|
|
|
+ if (BeanUtil.isNotEmpty(item.getJspgwdmc())){
|
|
|
+ rec.setAfterWname(item.getJspgwdmc());
|
|
|
+ }
|
|
|
+ if (BeanUtil.isNotEmpty(item.getJspgwdxtbh())){
|
|
|
+ rec.setAfterXtbh(item.getJspgwdxtbh());
|
|
|
+ }
|
|
|
+
|
|
|
+ rec.setAfterTime(item.getJspgwdsj());
|
|
|
+ // 创建工单的网点
|
|
|
+ setCreateWid(item, rec);
|
|
|
+
|
|
|
+ rec.setCreatedUserNumber(item.getCjren());
|
|
|
+ rec.setCreatedRealName(item.getCjrmc());
|
|
|
+ rec.setSalesOrderNo(item.getXsdh());
|
|
|
+ rec.setUserPhone(item.getYddh());
|
|
|
+ rec.setUserName(item.getYhmc());
|
|
|
+ rec.setMachineNum(item.getAzsl());
|
|
|
+ rec.setPgguid(item.getPgguid());
|
|
|
+ rec.setPgid(item.getPgid());
|
|
|
+
|
|
|
+ rec.setIsReservation("0");
|
|
|
+ if (item.getDqjd().equals(1100) || item.getDqjd().equals(1122) || item.getDqjd().equals(1130)){
|
|
|
+ rec.setIsReservation("1");
|
|
|
+ }
|
|
|
+
|
|
|
+ rec.setAfterNumber("");
|
|
|
+ if (!StringUtils.isEmpty(item.getJspgwdno())){
|
|
|
+ rec.setAfterNumber(item.getJspgwdno());
|
|
|
+ }
|
|
|
+
|
|
|
+ rec.setOrderState(getDqjd(item));
|
|
|
+ rec.setAppointState(getDqjd(item));
|
|
|
+ if (StringUtils.isEmpty(item.getYhsxid())){
|
|
|
+ rec.setUserTypeId(1);
|
|
|
+ } else {
|
|
|
+ if (item.getYhsxid().equals(0L)){
|
|
|
+ rec.setUserTypeId(1);
|
|
|
+ } else {
|
|
|
+ rec.setUserTypeId(Integer.valueOf(item.getYhsxid().toString()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ // 增加参数 todo
|
|
|
+ rec.setSalesTypeId(Integer.valueOf(sxlxid.toString()));
|
|
|
+
|
|
|
+
|
|
|
+ // 接收派工网点是否为中心,且下传的当前节点是不是1129或1301,如果是就更新为2待分部派工
|
|
|
+ if ((item.getJspgwdno().equals("S9219801") || item.getJspgwdno().equals("S9219807"))
|
|
|
+ && (item.getDqjd().equals(1129) || item.getDqjd().equals(1301))){
|
|
|
+ rec.setOrderState(2);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ return rec;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setCreateWid(ItfTblAzAssignLcLsDownload item, OrderInstall rec) {
|
|
|
+ QueryWrapper<BrandWebsit> paytypeServiceQueryWrapper = new QueryWrapper<BrandWebsit>()
|
|
|
+ .select("brand_websit_id")
|
|
|
+ .eq("brand_websit_number", item.getCjwdno())
|
|
|
+ .and(v -> v.eq("type",InterFaceTypeEnum.XS_WEBSIT_TYPE.getCode())
|
|
|
+ .or()
|
|
|
+ .eq("type", InterFaceTypeEnum.SH_WEBSIT_TYPE.getCode())
|
|
|
+ .ne("brand_websit_number", "99999999"));
|
|
|
+ List<BrandWebsit> brandWebsits = brandWebsitService.list(paytypeServiceQueryWrapper);
|
|
|
+ if (brandWebsits !=null || brandWebsits.size()>0){
|
|
|
+ if (BeanUtil.isNotEmpty(brandWebsits.get(0).getBrandWebsitId())){
|
|
|
+ rec.setCreateWid(brandWebsits.get(0).getBrandWebsitId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setAfterWid(ItfTblAzAssignLcLsDownload item, OrderInstall rec) {
|
|
|
+ BrandWebsit oldWebsitRec = brandWebsitService.lambdaQuery()
|
|
|
+ .eq(BrandWebsit::getBrandWebsitNumber, item.getJspgwdno()).one();
|
|
|
+ if (oldWebsitRec !=null){
|
|
|
+ if (BeanUtil.isNotEmpty(oldWebsitRec.getBrandWebsitId())){
|
|
|
+ rec.setAfterWid(oldWebsitRec.getBrandWebsitId());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setSalesWid(ItfTblAzAssignLcLsDownload item, OrderInstall rec) {
|
|
|
+ BrandWebsit oldWebsitRec = brandWebsitService.lambdaQuery()
|
|
|
+ .eq(BrandWebsit::getBrandWebsitNumber, item.getXsdwno())
|
|
|
+ .eq(BrandWebsit::getType, InterFaceTypeEnum.XS_WEBSIT_TYPE.getCode())
|
|
|
+ .one();
|
|
|
+ if (oldWebsitRec !=null){
|
|
|
+ if (BeanUtil.isNotEmpty(oldWebsitRec.getBrandWebsitId())){
|
|
|
+ rec.setSalesWid(oldWebsitRec.getBrandWebsitId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void getBelongCompany(ItfTblAzAssignLcLsDownload item, OrderInstall rec) {
|
|
|
+ BrandWebsit oldWebsitRec = brandWebsitService.lambdaQuery()
|
|
|
+ .eq(BrandWebsit::getBrandWebsitNumber, item.getJspgwdno()).one();
|
|
|
+ if (oldWebsitRec !=null){
|
|
|
+ if (BeanUtil.isNotEmpty(oldWebsitRec.getBelongCompanyId())){
|
|
|
+ rec.setBelongCompanyId(oldWebsitRec.getBelongCompanyId());
|
|
|
+ }
|
|
|
+ if (BeanUtil.isNotEmpty(oldWebsitRec.getBelongCompany())){
|
|
|
+ rec.setBelongCompany(oldWebsitRec.getBelongCompany());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ rec.setBelongCompanyId(0);
|
|
|
+ rec.setBelongCompany("0");
|
|
|
+ }
|
|
|
+ }*/
|
|
|
+
|
|
|
+ @NotNull
|
|
|
+ private Integer getDqjd(ItfTblAzAssignLcLsDownload item) {
|
|
|
+ Integer dqjd;
|
|
|
+ if (item.getDqjd() == 1100) {
|
|
|
+ dqjd = 1;
|
|
|
+ } else if (item.getDqjd() == 1101) {
|
|
|
+ dqjd = 1;
|
|
|
+ } else if (item.getDqjd() == 1121) {
|
|
|
+ dqjd = 2;
|
|
|
+ } else if (item.getDqjd() == 1122) {
|
|
|
+ dqjd = 2;
|
|
|
+ } else if (item.getDqjd() == 1125) {
|
|
|
+ dqjd = 3;
|
|
|
+ } else if (item.getDqjd() == 1129) {
|
|
|
+ dqjd = 4;
|
|
|
+ } else if (item.getDqjd() == 1130) {
|
|
|
+ dqjd = 4;
|
|
|
+ } else if (item.getDqjd() == 1135) {
|
|
|
+ dqjd = 5;
|
|
|
+ } else if (item.getDqjd() == 1301) {
|
|
|
+ dqjd = 6;
|
|
|
+ } else if (item.getDqjd() == 1304) {
|
|
|
+ dqjd = 7;
|
|
|
+ } else if (item.getDqjd() == 1306) {
|
|
|
+ dqjd = 7;
|
|
|
+ } else if (item.getDqjd() == 1307) {
|
|
|
+ dqjd = 8;
|
|
|
+ } else if (item.getDqjd() == 1308) {
|
|
|
+ dqjd = 9;
|
|
|
+ } else if (item.getDqjd() == 1309) {
|
|
|
+ dqjd = 10;
|
|
|
+ } else {
|
|
|
+ dqjd = 1;
|
|
|
+ }
|
|
|
+ return dqjd;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // 与总部进行状态同步下次获取时不再拉取数据
|
|
|
+ private void updateStatus() {
|
|
|
+ try {
|
|
|
+ List<ItfInstallBatchDownloadRec> recs = new ArrayList<>();
|
|
|
+ // greeStatSynStatus:总部同步标志是否已成功更新 0=否 1=是 99=其他
|
|
|
+ recs = itfInstallBatchDownloadRecService.lambdaQuery()
|
|
|
+ .eq(ItfInstallBatchDownloadRec::getGreeStatSynStatus,0)
|
|
|
+ .or()
|
|
|
+ .eq(ItfInstallBatchDownloadRec::getGreeStatSynStatus,99)
|
|
|
+ .le(ItfInstallBatchDownloadRec::getSynTimes,5)
|
|
|
+ .list();
|
|
|
+ if (recs.size()>0){
|
|
|
+ log.info("需要与总部同步安装工单下载状态记录数: {}",recs.size());
|
|
|
+ Token token = tokenCenter.getCurrentToken();
|
|
|
+ String url = baseurl + "tblAzAssignLcLs" + "/updateExtendfiled5";
|
|
|
+ for (ItfInstallBatchDownloadRec item :recs){
|
|
|
+ log.info("与总部同步下装状态的派工单号: {}",item.getPgid());
|
|
|
+ String pgguid = item.getPgguid();
|
|
|
+ Date lastModifiedDate = item.getLastModifiedDate();
|
|
|
+ Map<String, Object> paramMap = new HashMap<String, Object>();
|
|
|
+ paramMap.put("pgguid", pgguid);
|
|
|
+ paramMap.put("lastModifiedDate", lastModifiedDate);
|
|
|
+ JSONResult jsonResult = HttpUtil.httpRequestWithToken(url, "POST",
|
|
|
+ JSON.toJSONStringWithDateFormat(paramMap, "yyyy-MM-dd HH:mm:ss"), token);
|
|
|
+ // 与总部进行状态同步
|
|
|
+ syncStatus(item, jsonResult);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ log.info("与总部同步安装工单下载状态完成");
|
|
|
+ } catch (Exception ex) {
|
|
|
+ log.error("与总部同步更新安装工单下载状态失败", ex);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void syncStatus(ItfInstallBatchDownloadRec item, JSONResult jsonResult) {
|
|
|
+ ItfInstallBatchDownloadRec update = new ItfInstallBatchDownloadRec();
|
|
|
+ update.setSynReqId(item.getSynReqId());
|
|
|
+ update.setGreeStatSynTime(new Date());
|
|
|
+ update.setSynTimes(item.getSynTimes()+1);
|
|
|
+
|
|
|
+ if (jsonResult.isOK()) {
|
|
|
+ update.setGreeStatSynStatus(1);
|
|
|
+ } else {
|
|
|
+ update.setGreeStatSynStatus(99);
|
|
|
+ update.setGreeStatSynErrMsg(jsonResult.getMsg());
|
|
|
+ }
|
|
|
+ itfInstallBatchDownloadRecService.updateById(update);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void downloadAdd(List<ItfInstallBatchDownloadRec> rec, List<ItfTblAzAssignLcLsDownload> lcls, List<ItfTblAzAssignMxDownload> mx, List<ItfTblAzAssignFkmxDownload> fk, List<ItfTblAzAssignFeeDownload> fe, List<ItfTblAzAssignAppointmentDownload> app, List<ItfTblAzAssignLcFzryDownload> fz, List<ItfTblAzAssignSatisfactionDownload> sa, List<ItfTblAzAssignPlatformDownload> pla) {
|
|
|
+ if (rec.size()>0){
|
|
|
+ itfInstallBatchDownloadRecService.saveBatch(rec);
|
|
|
+ }
|
|
|
+ if (lcls.size()>0){
|
|
|
+ itfTblAzAssignLcLsDownloadService.saveBatch(lcls);
|
|
|
+ }
|
|
|
+ if (mx.size()>0){
|
|
|
+ itfTblAzAssignMxDownloadService.saveBatch(mx);
|
|
|
+ }
|
|
|
+ if (fk.size()>0){
|
|
|
+ itfTblAzAssignFkMxDownloadService.saveBatch(fk);
|
|
|
+ }
|
|
|
+ if (fe.size()>0){
|
|
|
+ itfTblAzAssignFeeDownloadService.saveBatch(fe);
|
|
|
+ }
|
|
|
+ if (app.size()>0){
|
|
|
+ itfTblAzAssignAppointmentDownloadService.saveBatch(app);
|
|
|
+ }
|
|
|
+ if (fz.size()>0){
|
|
|
+ itfTblAzAssignLcFzryDownloadService.saveBatch(fz);
|
|
|
+ }
|
|
|
+ if (sa.size()>0){
|
|
|
+ itfTblAzAssignSatisfactionDownloadService.saveBatch(sa);
|
|
|
+ }
|
|
|
+ if (pla.size()>0){
|
|
|
+ itfTblAzAssignPlatformDownloadService.saveBatch(pla);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void putLogInfo(JSONArray datas) {
|
|
|
+ StringBuffer str = new StringBuffer();
|
|
|
+ str.append("安装工单下载数据日志销售单号-派工单号:【");
|
|
|
+ for (int i = 0; i < datas.size(); i++) {
|
|
|
+ JSONObject sheet = datas.getJSONObject(i);
|
|
|
+ // 提取主表数据
|
|
|
+ JSONArray mainTableData = sheet.getJSONArray("TBL_AZ_ASSIGN_LC_LS");
|
|
|
+ if (mainTableData != null && mainTableData.size() > 0) {
|
|
|
+ JSONArray tableData = new JSONArray();
|
|
|
+ tableData = sheet.getJSONArray(ESInstallEnum.TBL_AZ_ASSIGN_LC_LS.getCode());
|
|
|
+ for (int j = 0; j < tableData.size(); j++) {
|
|
|
+ // 生成安装工单主表对象
|
|
|
+ ItfTblAzAssignLcLsDownload item = JSON.toJavaObject(tableData.getJSONObject(j),ItfTblAzAssignLcLsDownload.class);
|
|
|
+ str.append("("+item.getXsdh()+"-"+ item.getPgid()+")");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ str.append("】");
|
|
|
+ log.info(str.toString());
|
|
|
+ }
|
|
|
+
|
|
|
+ public void parseData(JSONObject sheet, String downloadTaskNo, String downloadBatchNo, List<ItfInstallBatchDownloadRec> rec) throws Exception {
|
|
|
+ List<ItfTblAzAssignLcLsDownload> lcls = new ArrayList<>();
|
|
|
+ List<ItfTblAzAssignMxDownload> mx = new ArrayList<>();
|
|
|
+ List<ItfTblAzAssignFkmxDownload> fk = new ArrayList<>();
|
|
|
+ List<ItfTblAzAssignFeeDownload> fe = new ArrayList<>();
|
|
|
+ List<ItfTblAzAssignAppointmentDownload> app = new ArrayList<>();
|
|
|
+ List<ItfTblAzAssignLcFzryDownload> fz = new ArrayList<>();
|
|
|
+ List<ItfTblAzAssignSatisfactionDownload> sa = new ArrayList<>();
|
|
|
+ List<ItfTblAzAssignPlatformDownload> pla = new ArrayList<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+ // 获取报文对应数据信息
|
|
|
+ getDataInfo(sheet, downloadTaskNo, downloadBatchNo, lcls, mx, fk, fe, app, fz, sa, pla);
|
|
|
+
|
|
|
+ // 打印预落表安装工单信息方便查询出错的订单信息
|
|
|
+ logAZGDInfo(lcls);
|
|
|
+
|
|
|
+ // 数据同步落到同步信息表 事务处理
|
|
|
+ downloadAdd(rec, lcls, mx, fk, fe, app, fz, sa, pla);
|
|
|
+
|
|
|
+ log.info("落表成功");
|
|
|
+
|
|
|
+ } catch (Exception ex) {
|
|
|
+ log.error("安装工单落表失败:{}", ex);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void logAZGDInfo(List<ItfTblAzAssignLcLsDownload> lcls) {
|
|
|
+ StringBuffer str = new StringBuffer();
|
|
|
+ str.append("预落表安装工单信息销售单号-派工单号:【");
|
|
|
+ if (lcls.size()>0){
|
|
|
+ for (ItfTblAzAssignLcLsDownload item : lcls){
|
|
|
+ str.append("("+item.getXsdh()+"-"+ item.getPgid()+")");
|
|
|
+ }
|
|
|
+ str.append("】");
|
|
|
+ log.info(str.toString());
|
|
|
+
|
|
|
+ for (ItfTblAzAssignLcLsDownload item : lcls){
|
|
|
+ log.info("item: {}",item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void getDataInfo(JSONObject sheet, String downloadTaskNo, String downloadBatchNo, List<ItfTblAzAssignLcLsDownload> lcls, List<ItfTblAzAssignMxDownload> mx, List<ItfTblAzAssignFkmxDownload> fk, List<ItfTblAzAssignFeeDownload> fe, List<ItfTblAzAssignAppointmentDownload> app, List<ItfTblAzAssignLcFzryDownload> fz, List<ItfTblAzAssignSatisfactionDownload> sa, List<ItfTblAzAssignPlatformDownload> pla) throws Exception {
|
|
|
+ JSONArray tableData = new JSONArray();
|
|
|
+ // 报文中提取安装工单主表数据 itf_tbl_az_assign_lc_ls_download
|
|
|
+ tableData = sheet.getJSONArray(ESInstallEnum.TBL_AZ_ASSIGN_LC_LS.getCode());
|
|
|
+ for (int j = 0; j < tableData.size(); j++) {
|
|
|
+ // 生成安装工单主表对象
|
|
|
+ parseTblAzAssignLcLsData(downloadBatchNo, downloadTaskNo, tableData.getJSONObject(j), lcls);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 安装工单明细表 itf_tbl_az_assign_lc_ls_download
|
|
|
+ tableData = sheet.getJSONArray(ESInstallEnum.TBL_AZ_ASSIGN_MX.getCode());
|
|
|
+ for (int j = 0; j < tableData.size(); j++) {
|
|
|
+ // 生成安装工单明细主表对象
|
|
|
+ parseTblAzAssignMxData(downloadBatchNo, downloadTaskNo, tableData.getJSONObject(j), mx);
|
|
|
+ }
|
|
|
+ // 安装反馈明细表 itf_tbl_az_assign_fkmx_download
|
|
|
+ tableData = sheet.getJSONArray(ESInstallEnum.TBL_AZ_ASSIGN_FKMX.getCode());
|
|
|
+ for (int j = 0; j < tableData.size(); j++) {
|
|
|
+ // 生成安装反馈明细表对象
|
|
|
+ parseTblAzAssignFkMXData(downloadBatchNo, downloadTaskNo, tableData.getJSONObject(j), fk);
|
|
|
+ }
|
|
|
+ // 安装费用清单表 itf_tbl_az_assign_fee_download
|
|
|
+ tableData = sheet.getJSONArray(ESInstallEnum.TBL_AZ_ASSIGN_FEE.getCode());
|
|
|
+ for (int j = 0; j < tableData.size(); j++) {
|
|
|
+ // 生成安装费用清单表对象
|
|
|
+ parseTblAzAssignFeeData(downloadBatchNo, downloadTaskNo, tableData.getJSONObject(j), fe);
|
|
|
+ }
|
|
|
+ // 用户预约改约表 itf_tbl_az_assign_appointment_download
|
|
|
+ tableData = sheet.getJSONArray(ESInstallEnum.TBL_AZ_ASSIGN_APPOINTMENT.getCode());
|
|
|
+ for (int j = 0; j < tableData.size(); j++) {
|
|
|
+ // 生成用户预约改约表对象
|
|
|
+ parseTblAzAssignAppointmentData(downloadBatchNo, downloadTaskNo, tableData.getJSONObject(j), app);
|
|
|
+ }
|
|
|
+ // 安装辅助人员表 itf_tbl_az_assign_lc_fzry_download
|
|
|
+ tableData = sheet.getJSONArray(ESInstallEnum.TBL_AZ_ASSIGN_LC_FZRY.getCode());
|
|
|
+ for (int j = 0; j < tableData.size(); j++) {
|
|
|
+ // 生成安装辅助人员表对象
|
|
|
+ parseTblAzAssignLcFzryData(downloadBatchNo, downloadTaskNo, tableData.getJSONObject(j), fz);
|
|
|
+ }
|
|
|
+ // 客户评价表 itf_tbl_az_assign_satisfaction_download
|
|
|
+ tableData = sheet.getJSONArray(ESInstallEnum.TBL_AZ_ASSIGN_SATISFACTION.getCode());
|
|
|
+ for (int j = 0; j < tableData.size(); j++) {
|
|
|
+ // 生成客户评价表对象
|
|
|
+ parseTblAzAssignSatisfactionData(downloadBatchNo, downloadTaskNo, tableData.getJSONObject(j) , sa);
|
|
|
+ }
|
|
|
+ // 第三方平台订单信息表 itf_tbl_az_assign_platform_download
|
|
|
+ tableData = sheet.getJSONArray(ESInstallEnum.TBL_AZ_ASSIGN_PLATFORM.getCode());
|
|
|
+ for (int j = 0; j < tableData.size(); j++) {
|
|
|
+ // 生成第三方平台订单信息表对象
|
|
|
+ parseTblAzAssignPlatformData(downloadBatchNo, downloadTaskNo, tableData.getJSONObject(j), pla);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // itf_tbl_az_assign_platform_download
|
|
|
+ private void parseTblAzAssignPlatformData(String downloadBatchNo, String downloadTaskNo, JSONObject aData,
|
|
|
+ List<ItfTblAzAssignPlatformDownload> pla) throws Exception {
|
|
|
+ ItfTblAzAssignPlatformDownload item = JSON.toJavaObject(aData,ItfTblAzAssignPlatformDownload.class);
|
|
|
+ item.setDownloadBatchNo(downloadBatchNo);
|
|
|
+ item.setDownloadTaskNo(downloadTaskNo);
|
|
|
+ pla.add(item);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ // itf_tbl_az_assign_satisfaction_download
|
|
|
+ private void parseTblAzAssignSatisfactionData(String downloadBatchNo, String downloadTaskNo, JSONObject aData ,
|
|
|
+ List<ItfTblAzAssignSatisfactionDownload> sa) throws Exception {
|
|
|
+ ItfTblAzAssignSatisfactionDownload item = JSON.toJavaObject(aData,ItfTblAzAssignSatisfactionDownload.class);
|
|
|
+ item.setDownloadBatchNo(downloadBatchNo);
|
|
|
+ item.setDownloadTaskNo(downloadTaskNo);
|
|
|
+ sa.add(item);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // itf_tbl_az_assign_lc_fzry_download
|
|
|
+ private void parseTblAzAssignLcFzryData(String downloadBatchNo, String downloadTaskNo, JSONObject aData,
|
|
|
+ List<ItfTblAzAssignLcFzryDownload> fz) throws Exception {
|
|
|
+ ItfTblAzAssignLcFzryDownload item = JSON.toJavaObject(aData,ItfTblAzAssignLcFzryDownload.class);
|
|
|
+ item.setDownloadBatchNo(downloadBatchNo);
|
|
|
+ item.setDownloadTaskNo(downloadTaskNo);
|
|
|
+ fz.add(item);
|
|
|
+ }
|
|
|
+
|
|
|
+ // itf_tbl_az_assign_appointment_download
|
|
|
+ private void parseTblAzAssignAppointmentData(String downloadBatchNo, String downloadTaskNo, JSONObject aData,
|
|
|
+ List<ItfTblAzAssignAppointmentDownload> app) throws Exception {
|
|
|
+ ItfTblAzAssignAppointmentDownload item = JSON.toJavaObject(aData,ItfTblAzAssignAppointmentDownload.class);
|
|
|
+ item.setDownloadBatchNo(downloadBatchNo);
|
|
|
+ item.setDownloadTaskNo(downloadTaskNo);
|
|
|
+ app.add(item);
|
|
|
+ }
|
|
|
+
|
|
|
+ // itf_tbl_az_assign_fkmx_download
|
|
|
+ private void parseTblAzAssignFeeData(String downloadBatchNo, String downloadTaskNo, JSONObject aData,
|
|
|
+ List<ItfTblAzAssignFeeDownload> fe) throws Exception {
|
|
|
+ ItfTblAzAssignFeeDownload item = JSON.toJavaObject(aData,ItfTblAzAssignFeeDownload.class);
|
|
|
+ item.setDownloadBatchNo(downloadBatchNo);
|
|
|
+ item.setDownloadTaskNo(downloadTaskNo);
|
|
|
+ fe.add(item);
|
|
|
+ }
|
|
|
+
|
|
|
+ // itf_tbl_az_assign_fkmx_download
|
|
|
+ private void parseTblAzAssignFkMXData(String downloadBatchNo, String downloadTaskNo, JSONObject aData,
|
|
|
+ List<ItfTblAzAssignFkmxDownload> fk) throws Exception {
|
|
|
+ ItfTblAzAssignFkmxDownload item = JSON.toJavaObject(aData,ItfTblAzAssignFkmxDownload.class);
|
|
|
+ item.setDownloadBatchNo(downloadBatchNo);
|
|
|
+ item.setDownloadTaskNo(downloadTaskNo);
|
|
|
+ fk.add(item);
|
|
|
+ }
|
|
|
+
|
|
|
+ // itf_tbl_az_assign_mx_download
|
|
|
+ private void parseTblAzAssignMxData(String downloadBatchNo, String downloadTaskNo, JSONObject aData,
|
|
|
+ List<ItfTblAzAssignMxDownload> mx) throws Exception {
|
|
|
+ ItfTblAzAssignMxDownload item = JSON.toJavaObject(aData,ItfTblAzAssignMxDownload.class);
|
|
|
+ item.setDownloadBatchNo(downloadBatchNo);
|
|
|
+ item.setDownloadTaskNo(downloadTaskNo);
|
|
|
+ mx.add(item);
|
|
|
+ }
|
|
|
+
|
|
|
+ // itf_tbl_az_assign_lc_ls_download
|
|
|
+ private void parseTblAzAssignLcLsData(String downloadBatchNo, String downloadTaskNo, JSONObject aData, List<ItfTblAzAssignLcLsDownload> lcls) throws Exception {
|
|
|
+ ItfTblAzAssignLcLsDownload item = JSON.toJavaObject(aData,ItfTblAzAssignLcLsDownload.class);
|
|
|
+ item.setDownloadBatchNo(downloadBatchNo);
|
|
|
+ item.setDownloadTaskNo(downloadTaskNo);
|
|
|
+ lcls.add(item);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查看下载记录表有无数据
|
|
|
+ * 无数据,插入一条记录
|
|
|
+ * 有数据
|
|
|
+ * 还未做处理时不做插入动作 总部同步标志是否已成功更新 0=否
|
|
|
+ * 其他插一条数据,做单独说明
|
|
|
+ */
|
|
|
+ public boolean insertInstallRecData(JSONObject aData, String downloadBatchNo, String downloadTaskNo,
|
|
|
+ List<ItfInstallBatchDownloadRec> rec, String salesWebsitNumber) throws Exception {
|
|
|
+ List<ItfInstallBatchDownloadRec> oldRec = new ArrayList<>();
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+
|
|
|
+ // 下载记录表查看数据 同一修改时间同一订单 itf_install_batch_download_rec
|
|
|
+ oldRec = itfInstallBatchDownloadRecService.lambdaQuery()
|
|
|
+ .eq(ItfInstallBatchDownloadRec::getPgguid,aData.getString("pgguid"))
|
|
|
+ .eq(ItfInstallBatchDownloadRec::getLastModifiedDate,sdf.parse(aData.getString("lastModifiedDate")))
|
|
|
+ .list();
|
|
|
+ boolean duplicate = (oldRec.size() > 0);
|
|
|
+ // 下载记录表中存在数据
|
|
|
+ if (duplicate) {
|
|
|
+ // 相同修改时间、相同订单存在待同步的数据,不再插入
|
|
|
+ if (!recHasNoUploadStatus(oldRec)) {
|
|
|
+ // 数据处理失败的 插一条新数据再次同步并做说明
|
|
|
+ ItfInstallBatchDownloadRec item = getItfInstallBatchDownloadRec(Boolean.TRUE,aData, downloadBatchNo, downloadTaskNo, salesWebsitNumber);
|
|
|
+ rec.add(item);
|
|
|
+ }
|
|
|
+ return Boolean.FALSE;
|
|
|
+ } else {
|
|
|
+ // 无数据插入新记录 生成对象
|
|
|
+ ItfInstallBatchDownloadRec item = getItfInstallBatchDownloadRec(Boolean.FALSE,aData, downloadBatchNo, downloadTaskNo, salesWebsitNumber);
|
|
|
+ rec.add(item);
|
|
|
+ return Boolean.TRUE;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @NotNull
|
|
|
+ private ItfInstallBatchDownloadRec getItfInstallBatchDownloadRec(Boolean flag, JSONObject aData, String downloadBatchNo, String downloadTaskNo, String salesWebsitNumber) {
|
|
|
+ ItfInstallBatchDownloadRec item = new ItfInstallBatchDownloadRec();
|
|
|
+ item.setSalesWebsitNumber(salesWebsitNumber);
|
|
|
+ item.setDownloadBatchNo(downloadBatchNo);
|
|
|
+ item.setDownloadTaskNo(downloadTaskNo);
|
|
|
+ item.setPgguid(aData.getString("pgguid"));
|
|
|
+ item.setCreatedBy(aData.getString("createdBy"));
|
|
|
+ item.setCreatedDate(aData.getDate("createdDate"));
|
|
|
+ item.setLastModifiedBy(aData.getString("lastModifiedBy"));
|
|
|
+ item.setLastModifiedDate(aData.getDate("lastModifiedDate"));
|
|
|
+ item.setPgid(aData.getString("pgid"));
|
|
|
+ item.setExtendfiled1(aData.getString("extendfiled1"));
|
|
|
+ item.setExtendfiled2(aData.getString("extendfiled2"));
|
|
|
+ item.setExtendfiled3(aData.getString("extendfiled3"));
|
|
|
+ item.setExtendfiled4(aData.getString("extendfiled4"));
|
|
|
+ item.setExtendfiled5(aData.getString("extendfiled5"));
|
|
|
+ if (flag){
|
|
|
+ item.setGreeStatSynErrMsg("任务已经存在,不再产生下载数据");
|
|
|
+ }
|
|
|
+ return item;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private boolean recHasNoUploadStatus(List<ItfInstallBatchDownloadRec> rec) {
|
|
|
+ for (ItfInstallBatchDownloadRec data: rec){
|
|
|
+ if (data.getGreeStatSynStatus() == 0){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ private JSONArray getDownloadData(String downloadBatchNo, String salesWebsitNumber) throws Exception {
|
|
|
+
|
|
|
+ Token token = tokenCenter.getCurrentToken();
|
|
|
+ String url = baseurl + "api/install/search/batch?ssxsgs=" + salesWebsitNumber;
|
|
|
+ // log.info("url[" + url + "],downloadBatchNo[" + downloadBatchNo + "],send[]");
|
|
|
+ JSONObject jsonResult = HttpUtil.httpRequestGetPgid(url, "GET", token, downloadBatchNo, null);
|
|
|
+ String statusCode = jsonResult.getString("statusCode");
|
|
|
+ if ("200".equals(statusCode)) {
|
|
|
+ JSONArray datas = jsonResult.getJSONArray("data");
|
|
|
+ return datas;
|
|
|
+ } else {
|
|
|
+ String errorMessage = jsonResult.getString("message");
|
|
|
+ if (errorMessage == null || errorMessage.trim().length() == 0) {
|
|
|
+ errorMessage = "失败";
|
|
|
+ }
|
|
|
+ log.info(errorMessage);
|
|
|
+ throw new Exception(errorMessage);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|