@Override
  public TmPieces updatePiecesInfoForStockIn(
      CsmStockInPiecesUpdateVo updateVo, ServiceOptParamLinkerVo linkerVo) {

    TmPieces updatePieces = null;
    if (updateVo.getTmPiecesId() == null) {
      updatePieces = new TmPieces();
      updatePieces.setPiecesNo(servicePvd.commonSeqNumberService.generatePiecesNo());
    }
    if (updateVo.getTmPiecesId() != null) {
      updatePieces = querier.selectTmPiecesById(updateVo.getTmPiecesId());
    }

    // Inser or Update pieces
    updatePieces.setActualWeight(updateVo.getActualWeight());
    updatePieces.setLength(updateVo.getLength());
    updatePieces.setWidth(updateVo.getWidth());
    updatePieces.setHeight(updateVo.getHeight());
    updatePieces.setVolumeWeight(updateVo.getVolumeWeight());
    updatePieces.setMemberCode(updateVo.getMemberCode());
    updatePieces.setLogisticsNo(StringUtils.toUpperAndTrim(updateVo.getReferenceNo()));
    updatePieces.setWarehouseCode(linkerVo.getWarehouseCode());
    updatePieces.setMemo(updateVo.getMemo());
    if (updatePieces.getCheckDate() == null)
      updatePieces.setCheckDate(DateUtils.getCurrentGMTDate());
    updatePieces.setTmConsignmentId(updateVo.getTmConsignment().getTmConsignmentId());
    updatePieces.setConsignmentNo(updateVo.getTmConsignment().getConsignmentNo());
    updatePieces.setCompanyCode(linkerVo.getCompanyCode());

    updatePieces =
        tmPiecesDao.saveTmPieces(updatePieces, updateVo.getUserName(), updateVo.getControllerId());

    // Insert or Update pieces current and history
    String memo = StringUtils.concat(linkerVo.getWarehouseDesc(), " 入库");
    ;
    if (updatePieces.getActualWeight() != null) {
      memo =
          StringUtils.concat(
              memo, " 实重 ", updatePieces.getActualWeight().toString(), linkerVo.getWeightUnit());
    }

    ComPiecesStatusUpdateVo updatePiecesStatusVo =
        servicePvd.commonPiecesService.createPiecesStatusUpdateVo(
            updatePieces.getTmPiecesId(),
            updatePieces.getPiecesNo(),
            CodeConstants.PIECES_ACTION.CI,
            memo,
            updateVo.getControllerId(),
            linkerVo);
    servicePvd.commonPiecesService.updatePiecesStatus(updatePiecesStatusVo);

    return updatePieces;
  }
  @Override
  public void formatCsmStockInUpdateVo(CsmStockInReqDto reqDto) {

    if (reqDto.getActualWeight() != null) {
      reqDto.setActualWeight(reqDto.getActualWeight().setScale(2, BigDecimal.ROUND_UP));
    }

    if (reqDto.getVolumeWeight() != null) {
      reqDto.setVolumeWeight(reqDto.getVolumeWeight().setScale(2, BigDecimal.ROUND_UP));
      reqDto.setLength(reqDto.getLength().setScale(2, BigDecimal.ROUND_UP));
      reqDto.setWidth(reqDto.getWidth().setScale(2, BigDecimal.ROUND_UP));
      reqDto.setHeight(reqDto.getHeight().setScale(2, BigDecimal.ROUND_UP));
    }

    reqDto.setReferenceNo(StringUtils.toUpperAndTrim(reqDto.getReferenceNo()));
  }