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

import com.prolog.rdc.tms.app.constant.DataDictionaryConstant;
import com.prolog.rdc.tms.app.constant.SeriaNnumberConstant;
import com.prolog.rdc.tms.app.constant.enums.DriverReceiveStatusEnum;
import com.prolog.rdc.tms.app.constant.enums.IntelligentLockEnum;
import com.prolog.rdc.tms.app.constant.enums.ShipBillTypeEnum;
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.TmsShipbillDetailModel;
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.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 退货运单新增
 * @author hongbo.pan
 * @date 2022/10/17
 */
@Component
public class ReturnShipBillAddHandle extends FlowNodeHandle {

    @Override
    public void doHandle(FlowContext context) {
        TmsShipbillHeaderModel shipBillHeaderModel = initTmsShipBillHeaderModel(context);
        shipBillHeaderModel.setIntelligentLock(IntelligentLockEnum.UN_LOCK.getCode());
        tmsShipbillHeaderMapper.save(shipBillHeaderModel);
        context.setTmsShipBillHeaderModel(shipBillHeaderModel);
        List<TmsShipbillDetailModel> shipBillDetailModelList = initTmsShipBillDetailModelList(context);
        tmsShipbillDetailMapper.saveBatch(shipBillDetailModelList);
        context.setTmsShipBillDetailModelList(shipBillDetailModelList);
    }

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

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

    @Override
    public TmsShipbillOperateLogModel buildShipBillOperateLog() {
        TmsShipbillOperateLogModel tmsShipbillOperateLogModel = new TmsShipbillOperateLogModel();
        tmsShipbillOperateLogModel.setOperateEvent(DataDictionaryConstant.SHIPBILL_STATUSNAME_CSH);
        tmsShipbillOperateLogModel.setOldStatus(DataDictionaryConstant.SHIPBILL_STATUS_CSH);
        tmsShipbillOperateLogModel.setNewStatus(DataDictionaryConstant.SHIPBILL_STATUS_CSH);
        return tmsShipbillOperateLogModel;
    }

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

