| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import netscape.javascript.JSObject; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | * @date 2025/09/28 09:01 |
| | | */ |
| | | @Service |
| | | @Slf4j |
| | | public class JkSketchServiceImpl implements JkSketchService { |
| | | |
| | | @Autowired |
| | | private JkSketchMapper jkSketchMapper; |
| | | @Autowired |
| | | private CategoryMapper categoryMapper; |
| | | @Autowired |
| | | private JkSketchLineMapper jkSketchLineMapper; |
| | | @Autowired |
| | |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"该线路订åéè´§éè¶
è¿äºçº¿è·¯æ»éè´§ééå¶ï¼æ æ³è¿è¡ä¼åï¼"); |
| | | } |
| | | model.setLineList(lineList);//线路éå |
| | | model.setCustomerList(checkJketchCustomerLocation(model));//订åéå |
| | | model.setCustomerList(checkJketchCustomerLocation(model,false));//订åéå |
| | | model.setStatus(Constants.ONE); |
| | | model.setPlanLineNum(lineList.size()); |
| | | model.setEditDate(new Date()); |
| | |
| | | jkSketchMapper.updateById(model); |
| | | return model; |
| | | } |
| | | @Override |
| | | public JkSketch initOriginDistance(JkSketch jkSketch ) { |
| | | JkSketch model = jkSketchMapper.selectById(jkSketch.getId()); |
| | | if(model == null ||Constants.equalsInteger(model.getIsdeleted(),Constants.ONE)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY); |
| | | } |
| | | if(!Constants.equalsInteger(model.getStatus(),Constants.ZERO) ){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"该线路已被ä¼åï¼å·²æ æ³è®¡ç®åå§è·¯çº¿è·¯ç¨æ°"); |
| | | } |
| | | checkJketchCustomerLocation(model,true); |
| | | model.setEditDate(new Date()); |
| | | model.setEditor(jkSketch.getLoginUserInfo().getId()); |
| | | model.setDistance(model.getOriginDistance()); |
| | | jkSketchMapper.updateById(model); |
| | | return model; |
| | | } |
| | | |
| | | @Override |
| | | @Async |
| | | public void distanceCustomer( Category cate) { |
| | | try { |
| | | 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); |
| | | BigDecimal cLongitude =new BigDecimal(0); |
| | | |
| | | String location = systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.COMPANY_LOCATION).getCode(); |
| | | try { |
| | | String[] ss = location.split(","); |
| | | cLongitude = new BigDecimal(ss[0]); |
| | | 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){ |
| | | |
| | | } |
| | | } |
| | | |
| | | }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) { |
| | | List<JkCustomer> updateCustomerList = new ArrayList<>(); |
| | | List<JkCustomerNavigation> navigationList = new ArrayList<>(); |
| | | List<DistanceMapParam> tmpList = new ArrayList<>(); |
| | | List<DistanceMapParam> distanceMapParamList = getListFromJsonStr(c.getDistance()); |
| | | boolean isNew = false; |
| | | JkCustomer u =new JkCustomer(); |
| | | DistanceMapParam t0 = new DistanceMapParam(); |
| | | 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()); |
| | | } |
| | | } |
| | | tmpList.add(t0); |
| | | for(JkCustomer cm : customerList){ |
| | | //客æ·å客æ·ä¹é´çè·ç¦»ä¿¡æ¯ |
| | | DistanceMapParam t = new DistanceMapParam(); |
| | | t.setId(cm.getId()); |
| | | DistanceMapParam param = getParamByCustomerIds( cm.getId(),distanceMapParamList); |
| | | if(param!=null){//妿ä¹åå·²ç»è·åè¿ |
| | | t = param; |
| | | }else{ |
| | | JkCustomerNavigation navigation = new JkCustomerNavigation(); |
| | | navigation.setStartId(c.getId()); |
| | | navigation.setEndId(cm.getId()); |
| | | navigation.setIsdeleted(Constants.ZERO); |
| | | navigation.setCreateDate(date); |
| | | navigation.setEditDate(date); |
| | | navigation.setEndLatitude(cm.getLatitude()); |
| | | navigation.setEndLogitude(cm.getLongitude()); |
| | | navigation.setStartLatitude(c.getLatitude()); |
| | | navigation.setStartLogitude(c.getLongitude()); |
| | | isNew = true; |
| | | if(Constants.equalsInteger(c.getId(),cm.getId())){ |
| | | t.setDistance(0l); |
| | | }else{ |
| | | DistanceCustomerModel dm = DistanceCalculator.calculateDistanceGaode(url,c,cm); |
| | | t.setDistance(dm.getDistance() ); |
| | | if(dm.getLocations().size()>0){ |
| | | //妿æè·¯å¾ä¿¡æ¯ |
| | | navigation.setSteps(dm.getPolyline()); |
| | | } |
| | | } |
| | | navigation.setIdIndex(c.getId()+"-"+cm.getId()); |
| | | navigation.setDistance(t.getDistance()); |
| | | navigationList.add(navigation); |
| | | } |
| | | tmpList.add(t); |
| | | } |
| | | DistanceMapParam tt = new DistanceMapParam(); |
| | | tt.setId(-2);//表示è¿åååº |
| | | tt.setDistance(Constants.formatLongNum(c.getEndDistance())); |
| | | if(Constants.formatLongNum(c.getEndDistance()) <= 0){ |
| | | //该客æ·è¿åååºçè·ç¦» ,妿ä¹åæªè·åè¿ |
| | | isNew = true; |
| | | JkCustomer start = new JkCustomer(); |
| | | 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()); |
| | | } |
| | | } |
| | | tmpList.add(tt); |
| | | if(isNew){// |
| | | u.setDistanceStatus(Constants.ONE); |
| | | u.setId(c.getId()); |
| | | u.setDistance(JSONObject.toJSONString(tmpList)); |
| | | updateCustomerList.add(u); |
| | | } |
| | | if(updateCustomerList.size()>0){ |
| | | for(JkCustomer c1 : updateCustomerList){ |
| | | jkCustomerMapper.updateById(c1);//æ´æ°å®¢æ·ä¸å
¶ä»ç¹ä¹é´çè·ç¦» |
| | | } |
| | | } |
| | | if(navigationList.size()>0){ |
| | | jkCustomerNavigationMapper.delete(new UpdateWrapper<JkCustomerNavigation>().lambda() |
| | | .eq(JkCustomerNavigation::getStartId,c.getId()));//å é¤å岿°æ® |
| | | jkCustomerNavigationMapper.insert(navigationList);//æå
¥ææ°æ°æ® |
| | | } |
| | | } |
| | | |
| | | private List<JkCustomer> checkNeedDistanceDo( List<JkCustomer> customerList) { |
| | | if(customerList==null || customerList.size()==0){ |
| | | return null; |
| | | } |
| | | boolean need = false; |
| | | List<JkCustomer> list = new ArrayList<>(); |
| | | for(JkCustomer jk : customerList){ |
| | | if(Constants.equalsInteger(jk.getDistanceStatus(),Constants.ZERO)){ |
| | | need = true; |
| | | list.add(jk); |
| | | } |
| | | } |
| | | if(!need){//妿æ éè¿è¡å¤ç |
| | | return null; |
| | | } |
| | | return list; |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public Category checkDataValid(JkSketch model) { |
| | | if(model.getCategoryId() == null){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | MPJLambdaWrapper<Category> queryWrapper = new MPJLambdaWrapper<>(); |
| | | queryWrapper.selectAll(Category.class ) |
| | | .eq(Category::getIsdeleted,Constants.ZERO) |
| | | .eq(Category::getType,Constants.FOUR) |
| | | .eq(Category::getId,model.getCategoryId() ); |
| | | Category c = categoryMapper.selectJoinOne(Category.class,queryWrapper); |
| | | if(c==null){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY); |
| | | } |
| | | if(Constants.equalsInteger(c.getStatus(),Constants.TWO)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"该主线æ£å¨è¿è¡å®¢æ·è·ç¦»è®¡ç®ä»»å¡ï¼è¯·èå¿çå¾
ä»»å¡å®æï¼"); |
| | | } |
| | | |
| | | MPJLambdaWrapper<JkCustomer> queryWrapper1 = new MPJLambdaWrapper<>(); |
| | | queryWrapper1.selectAll(JkCustomer.class ) |
| | | .leftJoin(JkLine.class,JkLine::getId,JkCustomer::getLineId) |
| | | .eq(JkCustomer::getIsdeleted,Constants.ZERO) |
| | | .eq(JkLine::getCategoryId,model.getCategoryId() ); |
| | | List<JkCustomer> customerList = jkCustomerMapper.selectJoinList(JkCustomer.class,queryWrapper1); |
| | | List<JkCustomer> needList =checkNeedDistanceDo(customerList); |
| | | if(needList == null || needList.size() == 0){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"è¯¥ä¸»çº¿ä¸æ éè¦è¿è¡è·ç¦»è®¡ç®ç客æ·ä¿¡æ¯ï¼"); |
| | | } |
| | | String errorMsg =""; |
| | | for(JkCustomer c1 : customerList){ |
| | | if(c1.getLatitude()==null || c1.getLongitude() ==null){ |
| | | errorMsg += c.getName()+"-"+c.getName()+" | "; |
| | | } |
| | | } |
| | | if(StringUtils.isNotBlank(errorMsg)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"该线路客æ·:ã"+errorMsg+"ãå®ä½ä¿¡æ¯ä¸å®æ´ï¼ä¸æ»¡è¶³è·ç¦»è®¡ç®æ¡ä»¶ï¼"); |
| | | } |
| | | c.setStatus(Constants.TWO); |
| | | categoryMapper.updateById(c);//æ´æ°ä»»å¡æ§è¡ç¶æ |
| | | c.setCustomerList(customerList); |
| | | return c; |
| | | } |
| | | @Override |
| | | @Async |
| | | public void startUpdateLineAsync(JkSketch model) { |
| | | try { |
| | | initCustomerDistance(model); |
| | | List<JkSketchCustomer> customerList = model.getCustomerList(); |
| | | List<JkLine> lineList = model.getLineList(); |
| | | TspSolver.DataModel dataModel = new TspSolver.DataModel(); |
| | |
| | | |
| | | } |
| | | |
| | | private void initCustomerDistance(JkSketch model) { |
| | | String url = systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.GAODE_DISTANCE_GEOAPI_URL).getCode(); |
| | | List<JkCustomer> updateCustomerList = new ArrayList<>(); |
| | | List<JkCustomerNavigation> navigationList = new ArrayList<>(); |
| | | private void initCustomerDistance( List<JkSketchLine> lineList,JkSketch model,boolean updateLineDistance) { |
| | | List<JkSketchCustomer> customerList = model.getCustomerList(); |
| | | |
| | | 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(","); |
| | | 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()); |
| | | boolean isNew = false; |
| | | JkCustomer u =new JkCustomer(); |
| | | DistanceMapParam t0 = new DistanceMapParam(); |
| | | t0.setId(-2);//表示è¿åååº |
| | | t0.setDistance(Constants.formatLongNum(c.getStartDistance()) ); |
| | | if(Constants.formatLongNum(c.getStartDistance()) <= 0){ |
| | | //ååºåå¾è¯¥å®¢æ·çè·ç¦»ï¼å¦æä¹åæªè·åè¿ |
| | | isNew = true; |
| | | JkSketchCustomer start = new JkSketchCustomer(); |
| | | start.setId(-1); |
| | | start.setLongitude(cLongitude); |
| | | start.setLatitude(cLatitude); |
| | | DistanceModel 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()); |
| | | } |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"该线路客æ·:"+c.getName()+"交éè§åå°æªå®æï¼ä¸æ»¡è¶³ä¼åæ¡ä»¶ï¼"); |
| | | } |
| | | tmpList.add(t0); |
| | | for(JkSketchCustomer cm : customerList){ |
| | | //客æ·å客æ·ä¹é´çè·ç¦»ä¿¡æ¯ |
| | | DistanceMapParam t = new DistanceMapParam(); |
| | | t.setId(cm.getId()); |
| | | DistanceMapParam param = getParamByCustomerIds( cm.getId(),distanceMapParamList); |
| | | t.setId(cm.getCustomerId()); |
| | | DistanceMapParam param = getParamByCustomerIds( cm.getCustomerId(),distanceMapParamList); |
| | | if(param!=null){//妿ä¹åå·²ç»è·åè¿ |
| | | t = param; |
| | | }else{ |
| | | JkCustomerNavigation navigation = new JkCustomerNavigation(); |
| | | navigation.setStartId(c.getId()); |
| | | navigation.setEndId(cm.getId()); |
| | | navigation.setIsdeleted(Constants.ZERO); |
| | | navigation.setCreateDate(date); |
| | | navigation.setEditDate(date); |
| | | navigation.setEndLatitude(cm.getLatitude()); |
| | | navigation.setEndLogitude(cm.getLongitude()); |
| | | navigation.setStartLatitude(c.getLatitude()); |
| | | navigation.setStartLogitude(c.getLongitude()); |
| | | isNew = true; |
| | | if(Constants.equalsInteger(c.getCustomerId(),cm.getCustomerId())){ |
| | | t.setDistance(0l); |
| | | }else{ |
| | | DistanceModel dm = DistanceCalculator.calculateDistanceGaode(url,c,cm); |
| | | t.setDistance(dm.getDistance() ); |
| | | if(dm.getLocations().size()>0){ |
| | | //妿æè·¯å¾ä¿¡æ¯ |
| | | navigation.setSteps(dm.getPolyline()); |
| | | } |
| | | } |
| | | navigation.setIdIndex(c.getId()+"-"+cm.getId()); |
| | | navigation.setDistance(t.getDistance()); |
| | | navigationList.add(navigation); |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"该线路客æ·:"+c.getName()+"交éè§åå°æªå®æï¼ä¸æ»¡è¶³è·¯ç¨è®¡ç®æ¡ä»¶ï¼"); |
| | | } |
| | | tmpList.add(t); |
| | | } |
| | |
| | | tt.setDistance(Constants.formatLongNum(c.getEndDistance())); |
| | | if(Constants.formatLongNum(c.getEndDistance()) <= 0){ |
| | | //该客æ·è¿åååºçè·ç¦» ,妿ä¹åæªè·åè¿ |
| | | isNew = true; |
| | | JkSketchCustomer start = new JkSketchCustomer(); |
| | | start.setId(-1); |
| | | start.setLongitude(cLongitude); |
| | | start.setLatitude(cLatitude); |
| | | |
| | | DistanceModel 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()); |
| | | } |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"该线路客æ·:"+c.getName()+"交éè§åå°æªå®æï¼ä¸æ»¡è¶³è·¯ç¨è®¡ç®æ¡ä»¶ï¼"); |
| | | } |
| | | tmpList.add(tt); |
| | | if(isNew){// |
| | | u.setId(c.getCustomerId()); |
| | | u.setDistance(JSONObject.toJSONString(tmpList)); |
| | | updateCustomerList.add(u); |
| | | } |
| | | c.setDistanceMapParamList(tmpList); |
| | | } |
| | | if(updateCustomerList.size()>0){ |
| | | for(JkCustomer c : updateCustomerList){ |
| | | jkCustomerMapper.updateById(c);//æ´æ°å®¢æ·ä¸å
¶ä»ç¹ä¹é´çè·ç¦» |
| | | if(lineList!=null){ |
| | | long totalDistance = 0; |
| | | for (JkSketchLine line :lineList){ |
| | | long lineDistance = 0; |
| | | List<JkSketchCustomer> customers = getCustomerListByLineId(line.getId(),customerList); |
| | | for(JkSketchCustomer c : customers){ |
| | | lineDistance+= Constants.formatLongNum(c.getStartDistance()); |
| | | lineDistance+= Constants.formatLongNum(c.getEndDistance()); |
| | | for(JkSketchCustomer cm : customers){ |
| | | DistanceMapParam param = getParamByCustomerIds( cm.getCustomerId(),getListFromJsonStr(c.getDistanceJson())); |
| | | lineDistance += param.getDistance(); |
| | | } |
| | | } |
| | | if(updateLineDistance && Constants.equalsInteger(model.getStatus(),Constants.ZERO) ){ |
| | | line.setDistance(lineDistance); |
| | | jkSketchLineMapper.updateById(line); |
| | | } |
| | | totalDistance += lineDistance; |
| | | } |
| | | if(Constants.equalsInteger(model.getStatus(),Constants.ZERO) ||Constants.formatLongNum(model.getOriginDistance()) <= 0l ){ |
| | | //妿馿¬¡ä¼åæè
ä¹å没æè®¡ç®è¿ï¼è®¾ç½®ä¼åååå§è·¯å¾ |
| | | model.setOriginDistance(totalDistance); |
| | | } |
| | | } |
| | | if(navigationList.size()>0){ |
| | | jkCustomerNavigationMapper.insert(navigationList); |
| | | } |
| | | |
| | | private List<JkSketchCustomer> getCustomerListByLineId(Integer id, List<JkSketchCustomer> customerList) { |
| | | List<JkSketchCustomer> list = new ArrayList<>(); |
| | | for (JkSketchCustomer c :customerList){ |
| | | if(Constants.equalsInteger(c.getSketchLineId(),id)){ |
| | | list.add(c); |
| | | } |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | private DistanceMapParam getParamByCustomerIds( Integer id1, List<DistanceMapParam> distanceMapParamList) { |
| | |
| | | } |
| | | } |
| | | |
| | | private List<JkSketchCustomer> checkJketchCustomerLocation(JkSketch model) { |
| | | private List<JkSketchCustomer> checkJketchCustomerLocation(JkSketch model,boolean updateLineDistance) { |
| | | MPJLambdaWrapper<JkSketchCustomer> queryWrapper = new MPJLambdaWrapper<>(); |
| | | queryWrapper.selectAll(JkSketchCustomer.class ) |
| | | .selectAs(JkCustomer::getName,JkSketchCustomer::getName) |
| | | .selectAs(JkCustomer::getCode,JkSketchCustomer::getCode) |
| | | .selectAs(JkCustomer::getDistanceStatus,JkSketchCustomer::getDistanceStatus) |
| | | .selectAs(JkCustomer::getDistance,JkSketchCustomer::getDistanceJson) |
| | | .selectAs(JkCustomer::getLongitude,JkSketchCustomer::getLongitude) |
| | | .selectAs(JkCustomer::getLatitude,JkSketchCustomer::getLatitude) |
| | |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"该线路客æ·ä¿¡æ¯ä¸ºç©ºï¼ä¸æ»¡è¶³ä¼åæ¡ä»¶ï¼"); |
| | | } |
| | | String errorMsg =""; |
| | | String errorMsg1 =""; |
| | | for(JkSketchCustomer c : customerList){ |
| | | if(c.getLatitude()==null || c.getLongitude() ==null){ |
| | | errorMsg += c.getName()+"-"+c.getName()+"ï¼"; |
| | | errorMsg += c.getName()+"-"+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+"å®ä½ä¿¡æ¯ä¸å®æ´ï¼ä¸æ»¡è¶³ä¼åæ¡ä»¶ï¼"); |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"该线路客æ·:ã"+errorMsg+"ãå®ä½ä¿¡æ¯ä¸å®æ´ï¼ä¸æ»¡è¶³ä¼åæ¡ä»¶ï¼"); |
| | | } |
| | | /* for(JkSketchCustomer c : customerList){ |
| | | List<Map<String,Object>> tmpList = new ArrayList<>(); |
| | | for(JkSketchCustomer cm : customerList){ |
| | | Map<String,Object> t = new HashMap<>(); |
| | | t.put("a",cm.getId()); |
| | | if(Constants.equalsInteger(c.getCustomerId(),cm.getCustomerId())){ |
| | | t.put("b",0l); |
| | | }else{ |
| | | t.put("b", DistanceCalculator.calculateDistance( |
| | | Constants.formatBigdecimal(c.getLatitude()).doubleValue(), |
| | | Constants.formatBigdecimal(c.getLongitude()).doubleValue(), |
| | | Constants.formatBigdecimal(cm.getLatitude()).doubleValue(), |
| | | Constants.formatBigdecimal(cm.getLongitude()).doubleValue())); |
| | | } |
| | | tmpList.add(t); |
| | | } |
| | | c.setDistanceList(tmpList); |
| | | if(StringUtils.isNotBlank(errorMsg1)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"该线路客æ·:ã"+errorMsg1+"ã交éè§åå°æªå®æï¼ä¸æ»¡è¶³ä¼åæ¡ä»¶ï¼"); |
| | | } |
| | | */ |
| | | /*if(Constants.equalsInteger(Constants.ZERO,model.getStatus())){ |
| | | //å¦ææ¯æªä¼åç¶æï¼è®¡ç®åå§è·ç¦» |
| | | long totalDistance = 0; |
| | | MPJLambdaWrapper<JkSketchLine> queryWrapper1 = new MPJLambdaWrapper<>(); |
| | | queryWrapper1.selectAll(JkSketchLine.class ) |
| | | .eq(JkSketchLine::getSketchId, model.getId()) |
| | | .eq(JkSketchLine::getIsdeleted,Constants.ZERO); |
| | | List<JkSketchLine> lineList = jkSketchLineMapper.selectJoinList(JkSketchLine.class,queryWrapper1);// |
| | | if(lineList!=null ||lineList.size()>0){ |
| | | double cLatitude =0; |
| | | double cLongitude =0; |
| | | String location = systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.COMPANY_LOCATION).getCode(); |
| | | try { |
| | | String[] ss = location.split(","); |
| | | cLongitude = Double.parseDouble(ss[0]); |
| | | cLatitude = Double.parseDouble(ss[1]); |
| | | }catch (Exception e){ |
| | | |
| | | } |
| | | for(JkSketchLine line : lineList){ |
| | | boolean isFirst =true; |
| | | JkSketchCustomer last = null; |
| | | for(JkSketchCustomer c : customerList){ |
| | | if(Constants.equalsInteger(c.getSketchLineId(),line.getId())){ |
| | | if(isFirst){ |
| | | totalDistance += DistanceCalculator.calculateDistance(cLatitude,cLongitude |
| | | ,Constants.formatBigdecimal(c.getLatitude()).doubleValue() |
| | | ,Constants.formatBigdecimal(c.getLongitude()).doubleValue()); |
| | | }else{ |
| | | totalDistance += DistanceCalculator.calculateDistance( |
| | | Constants.formatBigdecimal(c.getLatitude()).doubleValue() |
| | | ,Constants.formatBigdecimal(c.getLongitude()).doubleValue() |
| | | ,Constants.formatBigdecimal(last.getLatitude()).doubleValue() |
| | | ,Constants.formatBigdecimal(last.getLongitude()).doubleValue()); |
| | | } |
| | | last = c; |
| | | isFirst=false; |
| | | } |
| | | if(last!=null){ |
| | | totalDistance += DistanceCalculator.calculateDistance(cLatitude,cLongitude |
| | | ,Constants.formatBigdecimal(last.getLatitude()).doubleValue() |
| | | ,Constants.formatBigdecimal(last.getLongitude()).doubleValue()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | model.setOriginDistance(totalDistance); |
| | | }*/ |
| | | |
| | | model.setCustomerList(customerList); |
| | | MPJLambdaWrapper<JkSketchLine> queryWrapper1 = new MPJLambdaWrapper<>(); |
| | | queryWrapper1.selectAll(JkSketchLine.class ) |
| | | .eq(JkSketchLine::getSketchId, model.getId()) |
| | | .eq(JkSketchLine::getIsdeleted,Constants.ZERO) |
| | | .orderByAsc(JkSketchLine::getSortnum); |
| | | List<JkSketchLine> lineList = jkSketchLineMapper.selectJoinList(JkSketchLine.class,queryWrapper1); |
| | | initCustomerDistance(lineList,model,updateLineDistance); |
| | | return customerList; |
| | | } |
| | | |
| | |
| | | QueryWrapper<JkSketch> wrapper = new QueryWrapper<>(jkSketch); |
| | | return jkSketchMapper.selectCount(wrapper); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class,BusinessException.class}) |
| | | public List<JkSketch> importBatch(MultipartFile file, String dateInfoStr, LoginUserInfo loginUser){ |
| | |
| | | if(newOrderList.size()>0){ |
| | | jkOrdersMapper.insert(newOrderList); |
| | | } |
| | | |
| | | List<JkSketchLine> sketchLineList = initNewSketchLineList(newList,newOrderList,lineList); |
| | | jkSketchLineMapper.update(null,new UpdateWrapper<JkSketchLine>().lambda() |
| | | .set(JkSketchLine::getIsdeleted,Constants.ONE) |
| | |
| | | if(sketchLineList.size()>0){ |
| | | jkSketchLineMapper.insert(sketchLineList); |
| | | } |
| | | |
| | | List<JkSketchCustomer> sketchCuustomerList = initNewSketchCustomerList(sketchLineList,newOrderList);//æç
§ä¸»çº¿è·¯åç» |
| | | jkSketchCustomerMapper.update(null,new UpdateWrapper<JkSketchCustomer>().lambda() |
| | | .set(JkSketchCustomer::getIsdeleted,Constants.ONE) |
| | |
| | | list.add(tModel); |
| | | } |
| | | } |
| | | /*for(JkOrders orders : newOrderList){ |
| | | JkSketchLine tModel = findModelFromListByLineId(orders.getLineId(),list); |
| | | if(tModel!=null){ |
| | | tModel.setTotalNum( tModel.getTotalNum().add(orders.getNum()));//订åé累计 |
| | | tModel.setOrderNum(tModel.getOrderNum()+1);//å®¢æ·æ°å 1 |
| | | }else{ |
| | | tModel = new JkSketchLine(); |
| | | tModel.setSketchId(getSKetchIdByyCategoryId(orders.getCategoryId(),newList)); |
| | | tModel.setCreator(orders.getCreator()); |
| | | tModel.setCreateDate(orders.getCreateDate()); |
| | | tModel.setLineId(orders.getLineId()); |
| | | tModel.setTotalNum(orders.getNum()); |
| | | tModel.setOrderNum(1); |
| | | tModel.setDateInfo(orders.getDateInfo()); |
| | | tModel.setSortnum(list.size()+1); |
| | | tModel.setEditDate(tModel.getCreateDate()); |
| | | tModel.setEditor(tModel.getCreator()); |
| | | tModel.setIsdeleted(Constants.ZERO); |
| | | if(tModel.getSketchId()!=null){ |
| | | list.add(tModel); |
| | | } |
| | | } |
| | | }*/ |
| | | |
| | | return list; |
| | | } |
| | | |