From e6604f327adb238274dc7a1fc14892916e2d6a92 Mon Sep 17 00:00:00 2001
From: doum <doum>
Date: 星期五, 06 三月 2026 09:56:50 +0800
Subject: [PATCH] 最新版本541200007

---
 server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/JkSketchServiceImpl.java |   84 ++++++++++++-----------------------------
 1 files changed, 25 insertions(+), 59 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 a2c4051..29fecf8 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
@@ -129,7 +129,8 @@
         if(Constants.equalsInteger(Constants.ZERO,jkSketch.getForceUpdate()) && Constants.equalsInteger(model.getStatus(),Constants.ONE)){
             throw  new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"璇ョ嚎璺瓨鍦ㄦ鍦ㄤ紭鍖栦腑锛岃鑰愬績绛夊緟浼樺寲瀹屾垚鎴栬�呴�夋嫨寮哄埗浼樺寲鎿嶄綔锛�");
         }
-        if( jkSketch.getLineIdList() ==null || jkSketch.getLineIdList().size()==0 ){
+
+        if(  jkSketch.getLineIdList() ==null || jkSketch.getLineIdList().size()==0 ){
             throw  new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"璇烽�夋嫨鏈夋晥鍚堢悊鐨勭嚎璺繘琛屼紭鍖栨搷浣滐紒");
         }
         //褰撳墠鎵�鏈夌嚎璺�(绗﹀悎鏉′欢鐨勭嚎璺級
@@ -255,8 +256,7 @@
     @Async
     public  void distanceCustomer( Category cate) {
         try {
-            List<JkCustomer> allList = cate.getCustomerList();
-            List<JkCustomer> customerList = cate.getNeedList();
+            List<JkCustomer> customerList = cate.getCustomerList();
             String url = systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.GAODE_DISTANCE_GEOAPI_URL).getCode();
             Date date = new Date();
             BigDecimal cLatitude =new BigDecimal(0);
@@ -288,7 +288,7 @@
                         for (int j = start; j < end; j++) {
                             try {
                                 log.error("浜ら�氳鍒�========"+cate.getId()+"/"+cate.getName()+"/"+customerList.get(j).getName()+"=======cirle/index:"+finalI+"/"+index++);
-                                dealDistancePerCustomer(customerList.get(j),url,date, finalCLatitude, finalCLongitude,allList);
+                                dealDistancePerCustomer(customerList.get(j),url,date, finalCLatitude, finalCLongitude,customerList);
                             }catch (Exception e){
 
                             }
@@ -429,10 +429,8 @@
             }
         }
         if(navigationList.size()>0){
-            for (JkCustomerNavigation navigation:navigationList) {
-                jkCustomerNavigationMapper.delete(new UpdateWrapper<JkCustomerNavigation>().lambda()
-                        .eq(JkCustomerNavigation::getIdIndex,navigation.getIdIndex()));//鍒犻櫎鍘嗗彶鏁版嵁
-            }
+            jkCustomerNavigationMapper.delete(new UpdateWrapper<JkCustomerNavigation>().lambda()
+                    .eq(JkCustomerNavigation::getStartId,c.getId()));//鍒犻櫎鍘嗗彶鏁版嵁
             jkCustomerNavigationMapper.insert(navigationList);//鎻掑叆鏈�鏂版暟鎹�
         }
     }
@@ -495,8 +493,7 @@
         }
         c.setStatus(Constants.TWO);
         categoryMapper.updateById(c);//鏇存柊浠诲姟鎵ц鐘舵��
-        c.setCustomerList(customerList);
-        c.setNeedList(Constants.equalsInteger(model.getForceUpdate(),0)?needList:customerList);
+        c.setCustomerList(Constants.equalsInteger(model.getForceUpdate(),0)?needList:customerList);
         return  c;
     }
 