    /**
     * initTmsShipBillHeaderModel
     * @param context
     * @return
     */
    private TmsShipbillHeaderModel initTmsShipBillHeaderModel(FlowContext context) {
        TmsShipbillHeaderModel tmsShipbillHeaderModel = new TmsShipbillHeaderModel();
        String shipBillId = mainDataProxy.getCodeNumberByCode(SeriaNnumberConstant.TMS_SHIPBILL_HEADER_ID);
        TmsShipbillHeaderModel shipBillHeaderModel = context.getOriginalTmsShipBillHeaderModel();
        tmsShipbillHeaderModel.setShipbillId(shipBillId);
        tmsShipbillHeaderModel.setShipbillNo(shipBillId);
//        tmsShipbillHeaderModel.setFatherShipbillId();
//        tmsShipbillHeaderModel.setFatherShipbillNo();
//        tmsShipbillHeaderModel.setOriginalShipbillId();
//        tmsShipbillHeaderModel.setOriginalShipbillNo();
//        tmsShipbillHeaderModel.setBranchId();
//        tmsShipbillHeaderModel.setBranchCode();
//        tmsShipbillHeaderModel.setBranchName();
        tmsShipbillHeaderModel.setCargoOwnerId(shipBillHeaderModel.getCargoOwnerId());
        tmsShipbillHeaderModel.setCargoOwnerCode(shipBillHeaderModel.getCargoOwnerCode());
        tmsShipbillHeaderModel.setCargoOwnerName(shipBillHeaderModel.getCargoOwnerName());
        tmsShipbillHeaderModel.setOrderId(shipBillHeaderModel.getOrderId());
        tmsShipbillHeaderModel.setOrderNo(shipBillHeaderModel.getOrderNo());
        tmsShipbillHeaderModel.setOrderDate(shipBillHeaderModel.getOrderDate());
        tmsShipbillHeaderModel.setOrderType(shipBillHeaderModel.getOrderType());
        tmsShipbillHeaderModel.setOrderBusinessType(shipBillHeaderModel.getOrderBusinessType());
        tmsShipbillHeaderModel.setWmsOrderId(shipBillHeaderModel.getWmsOrderId());
        tmsShipbillHeaderModel.setWmsOrderNo(shipBillHeaderModel.getWmsOrderNo());
        tmsShipbillHeaderModel.setTransportStatus(DataDictionaryConstant.TRANSPORT_STATUS_PENDING_SHIP);
        tmsShipbillHeaderModel.setAbnormalStatus(DataDictionaryConstant.SHIPBILL_ABNORMAL_STATUS_NO);
        tmsShipbillHeaderModel.setSplitOrderStatus(DataDictionaryConstant.SPLIT_ORDER_STATUS_UN);
        tmsShipbillHeaderModel.setSplitOrderType(DataDictionaryConstant.SPLIT_ORDER_TYPE_UN);
        tmsShipbillHeaderModel.setCarrierSplitOrderStatus(DataDictionaryConstant.CARRIER_SPLIT_ORDER_STATUS_UN);
        tmsShipbillHeaderModel.setCarrierSplitOrderType(DataDictionaryConstant.CARRIER_SPLIT_ORDER_TYPE_UN);
        tmsShipbillHeaderModel.setDeliveryMethodType(shipBillHeaderModel.getDeliveryMethodType());
        tmsShipbillHeaderModel.setTransportType(shipBillHeaderModel.getTransportType());
        tmsShipbillHeaderModel.setTemperatureRequirement(shipBillHeaderModel.getTemperatureRequirement());
//        shipBillHeaderModel.setEstimatedPickupStartTime();
//        shipBillHeaderModel.setEstimatedPickupEndTime();
//        shipBillHeaderModel.setEstimatedDeliveryStartTime();
//        shipBillHeaderModel.setEstimatedDeliveryEndTime();
//        shipBillHeaderModel.setTransportAging();
        tmsShipbillHeaderModel.setShipperType(shipBillHeaderModel.getConsigneeType());
        tmsShipbillHeaderModel.setShipperUnitId(shipBillHeaderModel.getConsigneeUnitId());
        tmsShipbillHeaderModel.setShipperUnitCode(shipBillHeaderModel.getConsigneeUnitCode());
        tmsShipbillHeaderModel.setShipperUnitName(shipBillHeaderModel.getConsigneeUnitName());
        tmsShipbillHeaderModel.setShipperId(shipBillHeaderModel.getConsigneeId());
        tmsShipbillHeaderModel.setShipperCode(shipBillHeaderModel.getConsigneeCode());
        tmsShipbillHeaderModel.setShipperName(shipBillHeaderModel.getConsigneeName());
        tmsShipbillHeaderModel.setShipperContact(shipBillHeaderModel.getConsigneeContact());
        tmsShipbillHeaderModel.setShipperPhoneNumber(shipBillHeaderModel.getConsigneePhoneNumber());
        tmsShipbillHeaderModel.setShipperLandlineNumber(shipBillHeaderModel.getConsigneeLandlineNumber());
        tmsShipbillHeaderModel.setShipperEmail(shipBillHeaderModel.getConsigneeEmail());
        tmsShipbillHeaderModel.setShipperRelatedPhoneNumber(shipBillHeaderModel.getConsigneeRelatedPhoneNumber());
        tmsShipbillHeaderModel.setShipperProvince(shipBillHeaderModel.getConsigneeProvince());
        tmsShipbillHeaderModel.setShipperProvinceName(shipBillHeaderModel.getConsigneeProvinceName());
        tmsShipbillHeaderModel.setShipperCity(shipBillHeaderModel.getConsigneeCity());
        tmsShipbillHeaderModel.setShipperCityName(shipBillHeaderModel.getConsigneeCityName());
        tmsShipbillHeaderModel.setShipperDistrict(shipBillHeaderModel.getConsigneeDistrict());
        tmsShipbillHeaderModel.setShipperDistrictName(shipBillHeaderModel.getConsigneeDistrictName());
        tmsShipbillHeaderModel.setShipperAddress(shipBillHeaderModel.getConsigneeAddress());
        tmsShipbillHeaderModel.setShipperLongitude(shipBillHeaderModel.getConsigneeLongitude());
        tmsShipbillHeaderModel.setShipperLatitude(shipBillHeaderModel.getConsigneeLatitude());
        tmsShipbillHeaderModel.setShipperMemo(shipBillHeaderModel.getConsigneeMemo());
        tmsShipbillHeaderModel.setShipperPickUpSign(DataDictionaryConstant.WHETHER_NO);
        tmsShipbillHeaderModel.setShipperAutoPickUpSign(DataDictionaryConstant.WHETHER_NO);
        tmsShipbillHeaderModel.setShipperPickUpPicture(DataDictionaryConstant.WHETHER_NO);
        tmsShipbillHeaderModel.setShipperPickUpRail(BigDecimal.ZERO);
        tmsShipbillHeaderModel.setConsigneeType(shipBillHeaderModel.getShipperType());
        tmsShipbillHeaderModel.setConsigneeUnitId(shipBillHeaderModel.getShipperUnitId());
        tmsShipbillHeaderModel.setConsigneeUnitCode(shipBillHeaderModel.getShipperUnitCode());
        tmsShipbillHeaderModel.setConsigneeUnitName(shipBillHeaderModel.getShipperUnitName());
        tmsShipbillHeaderModel.setConsigneeId(shipBillHeaderModel.getShipperId());
        tmsShipbillHeaderModel.setConsigneeCode(shipBillHeaderModel.getShipperCode());
        tmsShipbillHeaderModel.setConsigneeName(shipBillHeaderModel.getShipperName());
        tmsShipbillHeaderModel.setConsigneeContact(shipBillHeaderModel.getShipperContact());
        tmsShipbillHeaderModel.setConsigneePhoneNumber(shipBillHeaderModel.getShipperPhoneNumber());
        tmsShipbillHeaderModel.setConsigneeLandlineNumber(shipBillHeaderModel.getShipperLandlineNumber());
        tmsShipbillHeaderModel.setConsigneeEmail(shipBillHeaderModel.getShipperEmail());
        tmsShipbillHeaderModel.setConsigneeRelatedPhoneNumber(shipBillHeaderModel.getShipperRelatedPhoneNumber());
        tmsShipbillHeaderModel.setConsigneeProvince(shipBillHeaderModel.getShipperProvince());
        tmsShipbillHeaderModel.setConsigneeProvinceName(shipBillHeaderModel.getShipperProvinceName());
        tmsShipbillHeaderModel.setConsigneeCity(shipBillHeaderModel.getShipperCity());
        tmsShipbillHeaderModel.setConsigneeCityName(shipBillHeaderModel.getShipperCityName());
        tmsShipbillHeaderModel.setConsigneeDistrict(shipBillHeaderModel.getShipperDistrict());
        tmsShipbillHeaderModel.setConsigneeDistrictName(shipBillHeaderModel.getShipperDistrictName());
        tmsShipbillHeaderModel.setConsigneeAddress(shipBillHeaderModel.getShipperAddress());
        tmsShipbillHeaderModel.setConsigneeLongitude(shipBillHeaderModel.getShipperLongitude());
        tmsShipbillHeaderModel.setConsigneeLatitude(shipBillHeaderModel.getShipperLatitude());
        tmsShipbillHeaderModel.setConsigneeMemo(shipBillHeaderModel.getShipperMemo());
        tmsShipbillHeaderModel.setConsigneeDeliverySign(DataDictionaryConstant.WHETHER_NO);
        tmsShipbillHeaderModel.setConsigneeAutoDeliverySign(DataDictionaryConstant.WHETHER_NO);
        tmsShipbillHeaderModel.setConsigneeDeliveryPicture(DataDictionaryConstant.WHETHER_NO);
        tmsShipbillHeaderModel.setConsigneeDeliveryRail(BigDecimal.ZERO);
        tmsShipbillHeaderModel.setLineId(shipBillHeaderModel.getLineId());
        tmsShipbillHeaderModel.setLineCode(shipBillHeaderModel.getLineCode());
        tmsShipbillHeaderModel.setLineName(shipBillHeaderModel.getLineName());
        tmsShipbillHeaderModel.setLineDirection(shipBillHeaderModel.getLineDirection());
        tmsShipbillHeaderModel.setShippingOrder(shipBillHeaderModel.getShippingOrder());
        tmsShipbillHeaderModel.setPickUpOrder(shipBillHeaderModel.getPickUpOrder());
        tmsShipbillHeaderModel.setReturnOrderFlag(DataDictionaryConstant.WHETHER_NO);
//        tmsShipbillHeaderModel.setReturnOrderDeadline();
        tmsShipbillHeaderModel.setTotalPcs(shipBillHeaderModel.getTotalPcs());
        tmsShipbillHeaderModel.setTotalVolume(shipBillHeaderModel.getTotalVolume());
        tmsShipbillHeaderModel.setTotalWeight(shipBillHeaderModel.getTotalWeight());
        tmsShipbillHeaderModel.setActualTotalPcs(shipBillHeaderModel.getActualTotalPcs());
        tmsShipbillHeaderModel.setActualTotalVolume(shipBillHeaderModel.getActualTotalVolume());
        tmsShipbillHeaderModel.setActualTotalWeight(shipBillHeaderModel.getActualTotalWeight());
        tmsShipbillHeaderModel.setTotalDeliveryPcs(BigDecimal.ZERO);
        tmsShipbillHeaderModel.setTotalDeliveryVolume(BigDecimal.ZERO);
        tmsShipbillHeaderModel.setTotalDeliveryWeight(BigDecimal.ZERO);
        tmsShipbillHeaderModel.setPackageWholePiece(BigDecimal.ZERO);
        tmsShipbillHeaderModel.setPackageLclPiece(BigDecimal.ZERO);
        tmsShipbillHeaderModel.setPackageTotalVolume(BigDecimal.ZERO);
        tmsShipbillHeaderModel.setPackageTotalWeight(BigDecimal.ZERO);
//        tmsShipbillHeaderModel.setBackType();
//        tmsShipbillHeaderModel.setBackReason();
        tmsShipbillHeaderModel.setStatus(DataDictionaryConstant.SHIPBILL_STATUS_CSH);
        tmsShipbillHeaderModel.setMemo("系统自动退回" + shipBillHeaderModel.getShipbillId());
        tmsShipbillHeaderModel.setSource(DataDictionaryConstant.SOURCE_ADD);
//        tmsShipbillHeaderModel.setImportBatchNumber();
        tmsShipbillHeaderModel.setOrganizationId(shipBillHeaderModel.getOrganizationId());
        tmsShipbillHeaderModel.setOrganizationCode(shipBillHeaderModel.getOrganizationCode());
        tmsShipbillHeaderModel.setOrganizationName(shipBillHeaderModel.getOrganizationName());
        tmsShipbillHeaderModel.setDepartmentId(shipBillHeaderModel.getDepartmentId());
        tmsShipbillHeaderModel.setDepartmentCode(shipBillHeaderModel.getDepartmentCode());
        tmsShipbillHeaderModel.setDepartmentName(shipBillHeaderModel.getDepartmentName());
        tmsShipbillHeaderModel.setCarrierType(shipBillHeaderModel.getCarrierType());
        tmsShipbillHeaderModel.setCarrierId(shipBillHeaderModel.getCarrierId());
        tmsShipbillHeaderModel.setCarrierCode(shipBillHeaderModel.getCarrierCode());
        tmsShipbillHeaderModel.setCarrierName(shipBillHeaderModel.getCarrierName());
//        shipBillHeaderModel.setCarrierShipbillStatus();
//        shipBillHeaderModel.setDepartureTime();
//        shipBillHeaderModel.setDeliveryTime();
        tmsShipbillHeaderModel.setEnterpriseId(shipBillHeaderModel.getEnterpriseId());
        tmsShipbillHeaderModel.setEnterpriseName(shipBillHeaderModel.getEnterpriseName());
        tmsShipbillHeaderModel.setExtStr1(shipBillHeaderModel.getExtStr1());
        tmsShipbillHeaderModel.setExtStr2(shipBillHeaderModel.getExtStr2());
        tmsShipbillHeaderModel.setExtStr3(shipBillHeaderModel.getExtStr3());
        tmsShipbillHeaderModel.setExtStr4(shipBillHeaderModel.getExtStr4());
        tmsShipbillHeaderModel.setExtStr5(shipBillHeaderModel.getExtStr5());
        tmsShipbillHeaderModel.setExtNum1(shipBillHeaderModel.getExtNum1());
        tmsShipbillHeaderModel.setExtNum2(shipBillHeaderModel.getExtNum2());
        tmsShipbillHeaderModel.setExtNum3(shipBillHeaderModel.getExtNum3());
        tmsShipbillHeaderModel.setExtNum4(shipBillHeaderModel.getExtNum4());
        tmsShipbillHeaderModel.setExtNum5(shipBillHeaderModel.getExtNum5());
        tmsShipbillHeaderModel.setExtDate1(shipBillHeaderModel.getExtDate1());
        tmsShipbillHeaderModel.setExtDate2(shipBillHeaderModel.getExtDate2());
        tmsShipbillHeaderModel.setExtDate3(shipBillHeaderModel.getExtDate3());
        tmsShipbillHeaderModel.setExtDate4(shipBillHeaderModel.getExtDate4());
        tmsShipbillHeaderModel.setExtDate5(shipBillHeaderModel.getExtDate5());
        tmsShipbillHeaderModel.setCreatetime(new Date());
        tmsShipbillHeaderModel.setCreateperson(context.getUserEntity().getNickname());
        tmsShipbillHeaderModel.setUpdatetime(new Date());
        tmsShipbillHeaderModel.setUpdateperson(context.getUserEntity().getNickname());
        tmsShipbillHeaderModel.setScanStatus(DataDictionaryConstant.SCAN_STATUS_INIT);
//        tmsShipbillHeaderModel.setDeliveryStatus();
        tmsShipbillHeaderModel.setConsigneeReturnOrderPicture(DataDictionaryConstant.WHETHER_NO);
        tmsShipbillHeaderModel.setFlowConfig(context.getFlowConfig());
//        tmsShipbillHeaderModel.setCarrierFlowConfig();
//        tmsShipbillHeaderModel.setAppTallyStatus();
        tmsShipbillHeaderModel.setRelationShipbillId(shipBillHeaderModel.getShipbillId());
        tmsShipbillHeaderModel.setRelationShipbillNo(shipBillHeaderModel.getShipbillNo());
        tmsShipbillHeaderModel.setShipbillType(ShipBillTypeEnum.RETURN.getCode());
        tmsShipbillHeaderModel.setSignInStatus(SignInStatusEnum.NOT_SIGN.getCode());
        tmsShipbillHeaderModel.setDriverReceiveStatus(DriverReceiveStatusEnum.N.getCode());
        tmsShipbillHeaderModel.setShipperStationId(shipBillHeaderModel.getConsigneeStationId());
        tmsShipbillHeaderModel.setShipperStationCode(shipBillHeaderModel.getConsigneeStationCode());
        tmsShipbillHeaderModel.setShipperStationName(shipBillHeaderModel.getConsigneeStationName());
        tmsShipbillHeaderModel.setShipperStationAreas(shipBillHeaderModel.getConsigneeStationAreas());
        tmsShipbillHeaderModel.setShipperDeliveryOrder(shipBillHeaderModel.getConsigneeDeliveryOrder());
        tmsShipbillHeaderModel.setConsigneeStationId(shipBillHeaderModel.getShipperStationId());
        tmsShipbillHeaderModel.setConsigneeStationCode(shipBillHeaderModel.getShipperStationCode());
        tmsShipbillHeaderModel.setConsigneeStationName(shipBillHeaderModel.getShipperStationName());
        tmsShipbillHeaderModel.setConsigneeStationAreas(shipBillHeaderModel.getShipperStationAreas());
        tmsShipbillHeaderModel.setConsigneeDeliveryOrder(shipBillHeaderModel.getShipperDeliveryOrder());
        return tmsShipbillHeaderModel;
    }

