From ba173949df6bf3f0a5a39e04e8265cd43c9cede4 Mon Sep 17 00:00:00 2001
From: doum <doum>
Date: 星期三, 19 十一月 2025 14:59:08 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/wuhuyancao' into wuhuyancao
---
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/JkSketchServiceImpl.java | 125 +++++++++++++++++++++++++++--------------
1 files changed, 83 insertions(+), 42 deletions(-)
diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/JkSketchServiceImpl.java b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/JkSketchServiceImpl.java
index d580516..f5dbf90 100644
--- a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/JkSketchServiceImpl.java
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/JkSketchServiceImpl.java
@@ -261,7 +261,6 @@
Date date = new Date();
BigDecimal cLatitude =new BigDecimal(0);
BigDecimal cLongitude =new BigDecimal(0);
-
String location = systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.COMPANY_LOCATION).getCode();
try {
String[] ss = location.split(",");
@@ -269,25 +268,55 @@
cLatitude = new BigDecimal(ss[1]);
}catch (Exception e){
}
- int index =0;
- for(JkCustomer c : customerList){
- try {
- log.info("浜ら�氳鍒�========"+c.getName()+"==========="+index++);
- dealDistancePerCustomer(c,url,date,cLatitude,cLongitude,customerList);
- }catch (Exception e){
-
- }
+ int circle = customerList.size()/100;//
+ if(customerList.size()%100>0){
+ circle +=1;
}
+ boolean[] results = new boolean[circle] ;
+ for (int i = 0; i < circle; i++) {
+ final int start =i*100;
+ final int end = (i+1)*100 > customerList.size()? customerList.size(): (i+1)*100;
+ results[i] =false;
+ BigDecimal finalCLatitude = cLatitude;
+ BigDecimal finalCLongitude = cLongitude;
+ log.error("浜ら�氳鍒�====绾跨▼circle锛�"+i+"====start:"+start+"===========end:"+end);
+ int finalI = i;
+ Thread t1=new Thread(() -> {
+ try {
+ int index =0;
+ for (int j = start; j < end; j++) {
+ try {
+ log.error("浜ら�氳鍒�========"+customerList.get(j).getName()+"========cirle:"+finalI+"==="+index++);
+ dealDistancePerCustomer(customerList.get(j),url,date, finalCLatitude, finalCLongitude,customerList);
+ }catch (Exception e){
+
+ }
+ }
+ }catch (Exception e){
+ }finally {
+ results[finalI] =true;
+ boolean isDone = false;
+ for(boolean t : results){
+ isDone = isDone&&t;
+ }
+ if(isDone){
+ cate.setStatus(Constants.ZERO);
+ categoryMapper.updateById(cate);//鏇存柊浠诲姟鎵ц鐘舵��
+ }
+ }
+
+ });
+ t1.start();
+ }
}catch (Exception e){
e.printStackTrace();
}finally {
- cate.setStatus(Constants.ZERO);
- categoryMapper.updateById(cate);//鏇存柊浠诲姟鎵ц鐘舵��
+
}
}
- private void dealDistancePerCustomer(JkCustomer c, String url, Date date, BigDecimal cLatitude, BigDecimal cLongitude, List<JkCustomer> customerList) {
+ private void dealDistancePerCustomer(JkCustomer c, String url, Date date, BigDecimal cLatitude, BigDecimal cLongitude, List<JkCustomer> customerList) throws InterruptedException {
List<JkCustomer> updateCustomerList = new ArrayList<>();
List<JkCustomerNavigation> navigationList = new ArrayList<>();
List<DistanceMapParam> tmpList = new ArrayList<>();
@@ -298,28 +327,34 @@
t0.setId(-2);//琛ㄧず杩斿洖鍥尯
t0.setDistance(Constants.formatLongNum(c.getStartDistance()) );
if(Constants.formatLongNum(c.getStartDistance()) <= 0){
- //鍥尯鍓嶅線璇ュ鎴风殑璺濈锛屽鏋滀箣鍓嶆湭鑾峰彇杩�
+ //鍥尯鍓嶅線璇ュ鎴风殑璺濈锛屽鏋滀箣鍓嶆湭鑾峰彇
isNew = true;
JkCustomer start = new JkCustomer();
start.setId(-1);
start.setLongitude(cLongitude);
start.setLatitude(cLatitude);
DistanceCustomerModel dm = DistanceCalculator.calculateDistanceGaode(url,start,c);
- c.setStartDistance(dm.getDistance() );
- t0.setDistance(dm.getDistance());
- u.setStartDistance(dm.getDistance());
- if(dm.getLocations().size()>0){
- //濡傛灉鏈夎矾寰勪俊鎭�
- u.setStartSteps(dm.getPolyline());
+ if(dm.getCode() == 1){
+ //瑙勫垝澶辫触
+ log.error("==============瀹㈡埛浜ら�氳鍒掓垚鍔熻捣鐐�:"+c.getName());
+ c.setStartDistance(dm.getDistance() );
+ t0.setDistance(dm.getDistance());
+ u.setStartDistance(dm.getDistance());
+ if(dm.getLocations().size()>0){
+ //濡傛灉鏈夎矾寰勪俊鎭�
+ u.setStartSteps(dm.getPolyline());
+ }
}
+
}
tmpList.add(t0);
for(JkCustomer cm : customerList){
//瀹㈡埛鍜屽鎴蜂箣闂寸殑璺濈淇℃伅
+ Thread.sleep(500);
DistanceMapParam t = new DistanceMapParam();
t.setId(cm.getId());
DistanceMapParam param = getParamByCustomerIds( cm.getId(),distanceMapParamList);
- if(param!=null){//濡傛灉涔嬪墠宸茬粡鑾峰彇杩�
+ if(param!=null && param.getDistance()!=0){//濡傛灉涔嬪墠宸茬粡鑾峰彇杩�
t = param;
}else{
JkCustomerNavigation navigation = new JkCustomerNavigation();
@@ -359,15 +394,19 @@
start.setId(-1);
start.setLongitude(cLongitude);
start.setLatitude(cLatitude);
-
DistanceCustomerModel dm = DistanceCalculator.calculateDistanceGaode(url,c,start);
- c.setEndDistance(dm.getDistance() );
- tt.setDistance(dm.getDistance());
- u.setEndDistance(dm.getDistance());
- if(dm.getLocations().size()>0){
- //濡傛灉鏈夎矾寰勪俊鎭�
- u.setEndSteps(dm.getPolyline());
+ if(dm.getCode()== 1){
+ //瑙勫垝澶辫触
+ log.error("==============瀹㈡埛浜ら�氳鍒掓垚鍔�2:"+c.getName());
+ c.setEndDistance(dm.getDistance() );
+ tt.setDistance(dm.getDistance());
+ u.setEndDistance(dm.getDistance());
+ if(dm.getLocations().size()>0){
+ //濡傛灉鏈夎矾寰勪俊鎭�
+ u.setEndSteps(dm.getPolyline());
+ }
}
+
}
tmpList.add(tt);
if(isNew){//
@@ -463,6 +502,7 @@
TspSolver.DataModel dataModel = new TspSolver.DataModel();
int vehicleNumber1 = lineList.size();//绾胯矾鏁伴噺
long[] vehicleCapacities1=new long[lineList.size()];//姣忚締杞︾殑鏈�澶ц鍗曢噺闄愬埗
+ long[] vehicleMaxNodes=new long[lineList.size()];//姣忚締杞︾殑鏈�澶ц鍗曢噺闄愬埗
long[] demands1 = new long[customerList.size()+1]; //鍚勪釜鐐圭殑璁㈠崟閲�
long[][] distanceMatrix1 = new long[customerList.size()+1][customerList.size()+1];
distanceMatrix1[0][0] = 0;
@@ -488,9 +528,10 @@
}
for (int i = 0; i < lineList.size(); i++) {
vehicleCapacities1[i] = lineList.get(i).getMaxOrder();//姣忚締杞︾殑鏈�澶ц鍗曢噺闄愬埗
+ vehicleMaxNodes[i] =lineList.get(i).getMaxCustomer();//鏈�澶у鎴锋暟
}
//鏋勯�犱紭鍖栨暟鎹ā鍨�
- dataModel.initDataInfo(vehicleNumber1,demands1,vehicleCapacities1,distanceMatrix1);
+ dataModel.initDataInfo(vehicleNumber1,demands1,vehicleCapacities1,distanceMatrix1,vehicleMaxNodes);
TspSolver.startSearch(dataModel);
dealSearchSolution(model,dataModel);
}catch (Exception e){
@@ -553,6 +594,7 @@
TspSolver.DataModel dataModel = new TspSolver.DataModel();
int vehicleNumber1 = 1;//绾胯矾鏁伴噺
long[] vehicleCapacities1=new long[]{line.getMaxOrder()};//姣忚締杞︾殑鏈�澶ц鍗曢噺闄愬埗
+ long[] vehicleMaxNodes=new long[]{line.getMaxCustomer()};//姣忚締杞︾殑鏈�澶ц鍗曢噺闄愬埗
long[] demands1 = new long[customerListParam.size()+1]; //鍚勪釜鐐圭殑璁㈠崟閲�
long[][] distanceMatrix1 = new long[customerListParam.size()+1][customerListParam.size()+1];
distanceMatrix1[0][0] = 0;
@@ -567,7 +609,7 @@
}
}
//鏋勯�犱紭鍖栨暟鎹ā鍨�
- dataModel.initDataInfo(vehicleNumber1,demands1,vehicleCapacities1,distanceMatrix1);
+ dataModel.initDataInfo(vehicleNumber1,demands1,vehicleCapacities1,distanceMatrix1,vehicleMaxNodes);
TspSolver.startSearch(dataModel);
if(dataModel.getSolutions()==null || dataModel.getSolutions().size()==0){
throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"绾胯矾銆�"+line.getLineName()+"銆戣皟鏁村け璐� 锛屾湭鑾峰緱鏈�浼樹氦閫氳鍒掓柟妗堬紒");
@@ -975,7 +1017,7 @@
queryWrapper.eq(JkSketch::getSortnum, pageWrap.getModel().getSortnum());
}
if (pageWrap.getModel().getDateInfo() != null) {
- queryWrapper.eq(JkSketch::getDateInfo, pageWrap.getModel().getDateInfo());
+ queryWrapper.like(JkSketch::getDateInfo, DateUtil.dateToString(pageWrap.getModel().getDateInfo(),"yyyy-MM-dd"));
}
if (pageWrap.getModel().getJobId() != null) {
queryWrapper.eq(JkSketch::getJobId, pageWrap.getModel().getJobId());
@@ -1322,8 +1364,9 @@
.leftJoin(JkLine.class,JkLine::getId,JkSketchLine::getLineId)
.leftJoin(Category.class,Category::getId,JkLine::getCategoryId )
.leftJoin(Cars.class,Cars::getId,JkLine::getCarId)
+ .eq(JkSketch::getIsdeleted,Constants.ZERO)
.and(StringUtils.isNotBlank(telecomLineInfoDTO.getSearchInfo()),i->i.like(Cars::getCode,telecomLineInfoDTO.getSearchInfo()).or().like(JkLine::getName,telecomLineInfoDTO.getSearchInfo()))
- .eq(StringUtils.isNotBlank(telecomLineInfoDTO.getDateInfo()),JkSketch::getDateInfo, telecomLineInfoDTO.getDateInfo())
+ .like(StringUtils.isNotBlank(telecomLineInfoDTO.getDateInfo()),JkSketch::getDateInfo, telecomLineInfoDTO.getDateInfo())
.eq(Objects.nonNull(telecomLineInfoDTO.getCategoryId()),JkLine::getCategoryId, telecomLineInfoDTO.getCategoryId())
.eq(Objects.nonNull(telecomLineInfoDTO.getLineId()),JkLine::getId, telecomLineInfoDTO.getLineId());
@@ -1367,10 +1410,11 @@
telecomLineCountVO.setCustomerNum(Constants.ZERO);
MPJLambdaWrapper<JkSketch> sketchMPJLambdaWrapper = new MPJLambdaWrapper<JkSketch>().selectAll(JkSketch.class )
.selectAs(Category::getName,JkSketch::getCategoryName)
- .select(" ifnull((select count(1) from jk_sketch_customer jc where jc.ISDELETED= 0 and jc.SKETCH_ID = t.id),0)" ,JkSketch::getCustomerNum)
+ .select(" ifnull((select count(1) from jk_sketch_customer jc where jc.ISDELETED = 0 and jc.SKETCH_ID = t.id),0)" ,JkSketch::getCustomerNum)
.select(" ifnull((select count(1) from jk_sketch_line jc where jc.TYPE = 0 and jc.SKETCH_ID = t.id),0)" ,JkSketch::getBeforeLineNum)
.leftJoin(Category.class,Category::getId,JkSketch::getCategoryId )
- .eq(JkSketch::getDateInfo, telecomLineInfoDTO.getDateInfo());
+ .eq(JkSketch::getIsdeleted,Constants.ZERO)
+ .like(JkSketch::getDateInfo, telecomLineInfoDTO.getDateInfo());
List<JkSketch> sketchList = jkSketchMapper.selectJoinList(JkSketch.class,sketchMPJLambdaWrapper);
if(CollectionUtils.isEmpty(sketchList)){
return telecomLineCountVO;
@@ -1396,10 +1440,10 @@
TelecomCategoryDataVO telecomCategoryDataVO = new TelecomCategoryDataVO();
telecomCategoryDataVO.setId(jkSketch.getCategoryId());
telecomCategoryDataVO.setName(jkSketch.getCategoryName());
- telecomCategoryDataVO.setCustomerNum(jkSketch.getCustomerNum());
+ telecomCategoryDataVO.setCustomerNum(Constants.ZERO);
List<JkSketchLine> childLineList = jkSketchLineList.stream().filter(i->Constants.equalsInteger(i.getSketchId(),jkSketch.getId())).collect(Collectors.toList());
//浼樺寲鍓嶆暟鎹�
- List<JkSketchLine> beforeList = childLineList.stream()
+ List<JkSketchLine> beforeList = jkSketchLineList.stream()
.filter(i->Constants.equalsInteger(i.getType(),Constants.ZERO)).collect(Collectors.toList());
//浼樺寲鍚庢暟鎹�
List<JkSketchLine> afterList = childLineList.stream()
@@ -1408,15 +1452,11 @@
lineNum = lineNum + (Constants.equalsInteger(jkSketch.getOptStatus(),Constants.ZERO)?beforeList.size():afterList.size());
List<TelecomLineDataVO> telecomLineDataVOList = new ArrayList<>();
for (JkSketchLine sketchLine: Constants.equalsInteger(jkSketch.getOptStatus(),Constants.ZERO)?beforeList:afterList) {
-// JkSketchLine finalSketchLine = sketchLine;
-// List<JkSketchLine> afterSelectList = afterList.stream().filter(i->Constants.equalsInteger(i.getLineId(), finalSketchLine.getLineId())).collect(Collectors.toList());
-// if(afterSelectList.size()>Constants.ZERO){
-// sketchLine = afterSelectList.get(Constants.ZERO);
-// }
TelecomLineDataVO telecomLineDataVO = new TelecomLineDataVO();
telecomLineDataVO.setId(sketchLine.getId());
telecomLineDataVO.setName(sketchLine.getLineName());
telecomLineDataVOList.add(telecomLineDataVO);
+ telecomCategoryDataVO.setCustomerNum(telecomCategoryDataVO.getCustomerNum() + sketchLine.getMaxCustomer());
telecomLineCountVO.setCustomerNum(
telecomLineCountVO.getCustomerNum() + sketchLine.getMaxCustomer()
);
@@ -1439,7 +1479,8 @@
MPJLambdaWrapper<JkSketch> sketchMPJLambdaWrapper = new MPJLambdaWrapper<JkSketch>().selectAll(JkSketch.class )
.selectAs(Category::getName,JkSketch::getCategoryName)
.leftJoin(Category.class,Category::getId,JkSketch::getCategoryId )
- .eq(JkSketch::getDateInfo, telecomLineInfoDTO.getDateInfo());
+ .eq(JkSketch::getIsdeleted,Constants.ZERO)
+ .like(JkSketch::getDateInfo, telecomLineInfoDTO.getDateInfo());
List<JkSketch> sketchList = jkSketchMapper.selectJoinList(JkSketch.class,sketchMPJLambdaWrapper);
if(CollectionUtils.isEmpty(sketchList)){
return new ArrayList<TelecomCategoryDataVO>();
@@ -1503,7 +1544,7 @@
.eq(Objects.nonNull(telecomLineInfoDTO.getCategoryId()),JkSketchLine::getCategoryId,telecomLineInfoDTO.getCategoryId())
.eq(Objects.nonNull(telecomLineInfoDTO.getLineId()),JkSketchLine::getLineId,telecomLineInfoDTO.getLineId())
.apply(" ( t.TYPE = t1.OPT_STATUS ) ")
- .eq(JkSketch::getDateInfo, telecomLineInfoDTO.getDateInfo());
+ .like(JkSketch::getDateInfo, telecomLineInfoDTO.getDateInfo());
List<JkSketchLine> returnLineList = jkSketchLineMapper.selectJoinList(JkSketchLine.class,queryWrapper);
// //浼樺寲鍓嶆暟鎹�
--
Gitblit v1.9.3