@@ -704,15 +701,6 @@
 
     private void initCustomerDistance( List<JkSketchLine> lineList,JkSketch model,boolean updateLineDistance) {
         List<JkSketchCustomer> customerList = model.getCustomerList();
-        BigDecimal cLatitude =new BigDecimal(0);
-        BigDecimal cLongitude =new BigDecimal(0);
-        String comLocation = systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.COMPANY_LOCATION).getCode();
-        try {
-            String[] ss = comLocation.split(",");
-            cLongitude = new BigDecimal(ss[0]);
-            cLatitude =  new BigDecimal(ss[1]);
-        }catch (Exception e){
-        }
         for(JkSketchCustomer c : customerList){
             List<DistanceMapParam> tmpList = new ArrayList<>();
             List<DistanceMapParam> distanceMapParamList  = getListFromJsonStr(c.getDistanceJson());
@@ -721,21 +709,18 @@
             t0.setDistance(Constants.formatLongNum(c.getStartDistance()) );
             if(Constants.formatLongNum(c.getStartDistance()) <= 0){
                 //鍥尯鍓嶅線璇ュ鎴风殑璺濈锛屽鏋滀箣鍓嶆湭鑾峰彇杩�
-                t0.setDistance(DistanceCalculator.calculateDistanceDecinal(cLatitude,cLongitude,c.getLatitude(),c.getLongitude()));
-//                throw  new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"璇ョ嚎璺鎴�:"+c.getName()+"浜ら�氳鍒掑皻鏈畬鎴愶紝涓嶆弧瓒充紭鍖栨潯浠讹紒");
+                throw  new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"璇ョ嚎璺鎴�:"+c.getName()+"浜ら�氳鍒掑皻鏈畬鎴愶紝涓嶆弧瓒充紭鍖栨潯浠讹紒");
             }
             tmpList.add(t0);
             for(JkSketchCustomer cm : customerList){
                 //瀹㈡埛鍜屽鎴蜂箣闂寸殑璺濈淇℃伅
                 DistanceMapParam t = new DistanceMapParam();
                 t.setId(cm.getCustomerId());
-                 DistanceMapParam param = getParamByCustomerIds( cm.getCustomerId(),distanceMapParamList);
-                if(param!=null && t.getDistance()>0){//濡傛灉涔嬪墠宸茬粡鑾峰彇杩�
+                DistanceMapParam param = getParamByCustomerIds( cm.getCustomerId(),distanceMapParamList);
+                if(param!=null){//濡傛灉涔嬪墠宸茬粡鑾峰彇杩�
                     t = param;
                 }else{
-                    //濡傛灉鏈鍒掞紝鎸夌収鐩寸嚎璺濈
-                    t.setDistance(DistanceCalculator.calculateDistanceDecinal(cm.getLatitude(),cm.getLongitude(),c.getLatitude(),c.getLongitude()));
-//                    throw  new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"璇ョ嚎璺鎴�:"+c.getName()+"涓庡鎴�:"+cm.getName()+"绠�浜ら�氳鍒掑皻鏈畬鎴愶紝涓嶆弧瓒宠矾绋嬭绠楁潯浠讹紒");
+                    throw  new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"璇ョ嚎璺鎴�:"+c.getName()+"浜ら�氳鍒掑皻鏈畬鎴愶紝涓嶆弧瓒宠矾绋嬭绠楁潯浠讹紒");
                 }
                 tmpList.add(t);
             }
@@ -744,8 +729,7 @@
             tt.setDistance(Constants.formatLongNum(c.getEndDistance()));
             if(Constants.formatLongNum(c.getEndDistance()) <= 0){
                 //璇ュ鎴疯繑鍥炲洯鍖虹殑璺濈 ,濡傛灉涔嬪墠鏈幏鍙栬繃
-                tt.setDistance(DistanceCalculator.calculateDistanceDecinal(cLatitude,cLongitude,c.getLatitude(),c.getLongitude()));
-//                throw  new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"璇ョ嚎璺鎴�:"+c.getName()+"涓庤捣鐐逛氦閫氳鍒掑皻鏈畬鎴愶紝涓嶆弧瓒宠矾绋嬭绠楁潯浠讹紒");
+                throw  new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"璇ョ嚎璺鎴�:"+c.getName()+"浜ら�氳鍒掑皻鏈畬鎴愶紝涓嶆弧瓒宠矾绋嬭绠楁潯浠讹紒");
             }
             tmpList.add(tt);
             c.setDistanceMapParamList(tmpList);
