package com.prolog.rdc.tms.app.service.flow.handle;

import com.google.common.collect.Lists;
import com.prolog.framework.core.exception.BizException;
import com.prolog.rdc.tms.app.constant.DataDictionaryConstant;
import com.prolog.rdc.tms.app.constant.SeriaNnumberConstant;
import com.prolog.rdc.tms.app.constant.enums.SignInStatusEnum;
import com.prolog.rdc.tms.app.model.entity.ShipbillNodeTracking;
import com.prolog.rdc.tms.app.model.entity.TmsLoadingBillDetailModel;
import com.prolog.rdc.tms.app.model.entity.TmsLoadingBillHeaderModel;
import com.prolog.rdc.tms.app.model.entity.TmsShipbillHeaderModel;
import com.prolog.rdc.tms.app.model.entity.TmsShipbillOperateLogModel;
import com.prolog.rdc.tms.app.model.entity.TmsShipbillTransLogModel;
import com.prolog.rdc.tms.app.service.flow.FlowContext;
import com.prolog.rdc.tms.app.service.flow.FlowNodeHandle;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * 退货运单调度
 * @author hongbo.pan
 * @date 2022/10/17
 */
@Component
public class ReturnShipBillDispatchHandle extends FlowNodeHandle {

    @Override
    public void doHandle(FlowContext context) {
        if (!DataDictionaryConstant.SHIPBILL_STATUS_REVIEW.equals(context.getTmsShipBillHeaderModel().getStatus())) {
            throw new BizException("运单状态不是已审核，shipBillId=" + context.getTmsShipBillHeaderModel().getShipbillId());
        }
        TmsShipbillHeaderModel tmsShipbillHeaderModel = context.getTmsShipBillHeaderModel();
        tmsShipbillHeaderModel.setStatus(DataDictionaryConstant.SHIPBILL_STATUS_DISPATCH);
        tmsShipbillHeaderModel.setUpdateperson(context.getUserEntity().getNickname());
        tmsShipbillHeaderModel.setUpdatetime(new Date());
        tmsShipbillHeaderMapper.update(tmsShipbillHeaderModel);
        context.setTmsShipBillHeaderModel(tmsShipbillHeaderModel);

        TmsLoadingBillHeaderModel tmsLoadingBillHeaderModel = initTmsLoadingBillHeaderModel(context);

        tmsLoadingBillHeaderModel.setScanStatus(DataDictionaryConstant.SCAN_STATUS_INIT);
        tmsLoadingBillHeaderMapper.save(tmsLoadingBillHeaderModel);
        context.setTmsLoadingBillHeaderModel(tmsLoadingBillHeaderModel);
        TmsLoadingBillDetailModel tmsLoadingBillDetailModel = initTmsLoadingBillDetailModel(context, tmsLoadingBillHeaderModel);
        tmsLoadingBillDetailMapper.save(tmsLoadingBillDetailModel);
        context.setTmsLoadingBillDetailModelList(Lists.newArrayList(tmsLoadingBillDetailModel));
    }

    @Override
    public String getFlowNode() {
        return DataDictionaryConstant.FLOW_CONFIG_DISPATCH;
    }

    @Override
    public ShipbillNodeTracking buildShipBillNodeTracking() {
        ShipbillNodeTracking shipbillNodeTracking = new ShipbillNodeTracking();
        shipbillNodeTracking.setStatus(DataDictionaryConstant.SHIPBILL_STATUS_DISPATCH);
        shipbillNodeTracking.setNodeEvent(DataDictionaryConstant.SHIPBILL_NODE_STATUSNAME_DI);
        return shipbillNodeTracking;
    }

    @Override
    public TmsShipbillOperateLogModel buildShipBillOperateLog() {
        TmsShipbillOperateLogModel tmsShipbillOperateLogModel = new TmsShipbillOperateLogModel();
        tmsShipbillOperateLogModel.setOperateEvent(DataDictionaryConstant.SHIPBILL_NODE_STATUSNAME_DI);
        tmsShipbillOperateLogModel.setOldStatus(DataDictionaryConstant.SHIPBILL_STATUS_REVIEW);
        tmsShipbillOperateLogModel.setNewStatus(DataDictionaryConstant.SHIPBILL_STATUS_DISPATCH);
        return tmsShipbillOperateLogModel;
    }

    @Override
    public TmsShipbillTransLogModel buildShipBillTransLog() {
        TmsShipbillTransLogModel tmsShipbillTransLogModel = new TmsShipbillTransLogModel();
        tmsShipbillTransLogModel.setDisDt(new Date());
        return tmsShipbillTransLogModel;
    }