    /**
     * initTmsShipBillDetailModelList
     * @param context
     * @return
     */
    private List<TmsShipbillDetailModel> initTmsShipBillDetailModelList(FlowContext context) {
        return context.getOriginalTmsShipBillDetailModelList().stream().map(shipBillDetailModel ->
                initTmsShipBillDetailModel(shipBillDetailModel, context)).collect(Collectors.toList());
    }

    /**
     * initTmsShipBillDetailModel
     * @param shipBillDetailModel
     * @param context
     * @return
     */
    private TmsShipbillDetailModel initTmsShipBillDetailModel(TmsShipbillDetailModel shipBillDetailModel, FlowContext context) {
        String shipBillDetailId = mainDataProxy.getCodeNumberByCode(SeriaNnumberConstant.TMS_SHIPBILL_DETAIL_ID);
        TmsShipbillDetailModel tmsShipbillDetailModel = new TmsShipbillDetailModel();
        tmsShipbillDetailModel.setId(shipBillDetailId);
        tmsShipbillDetailModel.setShipbillId(context.getTmsShipBillHeaderModel().getShipbillId());
        tmsShipbillDetailModel.setShipbillNo(context.getTmsShipBillHeaderModel().getShipbillNo());
        tmsShipbillDetailModel.setBranchId(shipBillDetailModel.getBranchId());
        tmsShipbillDetailModel.setBranchCode(shipBillDetailModel.getBranchCode());
        tmsShipbillDetailModel.setBranchName(shipBillDetailModel.getBranchName());
        tmsShipbillDetailModel.setCargoOwnerId(shipBillDetailModel.getCargoOwnerId());
        tmsShipbillDetailModel.setCargoOwnerCode(shipBillDetailModel.getCargoOwnerCode());
        tmsShipbillDetailModel.setCargoOwnerName(shipBillDetailModel.getCargoOwnerName());
        tmsShipbillDetailModel.setSeqno(shipBillDetailModel.getSeqno());
        tmsShipbillDetailModel.setOriginalSeqno(shipBillDetailModel.getOriginalSeqno());
        tmsShipbillDetailModel.setItemId(shipBillDetailModel.getItemId());
        tmsShipbillDetailModel.setItemCode(shipBillDetailModel.getItemCode());
        tmsShipbillDetailModel.setItemName(shipBillDetailModel.getItemName());
        tmsShipbillDetailModel.setItemCategoryId(shipBillDetailModel.getItemCategoryId());
        tmsShipbillDetailModel.setItemCategoryCode(shipBillDetailModel.getItemCategoryCode());
        tmsShipbillDetailModel.setItemCategoryName(shipBillDetailModel.getItemCategoryName());
        tmsShipbillDetailModel.setPackType(shipBillDetailModel.getPackType());
        tmsShipbillDetailModel.setCargoThermosphere(shipBillDetailModel.getCargoThermosphere());
        tmsShipbillDetailModel.setPcs(shipBillDetailModel.getPcs());
        tmsShipbillDetailModel.setVolume(shipBillDetailModel.getVolume());
        tmsShipbillDetailModel.setWeight(shipBillDetailModel.getWeight());
        tmsShipbillDetailModel.setMemo(shipBillDetailModel.getMemo());
        tmsShipbillDetailModel.setEnterpriseId(shipBillDetailModel.getEnterpriseId());
        tmsShipbillDetailModel.setEnterpriseName(shipBillDetailModel.getEnterpriseName());
        tmsShipbillDetailModel.setExtStr1(shipBillDetailModel.getExtStr1());
        tmsShipbillDetailModel.setExtStr2(shipBillDetailModel.getExtStr2());
        tmsShipbillDetailModel.setExtStr3(shipBillDetailModel.getExtStr3());
        tmsShipbillDetailModel.setExtStr4(shipBillDetailModel.getExtStr4());
        tmsShipbillDetailModel.setExtStr5(shipBillDetailModel.getExtStr5());
        tmsShipbillDetailModel.setExtNum1(shipBillDetailModel.getExtNum1());
        tmsShipbillDetailModel.setExtNum2(shipBillDetailModel.getExtNum2());
        tmsShipbillDetailModel.setExtNum3(shipBillDetailModel.getExtNum3());
        tmsShipbillDetailModel.setExtNum4(shipBillDetailModel.getExtNum4());
        tmsShipbillDetailModel.setExtNum5(shipBillDetailModel.getExtNum5());
        tmsShipbillDetailModel.setExtDate1(shipBillDetailModel.getExtDate1());
        tmsShipbillDetailModel.setExtDate2(shipBillDetailModel.getExtDate2());
        tmsShipbillDetailModel.setExtDate3(shipBillDetailModel.getExtDate3());
        tmsShipbillDetailModel.setExtDate4(shipBillDetailModel.getExtDate4());
        tmsShipbillDetailModel.setExtDate5(shipBillDetailModel.getExtDate5());
        tmsShipbillDetailModel.setCreatetime(new Date());
        tmsShipbillDetailModel.setCreateperson(context.getUserEntity().getNickname());
        tmsShipbillDetailModel.setUpdatetime(new Date());
        tmsShipbillDetailModel.setUpdateperson(context.getUserEntity().getNickname());
        tmsShipbillDetailModel.setInventoryPcs(0);
        tmsShipbillDetailModel.setStagingLocation(shipBillDetailModel.getStagingLocation());
        tmsShipbillDetailModel.setOrigPcs(shipBillDetailModel.getOrigPcs());
        tmsShipbillDetailModel.setClosingPcs(BigDecimal.ZERO);
        tmsShipbillDetailModel.setSignInPcs(BigDecimal.ZERO);
        tmsShipbillDetailModel.setPickUpPcs(BigDecimal.ZERO);
        tmsShipbillDetailModel.setDeliveryPcs(BigDecimal.ZERO);
        tmsShipbillDetailModel.setScanStatus(DataDictionaryConstant.SCAN_STATUS_INIT);
        tmsShipbillDetailModel.setPlanDeliveryPcs(shipBillDetailModel.getPcs());
        return tmsShipbillDetailModel;
    }
}