@@ -758,27 +742,14 @@
                 int index =0;
                 for(JkSketchCustomer c : customers){
                     if(index ==0){
-                        if(c.getStartDistance() >0){
-                            lineDistance+= Constants.formatLongNum(c.getStartDistance());
-                        }else{
-                            lineDistance += DistanceCalculator.calculateDistanceDecinal(c.getLatitude(),c.getLongitude(),cLatitude,cLongitude);
-                        }
+                        lineDistance+= Constants.formatLongNum(c.getStartDistance());
                     }
                     if(index == customers.size()-1){
-                        if(c.getEndDistance() >0){
-                            lineDistance+= Constants.formatLongNum(c.getEndDistance());
-                        }else{
-                            lineDistance += DistanceCalculator.calculateDistanceDecinal(c.getLatitude(),c.getLongitude(),cLatitude,cLongitude);
-                        }
+                        lineDistance+= Constants.formatLongNum(c.getEndDistance());
                         break;
                     }
-                    JkSketchCustomer end = customers.get(index+1);
-                    DistanceMapParam param1 = getParamByCustomerIds(end.getCustomerId(),getListFromJsonStr(c.getDistanceJson()));
-                    if(param1 !=null && param1.getDistance()>0){
-                        lineDistance += param1.getDistance();
-                    }else{
-                        lineDistance += DistanceCalculator.calculateDistanceDecinal(c.getLatitude(),c.getLongitude(),end.getLatitude(),end.getLongitude());
-                    }
+                    DistanceMapParam param = getParamByCustomerIds( customers.get(index+1).getCustomerId(),getListFromJsonStr(c.getDistanceJson()));
+                    lineDistance += param.getDistance();
                     index++;
                   /*  for(JkSketchCustomer cm : customers){
                         DistanceMapParam param = getParamByCustomerIds( cm.getCustomerId(),getListFromJsonStr(c.getDistanceJson()));
@@ -808,7 +779,7 @@
         return list;
     }
 
-    public static DistanceMapParam getParamByCustomerIds(  Integer id1, List<DistanceMapParam> distanceMapParamList) {
+    private DistanceMapParam getParamByCustomerIds(  Integer id1, List<DistanceMapParam> distanceMapParamList) {
         if(distanceMapParamList!=null){
             for(DistanceMapParam p :distanceMapParamList){
                 if(Constants.equalsInteger(p.getId(),id1)){
@@ -820,7 +791,7 @@
         return null;
     }
 
-    public static List<DistanceMapParam> getListFromJsonStr(String distanceJson) {
+    private List<DistanceMapParam> getListFromJsonStr(String distanceJson) {
         try {
             return  JSONObject.parseObject(distanceJson, new TypeReference<List<DistanceMapParam>>(){}.getType());
         }catch (Exception e){
@@ -952,11 +923,11 @@
         String errorMsg1 ="";
         for(JkSketchCustomer c : customerList){
             if(c.getLatitude()==null || c.getLongitude() ==null){
-                errorMsg +=  c.getName()+" | ";
+                errorMsg += c.getName()+"-"+c.getName()+" | ";
             }
-        /*    if(!Constants.equalsInteger(c.getDistanceStatus(),Constants.ONE)){
-                errorMsg1 +=  c.getName()+" | ";
-            }*/
+            if(!Constants.equalsInteger(c.getDistanceStatus(),Constants.ONE)){
+                errorMsg1 += c.getName()+"-"+c.getName()+" | ";
+            }
         }
         if(StringUtils.isNotBlank(errorMsg)){
             throw  new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"璇ョ嚎璺鎴�:銆�"+errorMsg+"銆戝畾浣嶄俊鎭笉瀹屾暣锛屼笉婊¤冻浼樺寲鏉′欢锛�");
@@ -1484,8 +1455,7 @@
                     .filter(i->Constants.equalsInteger(i.getType(),Constants.ZERO)).collect(Collectors.toList());
             //浼樺寲鍚庢暟鎹�
             List<JkSketchLine> afterList = childLineList.stream()
-                    .filter(i->Constants.equalsInteger(i.getType(),Constants.ONE)
-                            && Constants.equalsInteger(i.getIsdeleted(),Constants.ZERO)).collect(Collectors.toList());
+                    .filter(i->Constants.equalsInteger(i.getType(),Constants.ONE)&&Constants.equalsInteger(i.getIsdeleted(),Constants.ZERO)).collect(Collectors.toList());
 
             lineNum = lineNum + (Constants.equalsInteger(jkSketch.getOptStatus(),Constants.ZERO)?beforeList.size():afterList.size());
             List<TelecomLineDataVO> telecomLineDataVOList = new ArrayList<>();
@@ -1542,9 +1512,7 @@
                 telecomCategoryDataVO.setName(jkSketch.getCategoryName());
                 //浼樺寲鍓嶆暟鎹�
                 List<JkSketchLine> beforeList = jkSketchLineList.stream()
-                        .filter(i->Constants.equalsInteger(i.getSketchId(),jkSketch.getId())
-                                && Objects.nonNull(i.getDistance())
-                                &&Constants.equalsInteger(i.getType(),Constants.ZERO)).collect(Collectors.toList());
+                        .filter(i->Constants.equalsInteger(i.getSketchId(),jkSketch.getId())&&Constants.equalsInteger(i.getType(),Constants.ZERO)).collect(Collectors.toList());
                 telecomCategoryDataVO.setDistance(
                         beforeList.stream().map(i->i.getDistance()).reduce(Long.valueOf(0),Long::sum)
                 );
@@ -1553,9 +1521,7 @@
                 }else{
                     //浼樺寲鍚庢暟鎹�
                     List<JkSketchLine> afterList = jkSketchLineList.stream()
-                            .filter(i->Constants.equalsInteger(i.getSketchId(),jkSketch.getId())
-                                    && Objects.nonNull(i.getDistance())
-                                    &&Constants.equalsInteger(i.getType(),Constants.ONE)&&Constants.equalsInteger(i.getIsdeleted(),Constants.ZERO)).collect(Collectors.toList());
+                            .filter(i->Constants.equalsInteger(i.getSketchId(),jkSketch.getId())&&Constants.equalsInteger(i.getType(),Constants.ONE)&&Constants.equalsInteger(i.getIsdeleted(),Constants.ZERO)).collect(Collectors.toList());
 
                     Long distanceAfter = 0L;
                     for (JkSketchLine jkSketchLine:afterList) {

--
Gitblit v1.9.3