    private TmsLoadingBillHeaderModel initTmsLoadingBillHeaderModel(FlowContext context) {
        
        TmsLoadingBillHeaderModel tmsLoadingBillHeaderModel = new TmsLoadingBillHeaderModel();
        String loadingBillId = mainDataProxy.getCodeNumberByCode(SeriaNnumberConstant.TMS_LOADING_BILL_HEADER_ID);
        tmsLoadingBillHeaderModel.setLoadingBillId(loadingBillId);
        tmsLoadingBillHeaderModel.setLoadingBillNo(loadingBillId);
        tmsLoadingBillHeaderModel.setLoadingBillDate(new Date());
//        tmsLoadingBillHeaderModel.setBranchId(context.getOriginalTmsLoadingBillHeaderModel().getBranchId());
//        tmsLoadingBillHeaderModel.setBranchCode(context.getOriginalTmsLoadingBillHeaderModel().getBranchCode());
//        tmsLoadingBillHeaderModel.setBranchName(context.getOriginalTmsLoadingBillHeaderModel().getBranchName());
//        tmsLoadingBillHeaderModel.setGroupName(context.getOriginalTmsLoadingBillHeaderModel().getGroupName());
        tmsLoadingBillHeaderModel.setLoadingBillType(context.getOriginalTmsLoadingBillHeaderModel().getLoadingBillType());
        tmsLoadingBillHeaderModel.setScheduleType(DataDictionaryConstant.SCHEDULE_TYPE_ZY);
        tmsLoadingBillHeaderModel.setCarrierType(context.getOriginalTmsLoadingBillHeaderModel().getCarrierType());
        tmsLoadingBillHeaderModel.setCarrierId(context.getOriginalTmsLoadingBillHeaderModel().getCarrierId());
        tmsLoadingBillHeaderModel.setCarrierCode(context.getOriginalTmsLoadingBillHeaderModel().getCarrierCode());
        tmsLoadingBillHeaderModel.setCarrierName(context.getOriginalTmsLoadingBillHeaderModel().getCarrierName());
        tmsLoadingBillHeaderModel.setDriverId(context.getOriginalTmsLoadingBillHeaderModel().getDriverId());
        tmsLoadingBillHeaderModel.setDriverCode(context.getOriginalTmsLoadingBillHeaderModel().getDriverCode());
        tmsLoadingBillHeaderModel.setDriverName(context.getOriginalTmsLoadingBillHeaderModel().getDriverName());
        tmsLoadingBillHeaderModel.setDriverPhoneNumber(context.getOriginalTmsLoadingBillHeaderModel().getDriverPhoneNumber());
        tmsLoadingBillHeaderModel.setViceDriverId(context.getOriginalTmsLoadingBillHeaderModel().getViceDriverId());
        tmsLoadingBillHeaderModel.setViceDriverCode(context.getOriginalTmsLoadingBillHeaderModel().getViceDriverCode());
        tmsLoadingBillHeaderModel.setViceDriverName(context.getOriginalTmsLoadingBillHeaderModel().getViceDriverName());
        tmsLoadingBillHeaderModel.setViceDriverPhoneNumber(context.getOriginalTmsLoadingBillHeaderModel().getViceDriverPhoneNumber());
        tmsLoadingBillHeaderModel.setVehicleId(context.getOriginalTmsLoadingBillHeaderModel().getVehicleId());
        tmsLoadingBillHeaderModel.setVehicleCode(context.getOriginalTmsLoadingBillHeaderModel().getVehicleCode());
        tmsLoadingBillHeaderModel.setVehicleName(context.getOriginalTmsLoadingBillHeaderModel().getVehicleName());
        tmsLoadingBillHeaderModel.setVehiclePlateNumber(context.getOriginalTmsLoadingBillHeaderModel().getVehiclePlateNumber());
        tmsLoadingBillHeaderModel.setVehicleTypeId(context.getOriginalTmsLoadingBillHeaderModel().getVehicleTypeId());
        tmsLoadingBillHeaderModel.setVehicleTypeCode(context.getOriginalTmsLoadingBillHeaderModel().getVehicleTypeCode());
        tmsLoadingBillHeaderModel.setVehicleTypeName(context.getOriginalTmsLoadingBillHeaderModel().getVehicleTypeName());
        tmsLoadingBillHeaderModel.setDeliverymanId(context.getOriginalTmsLoadingBillHeaderModel().getDeliverymanId());
        tmsLoadingBillHeaderModel.setDeliverymanCode(context.getOriginalTmsLoadingBillHeaderModel().getDeliverymanCode());
        tmsLoadingBillHeaderModel.setDeliverymanName(context.getOriginalTmsLoadingBillHeaderModel().getDeliverymanName());
        tmsLoadingBillHeaderModel.setDeliverymanPhoneNumber(context.getOriginalTmsLoadingBillHeaderModel().getDeliverymanPhoneNumber());
        tmsLoadingBillHeaderModel.setViceDeliverymanId(context.getOriginalTmsLoadingBillHeaderModel().getViceDeliverymanId());
        tmsLoadingBillHeaderModel.setViceDeliverymanCode(context.getOriginalTmsLoadingBillHeaderModel().getViceDeliverymanCode());
        tmsLoadingBillHeaderModel.setViceDeliverymanName(context.getOriginalTmsLoadingBillHeaderModel().getViceDeliverymanName());
        tmsLoadingBillHeaderModel.setViceDeliverymanPhoneNumber(context.getOriginalTmsLoadingBillHeaderModel().getViceDeliverymanPhoneNumber());
        tmsLoadingBillHeaderModel.setDeviceType(context.getOriginalTmsLoadingBillHeaderModel().getDeviceType());
        tmsLoadingBillHeaderModel.setDeviceId(context.getOriginalTmsLoadingBillHeaderModel().getDeviceId());
        tmsLoadingBillHeaderModel.setDeviceCode(context.getOriginalTmsLoadingBillHeaderModel().getDeviceCode());
        tmsLoadingBillHeaderModel.setDeviceName(context.getOriginalTmsLoadingBillHeaderModel().getDeviceName());
        tmsLoadingBillHeaderModel.setShipbillNumber(1);
        tmsLoadingBillHeaderModel.setCustomerNumber(1);
        tmsLoadingBillHeaderModel.setSiteNumber(1);
//        tmsLoadingBillHeaderModel.setTotalMileage(BigDecimal.ZERO);
        tmsLoadingBillHeaderModel.setTotalPcs(context.getTmsShipBillHeaderModel().getTotalPcs());
        tmsLoadingBillHeaderModel.setTotalVolume(context.getTmsShipBillHeaderModel().getTotalVolume());
        tmsLoadingBillHeaderModel.setTotalWeight(context.getTmsShipBillHeaderModel().getTotalWeight());
        tmsLoadingBillHeaderModel.setActualTotalPcs(context.getTmsShipBillHeaderModel().getActualTotalPcs());
        tmsLoadingBillHeaderModel.setActualTotalVolume(context.getTmsShipBillHeaderModel().getActualTotalVolume());
        tmsLoadingBillHeaderModel.setActualTotalWeight(context.getTmsShipBillHeaderModel().getActualTotalWeight());
        tmsLoadingBillHeaderModel.setTotalWholePiece(context.getTmsShipBillHeaderModel().getPackageWholePiece());
        tmsLoadingBillHeaderModel.setTotalLclPiece(context.getTmsShipBillHeaderModel().getPackageLclPiece());
//        tmsLoadingBillHeaderModel.setVolumeLoadingRate(context.getOriginalTmsLoadingBillHeaderModel().getVolumeLoadingRate());
//        tmsLoadingBillHeaderModel.setWeightLoadingRate(context.getOriginalTmsLoadingBillHeaderModel().getWeightLoadingRate());
        tmsLoadingBillHeaderModel.setLoadingStartDate(new Date());
        tmsLoadingBillHeaderModel.setLoadingEndDate(new Date());
        tmsLoadingBillHeaderModel.setLoaderId(context.getOriginalTmsLoadingBillHeaderModel().getLoaderId());
        tmsLoadingBillHeaderModel.setLoaderName(context.getOriginalTmsLoadingBillHeaderModel().getLoaderName());
        tmsLoadingBillHeaderModel.setStatus(DataDictionaryConstant.LOADING_BILL_STATUS_WSH);
        tmsLoadingBillHeaderModel.setMemo("系统自动退回" + context.getTmsShipBillHeaderModel().getShipbillId());
        tmsLoadingBillHeaderModel.setOrganizationId(context.getOriginalTmsLoadingBillHeaderModel().getOrganizationId());
        tmsLoadingBillHeaderModel.setOrganizationCode(context.getOriginalTmsLoadingBillHeaderModel().getOrganizationCode());
        tmsLoadingBillHeaderModel.setOrganizationName(context.getOriginalTmsLoadingBillHeaderModel().getOrganizationName());
        tmsLoadingBillHeaderModel.setDepartmentId(context.getOriginalTmsLoadingBillHeaderModel().getDepartmentId());
        tmsLoadingBillHeaderModel.setDepartmentCode(context.getOriginalTmsLoadingBillHeaderModel().getDepartmentCode());
        tmsLoadingBillHeaderModel.setDepartmentName(context.getOriginalTmsLoadingBillHeaderModel().getDepartmentName());
        tmsLoadingBillHeaderModel.setEnterpriseId(context.getOriginalTmsLoadingBillHeaderModel().getEnterpriseId());
        tmsLoadingBillHeaderModel.setEnterpriseName(context.getOriginalTmsLoadingBillHeaderModel().getEnterpriseName());
        tmsLoadingBillHeaderModel.setExtStr1(context.getOriginalTmsLoadingBillHeaderModel().getExtStr1());
        tmsLoadingBillHeaderModel.setExtStr2(context.getOriginalTmsLoadingBillHeaderModel().getExtStr2());
        tmsLoadingBillHeaderModel.setExtStr3(context.getOriginalTmsLoadingBillHeaderModel().getExtStr3());
        tmsLoadingBillHeaderModel.setExtStr4(context.getOriginalTmsLoadingBillHeaderModel().getExtStr4());
        tmsLoadingBillHeaderModel.setExtStr5(context.getOriginalTmsLoadingBillHeaderModel().getExtStr5());
        tmsLoadingBillHeaderModel.setExtNum1(context.getOriginalTmsLoadingBillHeaderModel().getExtNum1());
        tmsLoadingBillHeaderModel.setExtNum2(context.getOriginalTmsLoadingBillHeaderModel().getExtNum2());
        tmsLoadingBillHeaderModel.setExtNum3(context.getOriginalTmsLoadingBillHeaderModel().getExtNum3());
        tmsLoadingBillHeaderModel.setExtNum4(context.getOriginalTmsLoadingBillHeaderModel().getExtNum4());
        tmsLoadingBillHeaderModel.setExtNum5(context.getOriginalTmsLoadingBillHeaderModel().getExtNum5());
        tmsLoadingBillHeaderModel.setExtDate1(context.getOriginalTmsLoadingBillHeaderModel().getExtDate1());
        tmsLoadingBillHeaderModel.setExtDate2(context.getOriginalTmsLoadingBillHeaderModel().getExtDate2());
        tmsLoadingBillHeaderModel.setExtDate3(context.getOriginalTmsLoadingBillHeaderModel().getExtDate3());
        tmsLoadingBillHeaderModel.setExtDate4(context.getOriginalTmsLoadingBillHeaderModel().getExtDate4());
        tmsLoadingBillHeaderModel.setExtDate5(context.getOriginalTmsLoadingBillHeaderModel().getExtDate5());
        tmsLoadingBillHeaderModel.setCreatetime(new Date());
        tmsLoadingBillHeaderModel.setCreateperson(context.getUserEntity().getNickname());
        tmsLoadingBillHeaderModel.setUpdatetime(new Date());
        tmsLoadingBillHeaderModel.setUpdateperson(context.getUserEntity().getNickname());
        tmsLoadingBillHeaderModel.setPickupStations(1L);
        tmsLoadingBillHeaderModel.setDeliveryStations(1L);
        tmsLoadingBillHeaderModel.setTotalStations(2L);
        tmsLoadingBillHeaderModel.setSignInStatus(SignInStatusEnum.NOT_SIGN.getCode());
        return tmsLoadingBillHeaderModel;
    }

