Commit d3893e9c authored by 曹云霄's avatar 曹云霄

优化路线绘制

parent f603834e
......@@ -147,6 +147,7 @@
[self.invoiceView addGestureRecognizer:[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(invoiceViewClickAction:)]];
//初始化
_geographicSearch = [[BMKGeoCodeSearch alloc]init];
_routesearch = [[BMKRouteSearch alloc]init];
self.locService = [[BMKLocationService alloc]init];
[self.locService startUserLocationService];
self.mapView = [[BMKMapView alloc]initWithFrame:CGRectMake(0, 0, self.view.mj_w, self.view.mj_h-44-64)];
......@@ -249,6 +250,13 @@
#pragma mark -路径规划
- (void)startDrawWayPointRoutepointArray:(NSArray *)arrays
{
//删除无坐标的门店
NSMutableArray *locationArray = [NSMutableArray array];
for (BusbillDtl *model in arrays) {
if ([model.customerLng length] && [model.customerLat length]) {
[locationArray addObject:model];
}
}
UserInforMation *user = [UserInforMation manager];
//起点
BMKPlanNode* start = [[BMKPlanNode alloc]init];
......@@ -256,9 +264,8 @@
start.cityName = user.driverAddress.city;
start.pt = CLLocationCoordinate2DMake(user.depotLatitude, user.depotLongitude);
//途径点
NSMutableArray *array = [NSMutableArray array];
[arrays enumerateObjectsUsingBlock:^(id _Nonnull object, NSUInteger index, BOOL * _Nonnull stop) {
[locationArray enumerateObjectsUsingBlock:^(id _Nonnull object, NSUInteger index, BOOL * _Nonnull stop) {
BusbillDtl *model = (BusbillDtl *)object;
BMKPlanNode* wayPointItem = [[BMKPlanNode alloc]init];
......@@ -266,7 +273,6 @@
wayPointItem.cityName = user.driverAddress.city;
CLLocationCoordinate2D pt = CLLocationCoordinate2DMake([model.customerLat doubleValue], [model.customerLng doubleValue]);
wayPointItem.pt = pt;
[array addObject:wayPointItem];
}];
BMKDrivingRoutePlanOption *drivingRouteSearchOption = [[BMKDrivingRoutePlanOption alloc]init];
......@@ -543,6 +549,9 @@
[orderDetails setRefreshListDatasBlock:^{
[weakSelf queryOrderBillDatasAndDepotInforMation];
}];
[orderDetails setRefreshPinStateBlock:^(NSArray *pinArray) {
[weakSelf startDrawWayPointRoutepointArray:pinArray];
}];
self.invoiceDetailsView = orderDetails.view;
self.invoiceDetailsView.frame = CGRectMake(0, self.view.mj_h, ScreenSize.width, orderDetails.view.mj_h);
[self addChildViewController:orderDetails];
......@@ -586,7 +595,7 @@
weakSelf.selecteOrderBill = order;
[weakSelf turnoffListButtonClickAction];
weakSelf.invoiceInformationlabel.text = [NSString stringWithFormat:@"%@(单号:%@)",order.busInfo,order.billNumber];
[weakSelf startDrawWayPointRoutepointArray:order.dtls];
[weakSelf sortingCoordinates:order.billNumber];
}];
self.orderListView = orderList.view;
self.orderListView.frame = CGRectMake(0, self.view.mj_h, ScreenSize.width, orderList.view.mj_h);
......@@ -611,5 +620,40 @@
}
#pragma mark - 绘点排序
- (void)sortingCoordinates:(NSString *)orderBillNumber
{
WS(weakSelf);
[self CreateMBProgressHUDLoding:@"计算路径中"];
NSString *urlString = [NSString stringWithFormat:SERVERREQUESTURL(ORDERSORTING),orderBillNumber,@"depot"];
NSString *utf8String = [urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[[NetworkRequestClassManager Manager] NetworkWithDictionaryRequestWithURL:utf8String WithRequestType:NetworkRequestWithGET WithParameter:nil WithReturnValueBlock:^(id returnValue) {
[weakSelf RemoveMBProgressHUDLoding];
if ([returnValue[@"code"] isEqualToNumber:@0]) {
NSMutableArray *sortingArray = [NSMutableArray array];
for (NSDictionary *dict in returnValue[@"data"]) {
BusbillDtl *details = [[BusbillDtl alloc]init];
details.customerLng = dict[@"lng"];
details.customerLat = dict[@"lat"];
details.customerName = dict[@"name"];
[sortingArray addObject:details];
}
[weakSelf startDrawWayPointRoutepointArray:sortingArray];
}else
{
[weakSelf SHOWPrompttext:returnValue[@"message"]];
}
} WithErrorCodeBlock:^(id errorCodeValue) {
[weakSelf RemoveMBProgressHUDLoding];
[weakSelf SHOWPrompttext:NETWORK];
} WithFailureBlock:^(NSError *error) {
[weakSelf RemoveMBProgressHUDLoding];
[weakSelf SHOWPrompttext:error.description];
}];
}
@end
......@@ -31,4 +31,9 @@
*/
@property (nonatomic,copy) void(^refreshListDatasBlock)();
/**
* 刷新大头针数据
*/
@property (nonatomic,copy) void(^refreshPinStateBlock)(NSArray *details);
@end
......@@ -9,7 +9,7 @@
#import "OrderDetailsViewController.h"
#import "OrderDetailsTableViewCell.h"
#define FINISH @"1"
#define FINISH @"已完成"
@interface OrderDetailsViewController ()<UITableViewDelegate,UITableViewDataSource>
......@@ -24,6 +24,7 @@
- (void)viewDidLoad {
[super viewDidLoad];
self.orderDetailsTableview.tableFooterView = [UIView new];
[self uiConfigAction];
}
......@@ -49,7 +50,12 @@
{
OrderDetailsTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"OrderDetailsTableViewCell" forIndexPath:indexPath];
BusbillDtl *model = self.orderDetails.dtls[indexPath.row];
cell.storeTitleLabel.text = model.customerName;
if (![model.customerLng length]&& ![model.customerLat length]) {
cell.storeTitleLabel.text = [NSString stringWithFormat:@"%@ (暂无GPS数据)",model.customerName];
}else
{
cell.storeTitleLabel.text = model.customerName;
}
if ([model.state isEqualToString:FINISH]) {
[cell.arriveButton setTitle:@"送货完成" forState:UIControlStateNormal];
[cell.arriveButton setTitleColor:RGBA(129, 196, 56, 1) forState:UIControlStateNormal];
......@@ -62,6 +68,7 @@
[cell.arriveButton setBackgroundColor:[UIColor redColor]];
cell.arriveButton.enabled = YES;
}
cell.storeAddressLabel.text = model.customerAddress;
cell.arriveButton.tag = indexPath.row;
[cell.arriveButton addTarget:self action:@selector(arriveButtonClickAction:) forControlEvents:UIControlEventTouchUpInside];
return cell;
......@@ -77,25 +84,23 @@
return 60;
}
#pragma mark - 确认送达
#pragma mark - 更新送货单某一详情状态
- (void)arriveButtonClickAction:(UIButton *)sender
{
WS(weakSelf);
BusbillDtl *model = self.orderDetails.dtls[sender.tag];
[self CreateMBProgressHUDLoding:@"加载中"];
NSString *urlString = [NSString stringWithFormat:SERVERREQUESTURL(ORDERDETAILSSTATE),model.fid,@"1"];
[[NetworkRequestClassManager Manager] NetworkWithDictionaryRequestWithURL:urlString WithRequestType:NetworkRequestWithPOST WithParameter:nil WithReturnValueBlock:^(id returnValue) {
NSString *urlString = [NSString stringWithFormat:SERVERREQUESTURL(ORDERDETAILSSTATE),model.fid,FINISH];
NSString *UTF8String = [urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[[NetworkRequestClassManager Manager] NetworkWithDictionaryRequestWithURL:UTF8String WithRequestType:NetworkRequestWithPOST WithParameter:nil WithReturnValueBlock:^(id returnValue) {
[weakSelf RemoveMBProgressHUDLoding];
if ([returnValue[@"code"] isEqualToNumber:@0]) {
model.state = @"1";
model.state = FINISH;
[sender setTitle:@"送货完成" forState:UIControlStateNormal];
[sender setTitleColor:RGBA(129, 196, 56, 1) forState:UIControlStateNormal];
[sender setBackgroundColor:[UIColor whiteColor]];
sender.enabled = NO;
if (weakSelf.refreshListDatasBlock) {
weakSelf.refreshListDatasBlock();
}
[weakSelf refreshDeliveryOrderState];
}else{
[weakSelf SHOWPrompttext:returnValue[@"message"]];
......@@ -109,22 +114,29 @@
}];
}
#pragma mark - 更新送货单状态
#pragma mark - 更新送货单列表
- (void)refreshDeliveryOrderState
{
NSString *orderState = FINISH;
for (BusbillDtl *model in self.orderDetails.dtls) {
if (![model.state isEqualToString:FINISH]) {
return;
orderState = @"送货中";break;
}
}
//更新状态
[self uiConfigAction];
WS(weakSelf);
NSString *urlString = [NSString stringWithFormat:SERVERREQUESTURL(REFRESHORDERSTATE),self.orderDetails.billNumber,@"1"];
[[NetworkRequestClassManager Manager] NetworkWithDictionaryRequestWithURL:urlString WithRequestType:NetworkRequestWithPOST WithParameter:nil WithReturnValueBlock:^(id returnValue) {
NSString *urlString = [NSString stringWithFormat:SERVERREQUESTURL(REFRESHORDERSTATE),self.orderDetails.billNumber,orderState];
NSString *UTF8String = [urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[[NetworkRequestClassManager Manager] NetworkWithDictionaryRequestWithURL:UTF8String WithRequestType:NetworkRequestWithPOST WithParameter:nil WithReturnValueBlock:^(id returnValue) {
if ([returnValue[@"code"] isEqualToNumber:@0]) {
if (weakSelf.refreshListDatasBlock) {
weakSelf.refreshListDatasBlock();
}
if (weakSelf.refreshPinStateBlock) {
weakSelf.refreshPinStateBlock(self.orderDetails.dtls);
}
}else
{
[weakSelf SHOWPrompttext:returnValue[@"message"]];
......
......@@ -20,6 +20,7 @@
- (void)viewDidLoad {
[super viewDidLoad];
self.orderTableView.tableFooterView = [UIView new];
[self uiConfigAction];
}
......@@ -47,7 +48,9 @@
OrderListTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"OrderListTableViewCell" forIndexPath:indexPath];
Busbill *model = self.datasArray[indexPath.row];
cell.orderBillStateLabel.text = model.state;
cell.orderBillStateLabel.textColor = [self returnColorFromOrderBillState:model.state];
cell.orderTitleLabel.text = [NSString stringWithFormat:@"单号:%@",model.billNumber];
return cell;
}
......@@ -76,4 +79,29 @@
}
}
#pragma mark - 通过状态返回不同的颜色
- (UIColor *)returnColorFromOrderBillState:(NSString *)state
{
UIColor *color = nil;
if ([state isEqualToString:@"已完成"]) {
color = [UIColor greenColor];
}else if ([state isEqualToString:@"送货中"]){
color = MainColor;
}else if ([state isEqualToString:@"未出货"])
{
color = [UIColor redColor];
}
return color;
}
@end
Palmwms/Palmwms/Images.xcassets/orderbill.imageset/orderbill.png

313 Bytes | W: 0px | H: 0px

Palmwms/Palmwms/Images.xcassets/orderbill.imageset/orderbill.png

2.95 KB | W: 0px | H: 0px

  • 2-up
  • Swipe
  • Onion skin
Palmwms/Palmwms/Images.xcassets/orderbill.imageset/orderbill@2x.png

546 Bytes | W: 0px | H: 0px

Palmwms/Palmwms/Images.xcassets/orderbill.imageset/orderbill@2x.png

4.69 KB | W: 0px | H: 0px

  • 2-up
  • Swipe
  • Onion skin
Palmwms/Palmwms/Images.xcassets/orderbill.imageset/orderbill@3x.png

1.15 KB | W: 0px | H: 0px

Palmwms/Palmwms/Images.xcassets/orderbill.imageset/orderbill@3x.png

12.2 KB | W: 0px | H: 0px

  • 2-up
  • Swipe
  • Onion skin
......@@ -521,14 +521,14 @@
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="张三百货" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="ryA-Yg-G3c">
<rect key="frame" x="12" y="9" width="206" height="21"/>
<rect key="frame" x="12" y="9" width="260" height="21"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="15"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="上海市联航路店" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="0VZ-gm-JKC">
<rect key="frame" x="12" y="32" width="206" height="21"/>
<rect key="frame" x="12" y="32" width="260" height="21"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="13"/>
<color key="textColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
......@@ -537,6 +537,7 @@
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="jsI-w3-AlX">
<rect key="frame" x="280" y="13" width="87" height="35"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<state key="normal" title="送货到达">
<color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</state>
......@@ -638,7 +639,7 @@
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="rB4-PK-a2j">
<rect key="frame" x="292.5" y="19" width="66.5" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="15"/>
<fontDescription key="fontDescription" type="system" weight="medium" pointSize="17"/>
<color key="textColor" red="0.2901960784" green="0.57254901960000004" blue="0.93725490199999995" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
......@@ -702,7 +703,7 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="EAK-MO-QVL">
<rect key="frame" x="20" y="352" width="30" height="30"/>
<rect key="frame" x="20" y="459" width="40" height="40"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" red="0.91372549020000005" green="0.91764705879999997" blue="0.92156862750000001" alpha="1" colorSpace="calibratedRGB"/>
<state key="normal" backgroundImage="orderbill"/>
......@@ -770,7 +771,7 @@
<image name="headerBackground" width="360" height="306"/>
<image name="icon" width="23" height="24"/>
<image name="logo" width="114" height="62"/>
<image name="orderbill" width="32" height="32"/>
<image name="orderbill" width="75" height="76"/>
<image name="orederDetails" width="27" height="27"/>
<image name="refresh" width="83" height="82"/>
<image name="turnoff" width="38" height="38"/>
......
......@@ -186,6 +186,12 @@ extern NSString * const QUERYORDERDIRECTION_DESC;
*
*/
@property (nonatomic, copy) NSString *state;
/**
* 客户地址
*
*
*/
@property (nonatomic, copy) NSString *customerAddress;
@end /* interface BusbillDtl */
......@@ -312,6 +318,24 @@ extern NSString * const QUERYORDERDIRECTION_DESC;
*
*/
@property (nonatomic, copy) NSString *lat;
/**
* 更新人名称
*
*
*/
@property (nonatomic, copy) NSString *updateName;
/**
* 更新人登录名称
*
*
*/
@property (nonatomic, copy) NSString *updateBy;
/**
* 更新日期
*
*
*/
@property (nonatomic, copy) NSString *updateDate;
@end /* interface Customer */
......
......@@ -35,6 +35,7 @@
@synthesize customerLng;
@synthesize customerLat;
@synthesize state;
@synthesize customerAddress;
+(BOOL)propertyIsOptional:(NSString*)propertyName
{
......@@ -91,6 +92,9 @@ NSString * const QUERYORDERDIRECTION_DESC = @"desc";
@synthesize address;
@synthesize lng;
@synthesize lat;
@synthesize updateName;
@synthesize updateBy;
@synthesize updateDate;
+(BOOL)propertyIsOptional:(NSString*)propertyName
{
......
......@@ -65,7 +65,10 @@
*/
#define REFRESHORDERSTATE @"busbill/updateState?billNumber=%@&state=%@"
/**
* 发货单坐标排序
*/
#define ORDERSORTING @"route/getByBillnumber/{billNumber}?billNumber=%@&code=%@"
......
......@@ -4,7 +4,7 @@ import requests
#configuration for iOS build setting
CODE_SIGN_IDENTITY = "iPhone Distribution: Shanghai Gomore Information Technology Co.,Ltd"
PROVISIONING_PROFILE = "df541a2c-b94a-4874-904a-04e7843bc5ab"
PROVISIONING_PROFILE = "3f85aed4-daef-463f-be40-80512d051d3a"
CONFIGURATION = "Release"
SDK = "iphoneos"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment