From 5e62af17e743bfc949e2919b311b7dbbb6a9b328 Mon Sep 17 00:00:00 2001 From: anthonywj Date: Wed, 27 Mar 2024 09:32:22 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B9=B3=E6=BD=AD=E6=94=B6=E8=B4=B9=E7=94=9F?= =?UTF-8?q?=E6=88=90=E5=8D=95=E6=8D=AE=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/glxp/api/aspect/AuthorizeAspect.java | 4 +- .../glxp/api/entity/thrsys/ThrInvOrder.java | 5 + .../glxp/api/http/sync/SpGetHttpClient.java | 4 + .../api/service/inout/IoAddInoutService.java | 2 +- .../thrsys/impl/ThrInvOrderServiceImpl.java | 342 ++++++++++-------- .../task/ScanThrOrderGenerateOrderTask.java | 6 +- src/main/resources/application-dev.yml | 2 +- .../mapper/thrsys/ThrInvOrderDetailMapper.xml | 7 +- src/main/resources/schemas/schema_v2.4.sql | 38 +- 9 files changed, 230 insertions(+), 180 deletions(-) diff --git a/src/main/java/com/glxp/api/aspect/AuthorizeAspect.java b/src/main/java/com/glxp/api/aspect/AuthorizeAspect.java index 4f8e23d29..cfa912a93 100644 --- a/src/main/java/com/glxp/api/aspect/AuthorizeAspect.java +++ b/src/main/java/com/glxp/api/aspect/AuthorizeAspect.java @@ -58,8 +58,8 @@ public class AuthorizeAspect { // 根据头部名称获取相应的值 String value = request.getHeader(name); - log.info("Header Name: " + name); - log.info("Header Value: " + value); +// log.info("Header Name: " + name); +// log.info("Header Value: " + value); } String id = request.getHeader("ADMINID"); diff --git a/src/main/java/com/glxp/api/entity/thrsys/ThrInvOrder.java b/src/main/java/com/glxp/api/entity/thrsys/ThrInvOrder.java index 3b04332fb..07bf94f92 100644 --- a/src/main/java/com/glxp/api/entity/thrsys/ThrInvOrder.java +++ b/src/main/java/com/glxp/api/entity/thrsys/ThrInvOrder.java @@ -108,6 +108,11 @@ public class ThrInvOrder implements Serializable { */ private Integer sourceType; + /** + * 生成单据状态,1.未生成,2.部分生成,3.已生成 + */ + private Integer genStatus; + /** * 异常信息 */ diff --git a/src/main/java/com/glxp/api/http/sync/SpGetHttpClient.java b/src/main/java/com/glxp/api/http/sync/SpGetHttpClient.java index f6d3930fc..c8cd19e3b 100644 --- a/src/main/java/com/glxp/api/http/sync/SpGetHttpClient.java +++ b/src/main/java/com/glxp/api/http/sync/SpGetHttpClient.java @@ -79,6 +79,7 @@ public class SpGetHttpClient { public BaseResponse postData(String taskId, BasicExportTypeEnum exportType, Object data) { SyncUpLoadRequest build = SyncUpLoadRequest.builder().taskId(taskId).exportType(exportType).data(data).build(); String result = okHttpCli.doPostJson(getIpUrl() + "/sps/sync/upload/data", JSONUtil.toJsonStr(build), buildHeader()); + log.info(result); return JSONObject.parseObject(result, new TypeReference>() { }); } @@ -88,6 +89,7 @@ public class SpGetHttpClient { public BaseResponse postAllOrder(SpsSyncOrderResponse spsSyncOrderResponse) { String json = JSONUtil.toJsonStr(spsSyncOrderResponse); String result = okHttpCli.doPostJson(getIpUrl() + "/orderApi/sps/sync/order/upload", json, buildHeader()); + log.info(result); BaseResponse response = JSONObject.parseObject(result, new TypeReference>() { }); @@ -98,6 +100,7 @@ public class SpGetHttpClient { public BaseResponse postAllBusOrder(SpsSyncBusOrderResponse spsSyncOrderResponse) { String json = JSONUtil.toJsonStr(spsSyncOrderResponse); String result = okHttpCli.doPostJson(getIpUrl() + "/busOrderApi/sps/sync/busOrder/upload", json, buildHeader()); + log.info(result); BaseResponse response = JSONObject.parseObject(result, new TypeReference>() { }); @@ -109,6 +112,7 @@ public class SpGetHttpClient { public BaseResponse postAllBusType(SpsSyncBusResponse spsSyncBusResponse) { String json = JSONUtil.toJsonStr(spsSyncBusResponse); String result = okHttpCli.doPostJson(getIpUrl() + "/sps/sync/busType/upload", json, buildHeader()); + log.info(result); BaseResponse response = JSONObject.parseObject(result, new TypeReference>() { }); diff --git a/src/main/java/com/glxp/api/service/inout/IoAddInoutService.java b/src/main/java/com/glxp/api/service/inout/IoAddInoutService.java index 1ec3fc720..bd3baf2f9 100644 --- a/src/main/java/com/glxp/api/service/inout/IoAddInoutService.java +++ b/src/main/java/com/glxp/api/service/inout/IoAddInoutService.java @@ -285,7 +285,7 @@ public class IoAddInoutService { if (StrUtil.isEmpty(orderDetailBizEntity.getSupId())) { errMsg = errMsg + orderDetailBizEntity.getCoName() + "该产品未指定供应商;"; } - if (orderDetailBizEntity.getCount() == 0) { + if (IntUtil.value(orderDetailBizEntity.getCount()) == 0) { errMsg = errMsg + orderDetailBizEntity.getCoName() + "产品数量不能为0;"; } diff --git a/src/main/java/com/glxp/api/service/thrsys/impl/ThrInvOrderServiceImpl.java b/src/main/java/com/glxp/api/service/thrsys/impl/ThrInvOrderServiceImpl.java index 59387fbec..28ae3f973 100644 --- a/src/main/java/com/glxp/api/service/thrsys/impl/ThrInvOrderServiceImpl.java +++ b/src/main/java/com/glxp/api/service/thrsys/impl/ThrInvOrderServiceImpl.java @@ -2,9 +2,9 @@ package com.glxp.api.service.thrsys.impl; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollectionUtil; -import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.github.pagehelper.PageHelper; @@ -21,7 +21,6 @@ import com.glxp.api.entity.basic.*; import com.glxp.api.entity.inout.IoCodeTempEntity; import com.glxp.api.entity.inout.IoOrderDetailBizEntity; import com.glxp.api.entity.inout.IoOrderEntity; -import com.glxp.api.entity.system.SystemParamConfigEntity; import com.glxp.api.entity.thrsys.*; import com.glxp.api.exception.JsonException; import com.glxp.api.http.ErpInvClient; @@ -36,7 +35,6 @@ import com.glxp.api.res.inv.ThrInvResultResponse; import com.glxp.api.res.thrsys.ThrInvOrderResponse; import com.glxp.api.service.auth.CustomerService; import com.glxp.api.service.basic.IBasicBussinessTypeService; -import com.glxp.api.service.basic.ProductInfoService; import com.glxp.api.service.basic.UdiRelevanceService; import com.glxp.api.service.basic.UdiRlSupService; import com.glxp.api.service.basic.impl.BasicDestinyRelService; @@ -53,7 +51,6 @@ import com.glxp.api.util.OrderNoTypeBean; import com.glxp.api.util.udi.FilterUdiUtils; import com.glxp.api.util.udi.UdiCalCountUtil; import lombok.extern.slf4j.Slf4j; -import org.apache.poi.ss.formula.functions.T; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -62,6 +59,7 @@ import javax.annotation.Resource; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.*; +import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; @@ -431,7 +429,7 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService { ioOrderEntity.setFromType(ConstantStatus.FROM_WEBNEW);//网页新增 ioOrderEntity.setStatus(ConstantStatus.ORDER_STATUS_TEMP_SAVE);//草稿 ioOrderEntity.setDealStatus(ConstantStatus.ORDER_DEAL_DRAFT);//草稿 - ioOrderEntity.setCorpOrderId(UUID.randomUUID()+"");//单据号 + ioOrderEntity.setCorpOrderId(UUID.randomUUID() + "");//单据号 ioOrderEntity.setThrOrderIdFk(billNo);//单据号 ioOrderEntity.setUpdateTime(new Date()); ioOrderEntity.setCustomerId("110"); @@ -449,7 +447,7 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService { //更新三方明细列表为已处理 List value = entry.getValue(); List updateThrInvOrderDetails = new ArrayList<>(value.size()); - value.forEach( x -> { + value.forEach(x -> { x.setHandleStatus(1); x.setToBillNo(newBillNo); updateThrInvOrderDetails.add(x); @@ -461,7 +459,7 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService { thrInvOrder.setUpdateTime(new Date()); thrInvOrder.setUpdateUser(userId + ""); - String toBillNo = (thrInvOrder.getToBillNo()==null?"":thrInvOrder.getToBillNo()) +( "," + newBillNo); + String toBillNo = (thrInvOrder.getToBillNo() == null ? "" : thrInvOrder.getToBillNo()) + ("," + newBillNo); // 检查字符串是否以逗号开始 if (toBillNo.startsWith(",")) { // 使用substring()去掉第一个字符 @@ -530,7 +528,7 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService { ioOrderEntity.setFromType(ConstantStatus.FROM_WEBNEW);//网页新增 ioOrderEntity.setStatus(ConstantStatus.ORDER_STATUS_TEMP_SAVE);//草稿 ioOrderEntity.setDealStatus(ConstantStatus.ORDER_DEAL_DRAFT);//草稿 - ioOrderEntity.setCorpOrderId(UUID.randomUUID()+"");//单据号 + ioOrderEntity.setCorpOrderId(UUID.randomUUID() + "");//单据号 ioOrderEntity.setThrOrderIdFk(billNo);//单据号 ioOrderEntity.setUpdateTime(new Date()); ioOrderEntity.setCreateTime(new Date()); @@ -554,7 +552,7 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService { //更新三方明细列表为已处理 List value = entry.getValue(); List updateThrInvOrderDetails = new ArrayList<>(value.size()); - value.forEach( x -> { + value.forEach(x -> { x.setHandleStatus(1); x.setToBillNo(newBillNo); updateThrInvOrderDetails.add(x); @@ -563,7 +561,7 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService { thrInvOrderDetailMapper.updateBatchById(updateThrInvOrderDetails); ioOrderService.insertOrder(ioOrderEntity); - String toBillNo = (thrInvOrder.getToBillNo()==null?"":thrInvOrder.getToBillNo()) +( "," + newBillNo); + String toBillNo = (thrInvOrder.getToBillNo() == null ? "" : thrInvOrder.getToBillNo()) + ("," + newBillNo); // 检查字符串是否以逗号开始 if (toBillNo.startsWith(",")) { // 使用substring()去掉第一个字符 @@ -810,166 +808,184 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService { @Override public void scanInvSfOrderGenerateSfOrder() { log.info("扫描处理第三方收费明细生成单据定时任务开始"); - List list = thrInvOrderDetailMapper.selectSourceTypeList(Constant.THR_INV_SF_ORDER_TYPE); - /** - * 1、根据 外检单号 进行 分组 - * 2、遍历不同分组 在分组的列表再次进行匹配 - * 3、匹配到的列表 不为空 进行 新增关联的单据 插入明细操作 - * 4、需要 回写三方的明细表 标记已处理 - */ - if (CollectionUtil.isEmpty(list)) return; - Map> grouped = list.stream() - .collect(Collectors.groupingBy(ThrInvOrderDetail::getOrderIdFk)); - for (Map.Entry> entry : grouped.entrySet()) { - String orderIdFk = entry.getKey(); - log.info("扫描处理第三方收费明细生成单据定时任务==orderIdFk==:[" + orderIdFk + "]"); - List thrInvOrderDetails = entry.getValue(); - //新单号 - String newBillNo = gennerOrderUtils.createScOrderNo(new OrderNoTypeBean(Constant.SCAN_ORDER, "yyyyMMdd")); - - //通过单号获取单据信息 - QueryWrapper qw = new QueryWrapper<>(); - qw.eq("billNo", orderIdFk); - ThrInvOrder thrInvOrder = thrInvOrderMapper.selectOne(qw); - BasicBussinessTypeEntity bussinessTypeEntity = bussinessTypeService.findByAction(thrInvOrder.getBillType()); - List addThrInvOrderDetails = new ArrayList<>(); - List updateThrInvOrderDetails = new ArrayList<>(); - List delThrInvOrderDetailIds = new ArrayList<>(); - List delThrCodes = new ArrayList<>(); - - if (thrInvOrder.getSourceType() == Constant.THR_INV_SF_ORDER_TYPE) {//走组套 - log.info("走组套"); - thrInvOrderDetails.forEach(item -> { - Long relId = item.getRelId(); - if (ObjectUtil.isNull(relId)) { - //通过thrCode获取到项目组套 - String thrCode = item.getThrCode(); - Integer count = Integer.valueOf(item.getReCount()); - List skProjectDetailEntityList = basicDestinyRelService.filterDestinyRelListByPId(thrCode); - if (CollectionUtil.isNotEmpty(skProjectDetailEntityList) && count > 0) { - delThrInvOrderDetailIds.add(item.getId()); - skProjectDetailEntityList.forEach(sk -> { - ThrInvOrderDetail thrInvOrderDetail = new ThrInvOrderDetail(); - BeanUtils.copyProperties(item, thrInvOrderDetail); - thrInvOrderDetail.setId(null); - thrInvOrderDetail.setOrderIdFk(orderIdFk); - thrInvOrderDetail.setRelId(sk.getRelId()); - thrInvOrderDetail.setSupId(sk.getSupId() + ""); - thrInvOrderDetail.setHandleStatus(1); - thrInvOrderDetail.setToBillNo(newBillNo); - - Integer skCount = sk.getCount(); - if (skCount != null && skCount > 0) { - thrInvOrderDetail.setReCount(String.valueOf(skCount * count)); - } - - addThrInvOrderDetails.add(thrInvOrderDetail); - delThrCodes.add(thrCode); - }); - } else { - - } - } - }); - - } else {//不走组套 - log.info("不走组套"); - String thirdSysFk = thrInvOrder.getThirdSysFk(); - List thrCodes = thrInvOrderDetails.stream().filter(x -> ObjectUtil.isNull(x.getRelId())) - .map(ThrInvOrderDetail::getThrCode).collect(Collectors.toList()); - if (CollectionUtil.isNotEmpty(thrCodes)) { - MainIdRelIdAndProductResponse map = udiRelevanceService.selectMainIdRelIdAndProductMap(thrCodes, thirdSysFk); - Map mainIdRelIdMap = map.getMainIdRelIdMap(); +// List list = thrInvOrderDetailMapper.selectSourceTypeList(Constant.THR_INV_SF_ORDER_TYPE); + + List thrInvOrders = thrInvOrderMapper.selectList(new LambdaQueryWrapper() + .eq(ThrInvOrder::getSourceType, Constant.THR_INV_SF_ORDER_TYPE) + .lt(ThrInvOrder::getGenStatus, 3)); + + if (CollUtil.isNotEmpty(thrInvOrders)) { + + for (ThrInvOrder thrInvOrder : thrInvOrders) { + /** + * 1、根据 外检单号 进行 分组 + * 2、遍历不同分组 在分组的列表再次进行匹配 + * 3、匹配到的列表 不为空 进行 新增关联的单据 插入明细操作 + * 4、需要 回写三方的明细表 标记已处理 + */ + + List thrInvOrderDetails = thrInvOrderDetailMapper.selectList( + new LambdaQueryWrapper() + .and(o -> o.isNull(ThrInvOrderDetail::getHandleStatus).or().ne(ThrInvOrderDetail::getHandleStatus, 1)). + eq(ThrInvOrderDetail::getOrderIdFk, thrInvOrder.getBillNo()) + ); + if (CollectionUtil.isEmpty(thrInvOrderDetails)) return; + log.info("扫描处理第三方收费明细生成单据定时任务==orderIdFk==:[" + thrInvOrder.getBillNo() + "]"); + //新单号 + String newBillNo = gennerOrderUtils.createScOrderNo(new OrderNoTypeBean(Constant.SCAN_ORDER, "yyyyMMdd")); + //通过单号获取单据信息 + QueryWrapper qw = new QueryWrapper<>(); + qw.eq("billNo", thrInvOrder.getBillNo()); + BasicBussinessTypeEntity bussinessTypeEntity = bussinessTypeService.findByAction(thrInvOrder.getBillType()); + List addThrInvOrderDetails = new ArrayList<>(); + List updateThrInvOrderDetails = new ArrayList<>(); + List delThrInvOrderDetailIds = new ArrayList<>(); + List delThrCodes = new ArrayList<>(); + if (thrInvOrder.getSourceType() == Constant.THR_INV_SF_ORDER_TYPE) {//走组套 + log.info("走组套"); + AtomicInteger fullGen = new AtomicInteger(); thrInvOrderDetails.forEach(item -> { - if (ObjectUtil.isNull(item.getRelId())) { + Long relId = item.getRelId(); + if (ObjectUtil.isNull(relId)) { String thrCode = item.getThrCode(); - Long relId = mainIdRelIdMap.get(thrCode).getId(); - if (ObjectUtil.isNotNull(relId)) { - item.setRelId(relId); - item.setHandleStatus(1); - item.setToBillNo(newBillNo); - updateThrInvOrderDetails.add(item); - //校验产品是否被供应商关联 - CompanyProductRelevanceEntity udiRlSupEntity = udiRlSupService.selOneByRlId(relId); - if (udiRlSupEntity != null) - item.setSupId(udiRlSupEntity.getCustomerId()); - } else { + Integer count = Integer.valueOf(item.getReCount()); + List skProjectDetailEntityList = basicDestinyRelService.filterDestinyRelListByPId(thrCode); + if (CollectionUtil.isNotEmpty(skProjectDetailEntityList) && count > 0) { + delThrInvOrderDetailIds.add(item.getId()); + skProjectDetailEntityList.forEach(sk -> { + ThrInvOrderDetail thrInvOrderDetail = new ThrInvOrderDetail(); + BeanUtils.copyProperties(item, thrInvOrderDetail); + thrInvOrderDetail.setId(null); + thrInvOrderDetail.setOrderIdFk(thrInvOrder.getBillNo()); + thrInvOrderDetail.setRelId(sk.getRelId()); + thrInvOrderDetail.setSupId(sk.getSupId() + ""); + thrInvOrderDetail.setHandleStatus(1); + thrInvOrderDetail.setToBillNo(newBillNo); + + Integer skCount = sk.getCount(); + if (skCount != null && skCount > 0) { + thrInvOrderDetail.setReCount(String.valueOf(skCount * count)); + } + addThrInvOrderDetails.add(thrInvOrderDetail); + delThrCodes.add(thrCode); + }); + fullGen.getAndIncrement(); } } }); + if (thrInvOrderDetails.size() == fullGen.intValue()) { + thrInvOrder.setGenStatus(2); + thrInvOrderMapper.updateById(thrInvOrder); + } else if (thrInvOrder.getGenStatus() < 1 && fullGen.intValue() > 0) { + thrInvOrder.setGenStatus(2); + thrInvOrderMapper.updateById(thrInvOrder); + } + + } else {//不走组套 + log.info("不走组套"); + String thirdSysFk = thrInvOrder.getThirdSysFk(); + List thrCodes = thrInvOrderDetails.stream().filter(x -> ObjectUtil.isNull(x.getRelId())) + .map(ThrInvOrderDetail::getThrCode).collect(Collectors.toList()); + if (CollectionUtil.isNotEmpty(thrCodes)) { + MainIdRelIdAndProductResponse map = udiRelevanceService.selectMainIdRelIdAndProductMap(thrCodes, thirdSysFk); + Map mainIdRelIdMap = map.getMainIdRelIdMap(); + + thrInvOrderDetails.forEach(item -> { + if (ObjectUtil.isNull(item.getRelId())) { + String thrCode = item.getThrCode(); + Long relId = mainIdRelIdMap.get(thrCode).getId(); + if (ObjectUtil.isNotNull(relId)) { + item.setRelId(relId); + item.setHandleStatus(1); + item.setToBillNo(newBillNo); + updateThrInvOrderDetails.add(item); + //校验产品是否被供应商关联 + CompanyProductRelevanceEntity udiRlSupEntity = udiRlSupService.selOneByRlId(relId); + if (udiRlSupEntity != null) + item.setSupId(udiRlSupEntity.getCustomerId()); + } + } + }); + } + } + //删除原来的明细 + if (CollectionUtil.isNotEmpty(delThrInvOrderDetailIds)) { + thrInvOrderDetailMapper.deleteBatchIds(delThrInvOrderDetailIds); + } + //删除原来的明细 + if (CollectionUtil.isNotEmpty(delThrCodes)) { + thrInvOrderDetailMapper.deleteBatchByThrCodeIds(delThrCodes); + } + //新增明细 + if (CollectionUtil.isNotEmpty(addThrInvOrderDetails)) { + thrInvOrderDetailMapper.insertBatch(addThrInvOrderDetails); + } + //更新明细 + if (CollectionUtil.isNotEmpty(updateThrInvOrderDetails)) { + thrInvOrderDetailMapper.updateBatchById(updateThrInvOrderDetails); + } + genOrder(newBillNo, updateThrInvOrderDetails, addThrInvOrderDetails, thrInvOrder, bussinessTypeEntity); + log.info("扫描处理第三方收费明细生成单据定时任务结束"); } - //删除原来的明细 - if (CollectionUtil.isNotEmpty(delThrInvOrderDetailIds)) { - thrInvOrderDetailMapper.deleteBatchIds(delThrInvOrderDetailIds); - } - //删除原来的明细 - if (CollectionUtil.isNotEmpty(delThrCodes)) { - thrInvOrderDetailMapper.deleteBatchByThrCodeIds(delThrCodes); - } - //新增明细 - if (CollectionUtil.isNotEmpty(addThrInvOrderDetails)) { - thrInvOrderDetailMapper.insertBatch(addThrInvOrderDetails); - } - //更新明细 - if (CollectionUtil.isNotEmpty(updateThrInvOrderDetails)) { - thrInvOrderDetailMapper.updateBatchById(updateThrInvOrderDetails); - } + } + } - if (updateThrInvOrderDetails.size() > 0 || addThrInvOrderDetails.size() > 0) { + public void genOrder(String newBillNo, + List updateThrInvOrderDetails, List addThrInvOrderDetails, + ThrInvOrder thrInvOrder, BasicBussinessTypeEntity bussinessTypeEntity) { + if (updateThrInvOrderDetails.size() > 0 || addThrInvOrderDetails.size() > 0) { - IoOrderEntity ioOrderEntity = new IoOrderEntity(); - ioOrderEntity.setBillNo(newBillNo); - ioOrderEntity.setMainAction(thrInvOrder.getMainAction()); - ioOrderEntity.setFromCorp(thrInvOrder.getFromCorp()); - ioOrderEntity.setInvCode(thrInvOrder.getInvCode()); - ioOrderEntity.setDeptCode(thrInvOrder.getDeptCode()); - ioOrderEntity.setAction(thrInvOrder.getBillType()); + IoOrderEntity ioOrderEntity = new IoOrderEntity(); + ioOrderEntity.setBillNo(newBillNo); + ioOrderEntity.setMainAction(thrInvOrder.getMainAction()); + ioOrderEntity.setFromCorp(thrInvOrder.getFromCorp()); + ioOrderEntity.setInvCode(thrInvOrder.getInvCode()); + ioOrderEntity.setDeptCode(thrInvOrder.getDeptCode()); + ioOrderEntity.setAction(thrInvOrder.getBillType()); - ioOrderEntity.setFromType(ConstantStatus.FROM_WEBNEW);//网页新增 - ioOrderEntity.setStatus(ConstantStatus.ORDER_STATUS_TEMP_SAVE);//草稿 - ioOrderEntity.setDealStatus(ConstantStatus.ORDER_DEAL_DRAFT);//草稿 - ioOrderEntity.setCorpOrderId(UUID.randomUUID() + "");//单据号 - ioOrderEntity.setThrOrderIdFk(thrInvOrder.getBillNo());//单据号 - ioOrderEntity.setUpdateTime(new Date()); - ioOrderEntity.setCreateTime(new Date()); - ioOrderEntity.setCustomerId("110"); - Long userId = customerService.getUserId(); - ioOrderEntity.setCreateUser(userId + ""); - ioOrderEntity.setUpdateUser(userId + ""); - ioOrderEntity.setOrderType(ConstantStatus.ORDER_TYPE_SCAN);//正常单据处理 - List newOrderDetailBiz = new ArrayList<>(updateThrInvOrderDetails.size()); + ioOrderEntity.setFromType(ConstantStatus.FROM_WEBNEW);//网页新增 + ioOrderEntity.setStatus(ConstantStatus.ORDER_STATUS_TEMP_SAVE);//草稿 + ioOrderEntity.setDealStatus(ConstantStatus.ORDER_DEAL_DRAFT);//草稿 + ioOrderEntity.setCorpOrderId(UUID.randomUUID() + "");//单据号 + ioOrderEntity.setThrOrderIdFk(thrInvOrder.getBillNo());//单据号 + ioOrderEntity.setUpdateTime(new Date()); + ioOrderEntity.setCreateTime(new Date()); + ioOrderEntity.setCustomerId("110"); + Long userId = customerService.getUserId(); + ioOrderEntity.setCreateUser(userId + ""); + ioOrderEntity.setUpdateUser(userId + ""); + ioOrderEntity.setOrderType(ConstantStatus.ORDER_TYPE_SCAN);//正常单据处理 + List newOrderDetailBiz = new ArrayList<>(updateThrInvOrderDetails.size()); - if (updateThrInvOrderDetails.size() > 0) { - if (!copyOrderDetailBiz(updateThrInvOrderDetails, newOrderDetailBiz, newBillNo)) { - throw new JsonException("第三方收费明细自动转化单据异常"); - } + if (updateThrInvOrderDetails.size() > 0) { + if (!copyOrderDetailBiz(updateThrInvOrderDetails, newOrderDetailBiz, newBillNo)) { + throw new JsonException("第三方收费明细自动转化单据异常"); } - if (addThrInvOrderDetails.size() > 0) { - if (!copyOrderDetailBiz(addThrInvOrderDetails, newOrderDetailBiz, newBillNo)) { - throw new JsonException("第三方收费明细自动转化单据异常"); - } - } - - String toBillNo = (thrInvOrder.getToBillNo()==null?"":thrInvOrder.getToBillNo()) +( "," + newBillNo); - // 检查字符串是否以逗号开始 - if (toBillNo.startsWith(",")) { - // 使用substring()去掉第一个字符 - toBillNo = toBillNo.substring(1); + } + if (addThrInvOrderDetails.size() > 0) { + if (!copyOrderDetailBiz(addThrInvOrderDetails, newOrderDetailBiz, newBillNo)) { + throw new JsonException("第三方收费明细自动转化单据异常"); } - thrInvOrder.setToBillNo(toBillNo); + } - thrInvOrderMapper.updateById(thrInvOrder); - ioOrderService.insertOrder(ioOrderEntity); - ioOrderDetailBizService.batchInsertBizs(newOrderDetailBiz); - //自动处理业务单据 - ioAddInoutService.dealBusProcess(ioOrderEntity, bussinessTypeEntity); + String toBillNo = (thrInvOrder.getToBillNo() == null ? "" : thrInvOrder.getToBillNo()) + ("," + newBillNo); + // 检查字符串是否以逗号开始 + if (toBillNo.startsWith(",")) { + // 使用substring()去掉第一个字符 + toBillNo = toBillNo.substring(1); } + thrInvOrder.setToBillNo(toBillNo); + + thrInvOrderMapper.updateById(thrInvOrder); + ioOrderService.insertOrder(ioOrderEntity); + ioOrderDetailBizService.batchInsertBizs(newOrderDetailBiz); + //自动处理业务单据 + ioAddInoutService.dealBusProcess(ioOrderEntity, bussinessTypeEntity); } - log.info("扫描处理第三方收费明细生成单据定时任务结束"); } @Override @@ -1117,7 +1133,7 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService { throw new JsonException("第三方普耗明细自动转化单据异常"); } } - String toBillNo = (thrInvOrder.getToBillNo()==null?"":thrInvOrder.getToBillNo()) +( "," + newBillNo); + String toBillNo = (thrInvOrder.getToBillNo() == null ? "" : thrInvOrder.getToBillNo()) + ("," + newBillNo); // 检查字符串是否以逗号开始 if (toBillNo.startsWith(",")) { // 使用substring()去掉第一个字符 @@ -1172,7 +1188,7 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService { } }); - if (generatethrInvOrderDetails.size() >0 ) { + if (generatethrInvOrderDetails.size() > 0) { thrInvOrderDetailMapper.updateBatchById(generatethrInvOrderDetails);//先进行 回写已处理状态 //通过单号获取单据信息 @@ -1208,7 +1224,7 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService { throw new JsonException("第三方高耗明细自动转化单据异常"); } - String toBillNo = (thrInvOrder.getToBillNo()==null?"":thrInvOrder.getToBillNo()) +( "," + newBillNo); + String toBillNo = (thrInvOrder.getToBillNo() == null ? "" : thrInvOrder.getToBillNo()) + ("," + newBillNo); // 检查字符串是否以逗号开始 if (toBillNo.startsWith(",")) { // 使用substring()去掉第一个字符 @@ -1259,6 +1275,8 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService { newBillNo) { List relIds = thrInvOrderDetails.stream().filter(x -> ObjectUtil.isNotNull(x.getRelId())) .map(ThrInvOrderDetail::getRelId).collect(Collectors.toList()); + if (CollUtil.isEmpty(relIds)) + return false; List basicProductsEntities = udiRelevanceDao.selectProductByRelIds(relIds); if (CollectionUtil.isEmpty(basicProductsEntities)) return false; Map relIdBasicProductsEntityMap = basicProductsEntities.stream().collect(Collectors.toMap(BasicProductsEntity::getId, x -> x)); @@ -1266,11 +1284,14 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService { for (int i = 0; i < thrInvOrderDetails.size(); i++) { ThrInvOrderDetail thrInvOrderDetail = thrInvOrderDetails.get(i); Long relId = thrInvOrderDetail.getRelId(); - BasicProductsEntity basicProductsEntity = relIdBasicProductsEntityMap.get(relId); - IoOrderDetailBizEntity ioOrderDetailBizEntity = new IoOrderDetailBizEntity(); - parameterPackag(basicProductsEntity, ioOrderDetailBizEntity, thrInvOrderDetail); - ioOrderDetailBizEntity.setOrderIdFk(newBillNo); - newOrderDetailBiz.add(ioOrderDetailBizEntity); + if (relId != null) { + BasicProductsEntity basicProductsEntity = relIdBasicProductsEntityMap.get(relId); + IoOrderDetailBizEntity ioOrderDetailBizEntity = new IoOrderDetailBizEntity(); + parameterPackag(basicProductsEntity, ioOrderDetailBizEntity, thrInvOrderDetail); + ioOrderDetailBizEntity.setOrderIdFk(newBillNo); + newOrderDetailBiz.add(ioOrderDetailBizEntity); + } + } return true; } @@ -1320,7 +1341,7 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService { ioOrderDetailBizEntity.setBindRlFk(basicProductsEntity.getId()); ioOrderDetailBizEntity.setSupId(thrInvOrderDetail.getSupId()); ioOrderDetailBizEntity.setNameCode(basicProductsEntity.getNameCode()); - ioOrderDetailBizEntity.setCount(Integer.valueOf(thrInvOrderDetail.getReCount())); + ioOrderDetailBizEntity.setCount(IntUtil.value(thrInvOrderDetail.getReCount())); ioOrderDetailBizEntity.setBatchNo(thrInvOrderDetail.getBatchNo()); ioOrderDetailBizEntity.setCoName(basicProductsEntity.getCpmctymc()); ioOrderDetailBizEntity.setCertCode(basicProductsEntity.getZczbhhzbapzbh()); @@ -1374,6 +1395,7 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService { thrInvOrder.setStatus(ConstantStatus.SFIO_DRAFT);//单据状态 草稿 thrInvOrder.setSourceType(SourceType);//来源类型 thrInvOrder.setCreateTime(newDate); + thrInvOrder.setGenStatus(1); if (thrSystemBusApiEntity != null) thrInvOrder.setFromCorp(thrSystemBusApiEntity.getFromCorp()); thrInvOrder.setCreateUser("外部系统下载"); diff --git a/src/main/java/com/glxp/api/task/ScanThrOrderGenerateOrderTask.java b/src/main/java/com/glxp/api/task/ScanThrOrderGenerateOrderTask.java index aa9cb7083..22b7825f9 100644 --- a/src/main/java/com/glxp/api/task/ScanThrOrderGenerateOrderTask.java +++ b/src/main/java/com/glxp/api/task/ScanThrOrderGenerateOrderTask.java @@ -1,10 +1,12 @@ package com.glxp.api.task; +import cn.hutool.core.thread.ThreadUtil; import com.glxp.api.dao.schedule.ScheduledDao; import com.glxp.api.entity.system.ScheduledEntity; import com.glxp.api.req.system.ScheduledRequest; import com.glxp.api.service.thrsys.ThrInvOrderService; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.exception.ExceptionUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.scheduling.annotation.SchedulingConfigurer; @@ -49,7 +51,7 @@ public class ScanThrOrderGenerateOrderTask implements SchedulingConfigurer { try { thrInvOrderService.scanInvSfOrderGenerateSfOrder(); } catch (Exception e) { - + log.error(ExceptionUtils.getStackTrace(e)); } log.info("定时扫描三方的明细表-收费明细类型结束"); //======================================================================================= @@ -57,7 +59,7 @@ public class ScanThrOrderGenerateOrderTask implements SchedulingConfigurer { try { thrInvOrderService.scanInvPhOrderGeneratePhOrder(); } catch (Exception e) { - + log.error(ExceptionUtils.getStackTrace(e)); } log.info("定时扫描三方的明细表-普耗明细类型结束"); //======================================================================================= diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index eff144325..819251754 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -4,7 +4,7 @@ server: spring: datasource: driver-class-name: com.p6spy.engine.spy.P6SpyDriver - jdbc-url: jdbc:p6spy:mysql://127.0.0.1:3306/udi_wms_ct?allowMultiQueries=true&serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true + jdbc-url: jdbc:p6spy:mysql://192.168.0.43:3306/udi_wms_pt?allowMultiQueries=true&serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true username: root password: 123456 hikari: diff --git a/src/main/resources/mybatis/mapper/thrsys/ThrInvOrderDetailMapper.xml b/src/main/resources/mybatis/mapper/thrsys/ThrInvOrderDetailMapper.xml index b369e901a..f961da564 100644 --- a/src/main/resources/mybatis/mapper/thrsys/ThrInvOrderDetailMapper.xml +++ b/src/main/resources/mybatis/mapper/thrsys/ThrInvOrderDetailMapper.xml @@ -27,11 +27,10 @@ resultType="com.glxp.api.entity.thrsys.ThrInvOrderDetail"> SELECT * FROM thr_inv_order_detail - right join thr_inv_order on thr_inv_order_detail.orderIdFk = thr_inv_order.billNo + right join thr_inv_order on thr_inv_order_detail.orderIdFk = thr_inv_order.billNo - AND thr_inv_order.sourceType = #{thrInvSfOrderType} - AND (thr_inv_order_detail.handleStatus = 0 or thr_inv_order_detail.handleStatus is null ) + AND thr_inv_order.sourceType = #{thrInvSfOrderType} + AND (thr_inv_order_detail.handleStatus = 0 or thr_inv_order_detail.handleStatus is null) - diff --git a/src/main/resources/schemas/schema_v2.4.sql b/src/main/resources/schemas/schema_v2.4.sql index 5909c9d75..ba36a6419 100644 --- a/src/main/resources/schemas/schema_v2.4.sql +++ b/src/main/resources/schemas/schema_v2.4.sql @@ -1809,11 +1809,14 @@ values (7, 2, '停用', '1', 'sys_normal_disable', '', 'danger', 'N', '0', 'admi insert IGNORE into sys_dict_type values (4, '设备来源', 'device_source_type', '0', 'admin', sysdate(), '', null, '设备来源列表'); insert IGNORE into sys_dict_data -values (8, 1, '采购', '1', 'device_source_type', '', 'primary', 'Y', '0', 'admin', sysdate(), '', null, 'chooseProductFlag'); +values (8, 1, '采购', '1', 'device_source_type', '', 'primary', 'Y', '0', 'admin', sysdate(), '', null, + 'chooseProductFlag'); insert IGNORE into sys_dict_data -values (9, 2, '赠与', '2', 'device_source_type', '', 'primary', 'N', '0', 'admin', sysdate(), '', null, 'selectInvProductVisible'); +values (9, 2, '赠与', '2', 'device_source_type', '', 'primary', 'N', '0', 'admin', sysdate(), '', null, + 'selectInvProductVisible'); insert IGNORE into sys_dict_data -values (10, 3, '寄售', '3', 'device_source_type', '', 'primary', 'N', '0', 'admin', sysdate(), '', null, 'chooseProductFlag'); +values (10, 3, '寄售', '3', 'device_source_type', '', 'primary', 'N', '0', 'admin', sysdate(), '', null, + 'chooseProductFlag'); ALTER TABLE sys_dict_data @@ -1821,11 +1824,16 @@ ALTER TABLE sys_dict_data ALTER TABLE sys_dict_type MODIFY COLUMN `dict_id` bigint(0) NOT NULL AUTO_INCREMENT COMMENT '字典主键' FIRST; -INSERT IGNORE INTO sys_dict_type(`dict_id`, `dict_name`, `dict_type`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) -VALUES (9, '相关人员类别', 'device_user_type', '0', 'admin', '2024-03-20 11:47:55', 'admin', '2024-03-20 11:47:55', '相关人员类别列表'); -insert IGNORE into sys_dict_data values(11, 1, '维护员', '1', 'device_user_type', '', 'primary', 'Y', '0', 'admin', sysdate(), '', null, '维护人员'); -insert IGNORE into sys_dict_data values(12, 2, '厂家技术支持', '2', 'device_user_type', '', 'primary', 'N', '0', 'admin', sysdate(), '', null, '厂家技术支持人员'); -insert IGNORE into sys_dict_data values(13, 3, '操作员', '3', 'device_user_type', '', 'primary', 'N', '0', 'admin', sysdate(), '', null, '操作人员'); +INSERT IGNORE INTO sys_dict_type(`dict_id`, `dict_name`, `dict_type`, `status`, `create_by`, `create_time`, `update_by`, + `update_time`, `remark`) +VALUES (9, '相关人员类别', 'device_user_type', '0', 'admin', '2024-03-20 11:47:55', 'admin', '2024-03-20 11:47:55', + '相关人员类别列表'); +insert IGNORE into sys_dict_data +values (11, 1, '维护员', '1', 'device_user_type', '', 'primary', 'Y', '0', 'admin', sysdate(), '', null, '维护人员'); +insert IGNORE into sys_dict_data +values (12, 2, '厂家技术支持', '2', 'device_user_type', '', 'primary', 'N', '0', 'admin', sysdate(), '', null, '厂家技术支持人员'); +insert IGNORE into sys_dict_data +values (13, 3, '操作员', '3', 'device_user_type', '', 'primary', 'N', '0', 'admin', sysdate(), '', null, '操作人员'); CALL Pro_Temp_ColumnWork('device_asset_user', 'userType', ' varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_as_cs NULL DEFAULT NULL COMMENT ''用户类型'' ', @@ -1839,8 +1847,13 @@ ALTER TABLE device_asset_user CALL Pro_Temp_ColumnWork('thr_inv_order_detail', 'batchNo', 'varchar(60)', 2); -INSERT IGNORE INTO sys_custom_config_detail(`id`, `configId`, `type`, `isShow`, `columnName`, `columnDesc`, `columnType`, `colorRule`, `sort`, `lableRule`, `width`, `tooltip`, `buttonRule`, `number`, `lineNumber`, `clickFuc`, `size`, `style`, `disabled`, `checkRules`, `inputType`, `disabledFuc`, `expression`, `dataFuc`, `isShowXx`) -VALUES (38032, 16, '1', 1, 'auditTime', '审核时间', 'text', '', NULL, '', NULL, NULL, '', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); +INSERT IGNORE INTO sys_custom_config_detail(`id`, `configId`, `type`, `isShow`, `columnName`, `columnDesc`, + `columnType`, `colorRule`, `sort`, `lableRule`, `width`, `tooltip`, + `buttonRule`, `number`, `lineNumber`, `clickFuc`, `size`, `style`, + `disabled`, `checkRules`, `inputType`, `disabledFuc`, `expression`, + `dataFuc`, `isShowXx`) +VALUES (38032, 16, '1', 1, 'auditTime', '审核时间', 'text', '', NULL, '', NULL, NULL, '', NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL); CALL Pro_Temp_ColumnWork('basic_products', 'catalogname1', ' varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT ''一级分类名称(学科,品名)''', @@ -1878,3 +1891,8 @@ CALL Pro_Temp_ColumnWork('thr_inv_order_detail', 'toBillNo', CALL Pro_Temp_ColumnWork('thr_inv_order', 'toBillNo', ' varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT ''生成的单据号''', 1); + + +CALL Pro_Temp_ColumnWork('thr_inv_order', 'genStatus', + ' tinyint NULL DEFAULT NULL COMMENT ''生成单据状态''', + 1);