    private TmsLoadingBillDetailModel initTmsLoadingBillDetailModel(FlowContext context, TmsLoadingBillHeaderModel newLoadingBill) {
        TmsLoadingBillDetailModel tmsLoadingBillDetailModel = new TmsLoadingBillDetailModel();
        String loadingBillDetailId = mainDataProxy.getCodeNumberByCode(SeriaNnumberConstant.TMS_LOADING_BILL_DETAIL_ID);
        tmsLoadingBillDetailModel.setId(loadingBillDetailId);
        tmsLoadingBillDetailModel.setShippingOrder(1);
        tmsLoadingBillDetailModel.setLoadingBillId(newLoadingBill.getLoadingBillId());
        tmsLoadingBillDetailModel.setLoadingBillNo(newLoadingBill.getLoadingBillNo());
        tmsLoadingBillDetailModel.setShipbillId(context.getTmsShipBillHeaderModel().getShipbillId());
        tmsLoadingBillDetailModel.setShipbillNo(context.getTmsShipBillHeaderModel().getShipbillNo());
        tmsLoadingBillDetailModel.setFatherShipbillId(context.getTmsShipBillHeaderModel().getFatherShipbillId());
        tmsLoadingBillDetailModel.setFatherShipbillNo(context.getTmsShipBillHeaderModel().getFatherShipbillNo());
        tmsLoadingBillDetailModel.setOriginalShipbillId(context.getTmsShipBillHeaderModel().getOriginalShipbillId());
        tmsLoadingBillDetailModel.setOriginalShipbillNo(context.getTmsShipBillHeaderModel().getOriginalShipbillNo());
        tmsLoadingBillDetailModel.setBranchId(context.getTmsShipBillHeaderModel().getBranchId());
        tmsLoadingBillDetailModel.setBranchCode(context.getTmsShipBillHeaderModel().getBranchCode());
        tmsLoadingBillDetailModel.setBranchName(context.getTmsShipBillHeaderModel().getBranchName());
        tmsLoadingBillDetailModel.setCargoOwnerId(context.getTmsShipBillHeaderModel().getCargoOwnerId());
        tmsLoadingBillDetailModel.setCargoOwnerCode(context.getTmsShipBillHeaderModel().getCargoOwnerCode());
        tmsLoadingBillDetailModel.setCargoOwnerName(context.getTmsShipBillHeaderModel().getCargoOwnerName());
        tmsLoadingBillDetailModel.setOrderId(context.getTmsShipBillHeaderModel().getOrderId());
        tmsLoadingBillDetailModel.setOrderNo(context.getTmsShipBillHeaderModel().getOrderNo());
        tmsLoadingBillDetailModel.setOrderDate(context.getTmsShipBillHeaderModel().getOrderDate());
        tmsLoadingBillDetailModel.setOrderType(context.getTmsShipBillHeaderModel().getOrderType());
        tmsLoadingBillDetailModel.setOrderBusinessType(context.getTmsShipBillHeaderModel().getOrderBusinessType());
        tmsLoadingBillDetailModel.setWmsOrderId(context.getTmsShipBillHeaderModel().getWmsOrderId());
        tmsLoadingBillDetailModel.setWmsOrderNo(context.getTmsShipBillHeaderModel().getWmsOrderNo());
        tmsLoadingBillDetailModel.setTransportStatus(context.getTmsShipBillHeaderModel().getTransportStatus());
        tmsLoadingBillDetailModel.setAbnormalStatus(context.getTmsShipBillHeaderModel().getAbnormalStatus());
        tmsLoadingBillDetailModel.setSplitOrderStatus(context.getTmsShipBillHeaderModel().getSplitOrderStatus());
        tmsLoadingBillDetailModel.setSplitOrderType(context.getTmsShipBillHeaderModel().getSplitOrderType());
        tmsLoadingBillDetailModel.setCarrierSplitOrderStatus(context.getTmsShipBillHeaderModel().getCarrierSplitOrderStatus());
        tmsLoadingBillDetailModel.setCarrierSplitOrderType(context.getTmsShipBillHeaderModel().getCarrierSplitOrderType());
        tmsLoadingBillDetailModel.setDeliveryMethodType(context.getTmsShipBillHeaderModel().getDeliveryMethodType());
        tmsLoadingBillDetailModel.setTransportType(context.getTmsShipBillHeaderModel().getTransportType());
        tmsLoadingBillDetailModel.setTemperatureRequirement(context.getTmsShipBillHeaderModel().getTemperatureRequirement());
        tmsLoadingBillDetailModel.setEstimatedPickupStartTime(context.getTmsShipBillHeaderModel().getEstimatedPickupStartTime());
        tmsLoadingBillDetailModel.setEstimatedPickupEndTime(context.getTmsShipBillHeaderModel().getEstimatedPickupEndTime());
        tmsLoadingBillDetailModel.setEstimatedDeliveryStartTime(context.getTmsShipBillHeaderModel().getEstimatedDeliveryStartTime());
        tmsLoadingBillDetailModel.setEstimatedDeliveryEndTime(context.getTmsShipBillHeaderModel().getEstimatedDeliveryEndTime());
        tmsLoadingBillDetailModel.setTransportAging(context.getTmsShipBillHeaderModel().getTransportAging());
        tmsLoadingBillDetailModel.setShipperType(context.getTmsShipBillHeaderModel().getShipperType());
        tmsLoadingBillDetailModel.setShipperUnitId(context.getTmsShipBillHeaderModel().getShipperUnitId());
        tmsLoadingBillDetailModel.setShipperUnitCode(context.getTmsShipBillHeaderModel().getShipperUnitCode());
        tmsLoadingBillDetailModel.setShipperUnitName(context.getTmsShipBillHeaderModel().getShipperUnitName());
        tmsLoadingBillDetailModel.setShipperId(context.getTmsShipBillHeaderModel().getShipperId());
        tmsLoadingBillDetailModel.setShipperCode(context.getTmsShipBillHeaderModel().getShipperCode());
        tmsLoadingBillDetailModel.setShipperName(context.getTmsShipBillHeaderModel().getShipperName());
        tmsLoadingBillDetailModel.setShipperContact(context.getTmsShipBillHeaderModel().getShipperContact());
        tmsLoadingBillDetailModel.setShipperPhoneNumber(context.getTmsShipBillHeaderModel().getShipperPhoneNumber());
        tmsLoadingBillDetailModel.setShipperLandlineNumber(context.getTmsShipBillHeaderModel().getShipperLandlineNumber());
        tmsLoadingBillDetailModel.setShipperEmail(context.getTmsShipBillHeaderModel().getShipperEmail());
        tmsLoadingBillDetailModel.setShipperRelatedPhoneNumber(context.getTmsShipBillHeaderModel().getShipperRelatedPhoneNumber());
        tmsLoadingBillDetailModel.setShipperProvince(context.getTmsShipBillHeaderModel().getShipperProvince());
        tmsLoadingBillDetailModel.setShipperProvinceName(context.getTmsShipBillHeaderModel().getShipperProvinceName());
        tmsLoadingBillDetailModel.setShipperCity(context.getTmsShipBillHeaderModel().getShipperCity());
        tmsLoadingBillDetailModel.setShipperCityName(context.getTmsShipBillHeaderModel().getShipperCityName());
        tmsLoadingBillDetailModel.setShipperDistrict(context.getTmsShipBillHeaderModel().getShipperDistrict());
        tmsLoadingBillDetailModel.setShipperDistrictName(context.getTmsShipBillHeaderModel().getShipperDistrictName());
        tmsLoadingBillDetailModel.setShipperAddress(context.getTmsShipBillHeaderModel().getShipperAddress());
        tmsLoadingBillDetailModel.setShipperLongitude(context.getTmsShipBillHeaderModel().getShipperLongitude());
        tmsLoadingBillDetailModel.setShipperLatitude(context.getTmsShipBillHeaderModel().getShipperLatitude());
        tmsLoadingBillDetailModel.setShipperMemo(context.getTmsShipBillHeaderModel().getShipperMemo());
        tmsLoadingBillDetailModel.setShipperPickUpSign(context.getTmsShipBillHeaderModel().getShipperPickUpSign());
        tmsLoadingBillDetailModel.setShipperAutoPickUpSign(context.getTmsShipBillHeaderModel().getShipperAutoPickUpSign());
        tmsLoadingBillDetailModel.setShipperPickUpPicture(context.getTmsShipBillHeaderModel().getShipperPickUpPicture());
        tmsLoadingBillDetailModel.setShipperPickUpRail(context.getTmsShipBillHeaderModel().getShipperPickUpRail());
        tmsLoadingBillDetailModel.setConsigneeType(context.getTmsShipBillHeaderModel().getConsigneeType());
        tmsLoadingBillDetailModel.setConsigneeUnitId(context.getTmsShipBillHeaderModel().getConsigneeUnitId());
        tmsLoadingBillDetailModel.setConsigneeUnitCode(context.getTmsShipBillHeaderModel().getConsigneeUnitCode());
        tmsLoadingBillDetailModel.setConsigneeUnitName(context.getTmsShipBillHeaderModel().getConsigneeUnitName());
        tmsLoadingBillDetailModel.setConsigneeId(context.getTmsShipBillHeaderModel().getConsigneeId());
        tmsLoadingBillDetailModel.setConsigneeCode(context.getTmsShipBillHeaderModel().getConsigneeCode());
        tmsLoadingBillDetailModel.setConsigneeName(context.getTmsShipBillHeaderModel().getConsigneeName());
        tmsLoadingBillDetailModel.setConsigneeContact(context.getTmsShipBillHeaderModel().getConsigneeContact());
        tmsLoadingBillDetailModel.setConsigneePhoneNumber(context.getTmsShipBillHeaderModel().getConsigneePhoneNumber());
        tmsLoadingBillDetailModel.setConsigneeLandlineNumber(context.getTmsShipBillHeaderModel().getConsigneeLandlineNumber());
        tmsLoadingBillDetailModel.setConsigneeEmail(context.getTmsShipBillHeaderModel().getConsigneeEmail());
        tmsLoadingBillDetailModel.setConsigneeRelatedPhoneNumber(context.getTmsShipBillHeaderModel().getConsigneeRelatedPhoneNumber());
        tmsLoadingBillDetailModel.setConsigneeProvince(context.getTmsShipBillHeaderModel().getConsigneeProvince());
        tmsLoadingBillDetailModel.setConsigneeProvinceName(context.getTmsShipBillHeaderModel().getConsigneeProvinceName());
        tmsLoadingBillDetailModel.setConsigneeCity(context.getTmsShipBillHeaderModel().getConsigneeCity());
        tmsLoadingBillDetailModel.setConsigneeCityName(context.getTmsShipBillHeaderModel().getConsigneeCityName());
        tmsLoadingBillDetailModel.setConsigneeDistrict(context.getTmsShipBillHeaderModel().getConsigneeDistrict());
        tmsLoadingBillDetailModel.setConsigneeDistrictName(context.getTmsShipBillHeaderModel().getConsigneeDistrictName());
        tmsLoadingBillDetailModel.setConsigneeAddress(context.getTmsShipBillHeaderModel().getConsigneeAddress());
        tmsLoadingBillDetailModel.setConsigneeLongitude(context.getTmsShipBillHeaderModel().getConsigneeLongitude());
        tmsLoadingBillDetailModel.setConsigneeLatitude(context.getTmsShipBillHeaderModel().getConsigneeLatitude());
        tmsLoadingBillDetailModel.setConsigneeMemo(context.getTmsShipBillHeaderModel().getConsigneeMemo());
        tmsLoadingBillDetailModel.setConsigneeDeliverySign(context.getTmsShipBillHeaderModel().getConsigneeDeliverySign());
        tmsLoadingBillDetailModel.setConsigneeAutoDeliverySign(context.getTmsShipBillHeaderModel().getConsigneeAutoDeliverySign());
        tmsLoadingBillDetailModel.setConsigneeDeliveryPicture(context.getTmsShipBillHeaderModel().getConsigneeDeliveryPicture());
        tmsLoadingBillDetailModel.setConsigneeDeliveryRail(context.getTmsShipBillHeaderModel().getConsigneeDeliveryRail());
        tmsLoadingBillDetailModel.setLineId(context.getTmsShipBillHeaderModel().getLineId());
        tmsLoadingBillDetailModel.setLineCode(context.getTmsShipBillHeaderModel().getLineCode());
        tmsLoadingBillDetailModel.setLineName(context.getTmsShipBillHeaderModel().getLineName());
        tmsLoadingBillDetailModel.setReturnOrderFlag(context.getTmsShipBillHeaderModel().getReturnOrderFlag());
        tmsLoadingBillDetailModel.setReturnOrderDeadline(context.getTmsShipBillHeaderModel().getReturnOrderDeadline());
        tmsLoadingBillDetailModel.setTotalPcs(context.getTmsShipBillHeaderModel().getTotalPcs());
        tmsLoadingBillDetailModel.setTotalVolume(context.getTmsShipBillHeaderModel().getTotalVolume());
        tmsLoadingBillDetailModel.setTotalWeight(context.getTmsShipBillHeaderModel().getTotalWeight());
        tmsLoadingBillDetailModel.setActualTotalPcs(context.getTmsShipBillHeaderModel().getActualTotalPcs());
        tmsLoadingBillDetailModel.setActualTotalVolume(context.getTmsShipBillHeaderModel().getActualTotalVolume());
        tmsLoadingBillDetailModel.setActualTotalWeight(context.getTmsShipBillHeaderModel().getActualTotalWeight());
        tmsLoadingBillDetailModel.setTotalDeliveryPcs(context.getTmsShipBillHeaderModel().getTotalDeliveryPcs());
        tmsLoadingBillDetailModel.setTotalDeliveryVolume(context.getTmsShipBillHeaderModel().getTotalDeliveryVolume());
        tmsLoadingBillDetailModel.setTotalDeliveryWeight(context.getTmsShipBillHeaderModel().getTotalDeliveryWeight());
        tmsLoadingBillDetailModel.setPackageWholePiece(context.getTmsShipBillHeaderModel().getPackageWholePiece());
        tmsLoadingBillDetailModel.setPackageLclPiece(context.getTmsShipBillHeaderModel().getPackageLclPiece());
        tmsLoadingBillDetailModel.setPackageTotalVolume(context.getTmsShipBillHeaderModel().getPackageTotalVolume());
        tmsLoadingBillDetailModel.setPackageTotalWeight(context.getTmsShipBillHeaderModel().getPackageTotalWeight());
        tmsLoadingBillDetailModel.setBackType(context.getTmsShipBillHeaderModel().getBackType());
        tmsLoadingBillDetailModel.setBackReason(context.getTmsShipBillHeaderModel().getBackReason());
        tmsLoadingBillDetailModel.setStatus(context.getTmsShipBillHeaderModel().getStatus());
        tmsLoadingBillDetailModel.setMemo(context.getTmsShipBillHeaderModel().getMemo());
        tmsLoadingBillDetailModel.setSource(context.getTmsShipBillHeaderModel().getSource());
        tmsLoadingBillDetailModel.setImportBatchNumber(context.getTmsShipBillHeaderModel().getImportBatchNumber());
        tmsLoadingBillDetailModel.setOrganizationId(context.getTmsShipBillHeaderModel().getOrganizationId());
        tmsLoadingBillDetailModel.setOrganizationCode(context.getTmsShipBillHeaderModel().getOrganizationCode());
        tmsLoadingBillDetailModel.setOrganizationName(context.getTmsShipBillHeaderModel().getOrganizationName());
        tmsLoadingBillDetailModel.setDepartmentId(context.getTmsShipBillHeaderModel().getDepartmentId());
        tmsLoadingBillDetailModel.setDepartmentCode(context.getTmsShipBillHeaderModel().getDepartmentCode());
        tmsLoadingBillDetailModel.setDepartmentName(context.getTmsShipBillHeaderModel().getDepartmentName());
        tmsLoadingBillDetailModel.setEnterpriseId(context.getTmsShipBillHeaderModel().getEnterpriseId());
        tmsLoadingBillDetailModel.setEnterpriseName(context.getTmsShipBillHeaderModel().getEnterpriseName());
        tmsLoadingBillDetailModel.setExtStr1(context.getTmsShipBillHeaderModel().getExtStr1());
        tmsLoadingBillDetailModel.setExtStr2(context.getTmsShipBillHeaderModel().getExtStr2());
        tmsLoadingBillDetailModel.setExtStr3(context.getTmsShipBillHeaderModel().getExtStr3());
        tmsLoadingBillDetailModel.setExtStr4(context.getTmsShipBillHeaderModel().getExtStr4());
        tmsLoadingBillDetailModel.setExtStr5(context.getTmsShipBillHeaderModel().getExtStr5());
        tmsLoadingBillDetailModel.setExtNum1(context.getTmsShipBillHeaderModel().getExtNum1());
        tmsLoadingBillDetailModel.setExtNum2(context.getTmsShipBillHeaderModel().getExtNum2());
        tmsLoadingBillDetailModel.setExtNum3(context.getTmsShipBillHeaderModel().getExtNum3());
        tmsLoadingBillDetailModel.setExtNum4(context.getTmsShipBillHeaderModel().getExtNum4());
        tmsLoadingBillDetailModel.setExtNum5(context.getTmsShipBillHeaderModel().getExtNum5());
        tmsLoadingBillDetailModel.setExtDate1(context.getTmsShipBillHeaderModel().getExtDate1());
        tmsLoadingBillDetailModel.setExtDate2(context.getTmsShipBillHeaderModel().getExtDate2());
        tmsLoadingBillDetailModel.setExtDate3(context.getTmsShipBillHeaderModel().getExtDate3());
        tmsLoadingBillDetailModel.setExtDate4(context.getTmsShipBillHeaderModel().getExtDate4());
        tmsLoadingBillDetailModel.setExtDate5(context.getTmsShipBillHeaderModel().getExtDate5());
        tmsLoadingBillDetailModel.setCreatetime(new Date());
        tmsLoadingBillDetailModel.setCreateperson(context.getUserEntity().getNickname());
        tmsLoadingBillDetailModel.setUpdatetime(new Date());
        tmsLoadingBillDetailModel.setUpdateperson(context.getUserEntity().getNickname());
        tmsLoadingBillDetailModel.setConsigneeReturnOrderPicture(context.getTmsShipBillHeaderModel().getConsigneeReturnOrderPicture());
        tmsLoadingBillDetailModel.setDeliveryStatus(context.getTmsShipBillHeaderModel().getDeliveryStatus());
        tmsLoadingBillDetailModel.setScanStatus(context.getTmsShipBillHeaderModel().getScanStatus());
        tmsLoadingBillDetailModel.setCarrierShipbillStatus(context.getTmsShipBillHeaderModel().getCarrierShipbillStatus());
        tmsLoadingBillDetailModel.setDepartureTime(context.getTmsShipBillHeaderModel().getDepartureTime());
        tmsLoadingBillDetailModel.setDeliveryTime(context.getTmsShipBillHeaderModel().getDeliveryTime());
        tmsLoadingBillDetailModel.setCarrierId(context.getTmsShipBillHeaderModel().getCarrierId());
        tmsLoadingBillDetailModel.setCarrierCode(context.getTmsShipBillHeaderModel().getCarrierCode());
        tmsLoadingBillDetailModel.setCarrierName(context.getTmsShipBillHeaderModel().getCarrierName());
        tmsLoadingBillDetailModel.setCarrierType(context.getTmsShipBillHeaderModel().getCarrierType());
        tmsLoadingBillDetailModel.setFlowConfig(context.getTmsShipBillHeaderModel().getFlowConfig());
        tmsLoadingBillDetailModel.setCarrierFlowConfig(context.getTmsShipBillHeaderModel().getCarrierFlowConfig());
        tmsLoadingBillDetailModel.setAppTallyStatus(context.getTmsShipBillHeaderModel().getAppTallyStatus());
        tmsLoadingBillDetailModel.setSignInStatus(context.getTmsShipBillHeaderModel().getSignInStatus());
        return tmsLoadingBillDetailModel;

    }

}
